Skip to content

Commit 0717a0a

Browse files
tec: Upgrade Minz to the last version
2 parents 8741c97 + 01f5391 commit 0717a0a

File tree

253 files changed

+8481
-11638
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

253 files changed

+8481
-11638
lines changed

<

Lines changed: 628 additions & 0 deletions
Large diffs are not rendered by default.

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@
66

77
PHP 8.1+ is now required. Please check your version before updating flusio!
88

9+
The CLI command to execute a single job has changed.
10+
You should now execute:
11+
12+
```console
13+
$ php cli jobs watch --stop-after=1
14+
```
15+
16+
The `run` command now takes a job id to execute a specific job.
17+
918
## 2023-04-07 - v0.54
1019

1120
### Security

Makefile

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
USER = $(shell id -u):$(shell id -g)
44

5+
DOCKER_COMPOSE = docker-compose -p flusio -f docker/docker-compose.yml
6+
57
ifdef NO_DOCKER
68
PHP = php
79
COMPOSER = composer
@@ -33,15 +35,15 @@ endif
3335
.PHONY: docker-start
3436
docker-start: .env ## Start a development server with Docker
3537
@echo "Running webserver on http://localhost:8000"
36-
docker-compose -p flusio -f docker/docker-compose.yml up
38+
$(DOCKER_COMPOSE) up
3739

3840
.PHONY: docker-clean
3941
docker-clean: ## Stop and clean Docker server
40-
docker-compose -p flusio -f docker/docker-compose.yml down
42+
$(DOCKER_COMPOSE) down
4143

4244
.PHONY: docker-build
4345
docker-build: ## Rebuild the Docker images
44-
docker-compose -p flusio -f docker/docker-compose.yml build
46+
$(DOCKER_COMPOSE) build
4547

4648
.PHONY: install
4749
install: ## Install the dependencies
@@ -50,10 +52,7 @@ install: ## Install the dependencies
5052

5153
.PHONY: setup
5254
setup: .env ## Setup the application system
53-
$(CLI) system setup
54-
55-
.PHONY: update
56-
update: setup ## Update the application
55+
$(CLI) migrations setup --seed
5756

5857
.PHONY: rollback
5958
rollback: ## Reverse the last migration
@@ -65,8 +64,12 @@ endif
6564

6665
.PHONY: reset
6766
reset: ## Reset the database
68-
rm data/migrations_version.txt || true
69-
$(CLI) system setup
67+
ifndef FORCE
68+
$(error Please run the operation with FORCE=true)
69+
endif
70+
$(DOCKER_COMPOSE) stop job_worker
71+
$(CLI) migrations reset --force --seed
72+
$(DOCKER_COMPOSE) start job_worker
7073

7174
.PHONY: icons-build
7275
icons-build: ## Build the icons asset

cli

Lines changed: 2 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -16,66 +16,11 @@ $app_path = __DIR__;
1616
include $app_path . '/autoload.php';
1717
\Minz\Configuration::load('dotenv', $app_path);
1818
\Minz\Configuration::$no_syslog_output = true;
19-
\Minz\Environment::initialize();
2019

21-
// Read command line parameters to create a Request
22-
$command = [];
23-
$parameters = [];
24-
25-
// We need to skip the first argument which is the name of the script
26-
$arguments = array_slice($argv, 1);
27-
foreach ($arguments as $argument) {
28-
$result = preg_match('/^--(?P<option>\w+)(=(?P<argument>.+))?$/sm', $argument, $matches);
29-
if ($result) {
30-
$parameters[$matches['option']] = $matches['argument'] ?? true;
31-
} else {
32-
$command[] = $argument;
33-
}
34-
}
35-
36-
$request_uri = implode('/', $command);
37-
if (!$request_uri) {
38-
$request_uri = '/help';
39-
} elseif ($request_uri[0] !== '/') {
40-
$request_uri = '/' . $request_uri;
41-
}
42-
43-
try {
44-
$request = new \Minz\Request('cli', $request_uri, $parameters);
45-
} catch (\Minz\Errors\RequestError $e) {
46-
die($e->getMessage() . "\n");
47-
}
48-
49-
$request->setParam('bin', $argv[0]);
20+
$request = \Minz\Request::initFromCli($argv);
5021

5122
// Initialize the Application and execute the request to get a Response
5223
$application = new \flusio\cli\Application();
5324
$response = $application->run($request);
5425

55-
if ($response instanceof Generator) {
56-
// This is used by the JobsWorker#watch method in order to provide a
57-
// long-running service.
58-
foreach ($response as $response_part) {
59-
$output = $response_part->render();
60-
if ($output) {
61-
echo $output . "\n";
62-
}
63-
}
64-
65-
exit(0);
66-
} else {
67-
// Display the content
68-
$output = $response->render();
69-
if ($output && $output[-1] === "\n") {
70-
echo $output;
71-
} elseif ($output) {
72-
echo $output . "\n";
73-
}
74-
75-
$code = $response->code();
76-
if ($code >= 200 && $code < 300) {
77-
exit(0);
78-
} else {
79-
exit(1);
80-
}
81-
}
26+
\Minz\Response::sendToCli($response);

configuration/environment_development.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
'feeds_links_keep_minimum' => $feeds_links_keep_minimum,
5757
'feeds_links_keep_maximum' => $feeds_links_keep_maximum,
5858
'feeds_links_keep_period' => $feeds_links_keep_period,
59-
'job_adapter' => 'database',
6059
'job_feeds_sync_count' => $job_feeds_sync_count,
6160
'job_links_sync_count' => $job_links_sync_count,
6261
'server_ips' => $server_ips,
@@ -86,4 +85,6 @@
8685
'secure' => $dotenv->pop('SMTP_SECURE', ''),
8786
],
8887
],
88+
89+
'jobs_adapter' => 'database',
8990
];

configuration/environment_production.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
'feeds_links_keep_minimum' => $feeds_links_keep_minimum,
6060
'feeds_links_keep_maximum' => $feeds_links_keep_maximum,
6161
'feeds_links_keep_period' => $feeds_links_keep_period,
62-
'job_adapter' => 'database',
6362
'job_feeds_sync_count' => $job_feeds_sync_count,
6463
'job_links_sync_count' => $job_links_sync_count,
6564
'server_ips' => $server_ips,
@@ -87,4 +86,6 @@
8786
'secure' => $dotenv->pop('SMTP_SECURE', ''),
8887
],
8988
],
89+
90+
'jobs_adapter' => 'database',
9091
];

configuration/environment_test.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
$db_port = intval($dotenv->pop('DB_PORT', '5432'));
55
$db_name = 'flusio_test';
66

7-
$temporary_directory = sys_get_temp_dir() . '/flusio/' . \flusio\utils\Random::hex(10);
7+
$temporary_directory = sys_get_temp_dir() . '/flusio/' . \Minz\Random::hex(10);
88
$data_directory = $temporary_directory . '/data';
99
$cache_directory = $temporary_directory . '/cache';
1010
$media_directory = $temporary_directory . '/media';
@@ -47,7 +47,6 @@
4747
'feeds_links_keep_period' => 0,
4848
'feeds_links_keep_minimum' => 0,
4949
'feeds_links_keep_maximum' => 0,
50-
'job_adapter' => 'test',
5150
'job_feeds_sync_count' => 1,
5251
'job_links_sync_count' => 1,
5352
'server_ips' => [],
@@ -67,6 +66,8 @@
6766
'from' => 'root@localhost',
6867
],
6968

69+
'jobs_adapter' => 'test',
70+
7071
'data_path' => $data_directory,
7172
'tmp_path' => $temporary_directory,
7273
'no_syslog_output' => true,

docs/errors.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ should be a `bad request` HTTP response returning the current `GET` view:
7676

7777
```php
7878
$csrf = $request->param('csrf');
79-
if (!\Minz\CSRF::validate($csrf)) {
79+
if (!\Minz\Csrf::validate($csrf)) {
8080
return Response::badRequest('get view pointer', [
8181
'error' => _('A security verification failed: you should retry to submit the form.'),
8282
]);
@@ -158,7 +158,7 @@ Or if an error is expected, you should store the error message as a `Flash`
158158
variable and redirect to the `from` parameter:
159159

160160
```php
161-
utils\Flash::set('error', _('A problem happened.'));
161+
\Minz\Flash::set('error', _('A problem happened.'));
162162
return Response::found($from);
163163
```
164164

docs/production.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ flusio# chmod 400 .env
8484
You must now load the SQL schema to your database. You can do it with:
8585

8686
```console
87-
flusio# sudo -u www-data php cli system setup
87+
flusio# sudo -u www-data php cli migrations setup --seed
8888
flusio# # OR via make
8989
flusio# sudo -u www-data make setup NO_DOCKER=true
9090
```
@@ -192,7 +192,7 @@ have permission on your server to create a new service. An alternative is to
192192
setup a cron task:
193193

194194
```cron
195-
* * * * * www-data php /var/www/flusio/cli jobs run >/dev/null 2>&1
195+
* * * * * www-data php /var/www/flusio/cli jobs watch --stop-after=1 >/dev/null 2>&1
196196
```
197197

198198
It will find and run a single job every minute. It’s less efficient than a

docs/update.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ flusio# chown -R www-data:www-data .
2525
Then, apply the migrations and load seeds with:
2626

2727
```console
28-
flusio$ sudo -u www-data make update NO_DOCKER=true
28+
flusio$ sudo -u www-data make setup NO_DOCKER=true
2929
```
3030

3131
Finally, you might need to restart PHP and the job worker so it detects
@@ -63,8 +63,8 @@ flusio$ git checkout PREVIOUS_TAG
6363
If something goes really wrong with the database, you can use the joker command:
6464

6565
```console
66-
flusio$ sudo -u www-data make reset NO_DOCKER=true
66+
flusio$ sudo -u www-data make reset FORCE=true
6767
```
6868

69-
It will reset the database and reload the schema. **Obviously, you should avoid
70-
this command in production or you will erase all the data.**
69+
It will reset the database and reload the schema. **Note this command doesn't
70+
work in production.**

0 commit comments

Comments
 (0)