From abbf97bcdec11ebbe17974264908795a32fc5ad4 Mon Sep 17 00:00:00 2001 From: Anton Medvedev Date: Mon, 9 Jan 2023 10:02:08 +0100 Subject: [PATCH 1/7] Test on php 8.2 as well --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8fb575716..e7398c110 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-versions: [ '7.3', '7.4', '8.0', '8.1' ] + php-versions: [ '7.3', '7.4', '8.0', '8.1', '8.2' ] steps: - uses: actions/checkout@v2 From 473cf1a1130f69dfa97fb3f16c8fe950544dbfe2 Mon Sep 17 00:00:00 2001 From: Anton Medvedev Date: Mon, 9 Jan 2023 10:04:17 +0100 Subject: [PATCH 2/7] Update symfony/console to ^5.4.9 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 8a8a3bb49..4a26ba956 100644 --- a/composer.json +++ b/composer.json @@ -46,7 +46,7 @@ "justinrainbow/json-schema": "^5.2", "psr/http-message": "^1", "react/http": "^1.5", - "symfony/console": "^5", + "symfony/console": "^5.4.9", "symfony/polyfill-php80": "^1.22", "symfony/polyfill-php81": "^1.26", "symfony/process": "^5", From c16626a081a74023b8552fcd501feb976c39846a Mon Sep 17 00:00:00 2001 From: Anton Medvedev Date: Mon, 9 Jan 2023 10:16:18 +0100 Subject: [PATCH 3/7] Update symfony/console to ^5.4.9 --- composer.lock | 47 ++++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/composer.lock b/composer.lock index 507683509..ed544b713 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "81022abe0ce3de12326a19b51217ced3", + "content-hash": "2e4a876ba583ea7b5ddf4bebd46c0262", "packages": [ { "name": "evenement/evenement", @@ -1083,16 +1083,16 @@ }, { "name": "symfony/console", - "version": "v5.4.5", + "version": "v5.4.17", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "d8111acc99876953f52fe16d4c50eb60940d49ad" + "reference": "58422fdcb0e715ed05b385f70d3e8b5ed4bbd45f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/d8111acc99876953f52fe16d4c50eb60940d49ad", - "reference": "d8111acc99876953f52fe16d4c50eb60940d49ad", + "url": "https://api.github.com/repos/symfony/console/zipball/58422fdcb0e715ed05b385f70d3e8b5ed4bbd45f", + "reference": "58422fdcb0e715ed05b385f70d3e8b5ed4bbd45f", "shasum": "" }, "require": { @@ -1162,7 +1162,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v5.4.5" + "source": "https://github.com/symfony/console/tree/v5.4.17" }, "funding": [ { @@ -1178,7 +1178,7 @@ "type": "tidelift" } ], - "time": "2022-02-24T12:45:35+00:00" + "time": "2022-12-28T14:15:31+00:00" }, { "name": "symfony/deprecation-contracts", @@ -1741,16 +1741,16 @@ }, { "name": "symfony/polyfill-php81", - "version": "v1.26.0", + "version": "v1.28.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php81.git", - "reference": "13f6d1271c663dc5ae9fb843a8f16521db7687a1" + "reference": "7581cd600fa9fd681b797d00b02f068e2f13263b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/13f6d1271c663dc5ae9fb843a8f16521db7687a1", - "reference": "13f6d1271c663dc5ae9fb843a8f16521db7687a1", + "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/7581cd600fa9fd681b797d00b02f068e2f13263b", + "reference": "7581cd600fa9fd681b797d00b02f068e2f13263b", "shasum": "" }, "require": { @@ -1759,7 +1759,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.26-dev" + "dev-main": "1.28-dev" }, "thanks": { "name": "symfony/polyfill", @@ -1800,7 +1800,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php81/tree/v1.26.0" + "source": "https://github.com/symfony/polyfill-php81/tree/v1.28.0" }, "funding": [ { @@ -1816,7 +1816,7 @@ "type": "tidelift" } ], - "time": "2022-05-24T11:49:31+00:00" + "time": "2023-01-26T09:26:14+00:00" }, { "name": "symfony/process", @@ -3055,27 +3055,28 @@ }, { "name": "phpspec/prophecy", - "version": "v1.15.0", + "version": "v1.17.0", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "bbcd7380b0ebf3961ee21409db7b38bc31d69a13" + "reference": "15873c65b207b07765dbc3c95d20fdf4a320cbe2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/bbcd7380b0ebf3961ee21409db7b38bc31d69a13", - "reference": "bbcd7380b0ebf3961ee21409db7b38bc31d69a13", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/15873c65b207b07765dbc3c95d20fdf4a320cbe2", + "reference": "15873c65b207b07765dbc3c95d20fdf4a320cbe2", "shasum": "" }, "require": { - "doctrine/instantiator": "^1.2", - "php": "^7.2 || ~8.0, <8.2", + "doctrine/instantiator": "^1.2 || ^2.0", + "php": "^7.2 || 8.0.* || 8.1.* || 8.2.*", "phpdocumentor/reflection-docblock": "^5.2", "sebastian/comparator": "^3.0 || ^4.0", "sebastian/recursion-context": "^3.0 || ^4.0" }, "require-dev": { "phpspec/phpspec": "^6.0 || ^7.0", + "phpstan/phpstan": "^1.9", "phpunit/phpunit": "^8.0 || ^9.0" }, "type": "library", @@ -3116,9 +3117,9 @@ ], "support": { "issues": "https://github.com/phpspec/prophecy/issues", - "source": "https://github.com/phpspec/prophecy/tree/v1.15.0" + "source": "https://github.com/phpspec/prophecy/tree/v1.17.0" }, - "time": "2021-12-08T12:19:24+00:00" + "time": "2023-02-02T15:41:36+00:00" }, { "name": "phpstan/phpdoc-parser", @@ -4894,5 +4895,5 @@ "ext-json": "*" }, "platform-dev": [], - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.2.0" } From b85af25c07691761f9fee55a01d4eba0ab4c6474 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 14 Jun 2023 15:00:13 +0200 Subject: [PATCH 4/7] Update php.php to 8.2 (#3619) (cherry picked from commit 981d5f6fe292c2463ec9aae305a78a0fd45d98ff) --- recipe/provision/php.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipe/provision/php.php b/recipe/provision/php.php index d107e284a..175931c79 100644 --- a/recipe/provision/php.php +++ b/recipe/provision/php.php @@ -2,7 +2,7 @@ namespace Deployer; set('php_version', function () { - return ask(' What PHP version to install? ', '8.1', ['5.6', '7.4', '8.0', '8.1']); + return ask(' What PHP version to install? ', '8.2', ['5.6', '7.4', '8.0', '8.1', '8.2']); }); desc('Installs PHP packages'); From ecd527d43d188bcd60665f409b85ef8a92816be0 Mon Sep 17 00:00:00 2001 From: Mykola Orlenko Date: Fri, 29 Sep 2023 10:30:09 +0200 Subject: [PATCH 5/7] Magento 2: Cache key id prefix (#3453) (cherry picked from commit 7fa09a2299ab8d9690ecdbb49d6c5dde3f33d5cb) --- composer.json | 3 +- composer.lock | 75 +++++++++++++++++- docs/contrib/cachetool.md | 15 ++-- docs/recipe/magento2.md | 148 +++++++++++++++++++++++------------ docs/recipe/provision/php.md | 2 +- recipe/magento2.php | 57 ++++++++++++++ 6 files changed, 241 insertions(+), 59 deletions(-) diff --git a/composer.json b/composer.json index 4a26ba956..ccf5d749b 100644 --- a/composer.json +++ b/composer.json @@ -58,7 +58,8 @@ "phpunit/php-code-coverage": "^9.2", "phpunit/phpunit": "^9.3", "slevomat/coding-standard": "^7.0", - "squizlabs/php_codesniffer": "^3.5" + "squizlabs/php_codesniffer": "^3.5", + "symfony/var-exporter": "^5.4" }, "config": { "sort-packages": true, diff --git a/composer.lock b/composer.lock index ed544b713..edfc2b1d1 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "2e4a876ba583ea7b5ddf4bebd46c0262", + "content-hash": "a8fcdbe293cf508305b9865ac9821da4", "packages": [ { "name": "evenement/evenement", @@ -4776,6 +4776,79 @@ }, "time": "2021-12-12T21:44:58+00:00" }, + { + "name": "symfony/var-exporter", + "version": "v5.4.21", + "source": { + "type": "git", + "url": "https://github.com/symfony/var-exporter.git", + "reference": "be74908a6942fdd331554b3cec27ff41b45ccad4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/var-exporter/zipball/be74908a6942fdd331554b3cec27ff41b45ccad4", + "reference": "be74908a6942fdd331554b3cec27ff41b45ccad4", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/polyfill-php80": "^1.16" + }, + "require-dev": { + "symfony/var-dumper": "^4.4.9|^5.0.9|^6.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\VarExporter\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Allows exporting any serializable PHP data structure to plain PHP code", + "homepage": "https://symfony.com", + "keywords": [ + "clone", + "construct", + "export", + "hydrate", + "instantiate", + "serialize" + ], + "support": { + "source": "https://github.com/symfony/var-exporter/tree/v5.4.21" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-02-21T19:46:44+00:00" + }, { "name": "theseer/tokenizer", "version": "1.2.1", diff --git a/docs/contrib/cachetool.md b/docs/contrib/cachetool.md index 646652e5f..671eb7eaa 100644 --- a/docs/contrib/cachetool.md +++ b/docs/contrib/cachetool.md @@ -102,27 +102,28 @@ The value of this configuration is autogenerated on access. ### cachetool_url -[Source](https://github.com/deployphp/deployer/blob/master/contrib/cachetool.php#L94) +[Source](https://github.com/deployphp/deployer/blob/master/contrib/cachetool.php#L95) URL to download cachetool from if it is not available +CacheTool 9.x works with PHP >=8.1 CacheTool 8.x works with PHP >=8.0 CacheTool 7.x works with PHP >=7.3 ```php title="Default value" -'https://github.com/gordalina/cachetool/releases/download/7.0.0/cachetool.phar' +'https://github.com/gordalina/cachetool/releases/download/9.0.0/cachetool.phar' ``` ### cachetool_args -[Source](https://github.com/deployphp/deployer/blob/master/contrib/cachetool.php#L95) +[Source](https://github.com/deployphp/deployer/blob/master/contrib/cachetool.php#L96) ### bin/cachetool -[Source](https://github.com/deployphp/deployer/blob/master/contrib/cachetool.php#L101) +[Source](https://github.com/deployphp/deployer/blob/master/contrib/cachetool.php#L102) Path to the executable cachetool binary (cachetool.phar) @@ -138,7 +139,7 @@ The value of this configuration is autogenerated on access. ## Tasks ### cachetool:clear:opcache -[Source](https://github.com/deployphp/deployer/blob/master/contrib/cachetool.php#L120) +[Source](https://github.com/deployphp/deployer/blob/master/contrib/cachetool.php#L121) Clears OPcode cache. @@ -146,7 +147,7 @@ Clear opcache cache ### cachetool:clear:apcu -[Source](https://github.com/deployphp/deployer/blob/master/contrib/cachetool.php#L158) +[Source](https://github.com/deployphp/deployer/blob/master/contrib/cachetool.php#L159) Clears APCu system cache. @@ -154,7 +155,7 @@ Clear APCU cache ### cachetool:clear:stat -[Source](https://github.com/deployphp/deployer/blob/master/contrib/cachetool.php#L173) +[Source](https://github.com/deployphp/deployer/blob/master/contrib/cachetool.php#L174) Clears file status and realpath caches. diff --git a/docs/recipe/magento2.md b/docs/recipe/magento2.md index 02392852d..4c20f6b35 100644 --- a/docs/recipe/magento2.md +++ b/docs/recipe/magento2.md @@ -42,8 +42,10 @@ The [deploy](#deploy) task of **Magento 2** consists of: * [magento:build](/docs/recipe/magento2.md#magentobuild) – Magento2 build operations * [magento:compile](/docs/recipe/magento2.md#magentocompile) – Compiles magento di * [magento:deploy:assets](/docs/recipe/magento2.md#magentodeployassets) – Deploys assets + * [magento:maintenance:enable-if-needed](/docs/recipe/magento2.md#magentomaintenanceenable-if-needed) – Set maintenance mode if needed * [magento:config:import](/docs/recipe/magento2.md#magentoconfigimport) – Config Import * [magento:upgrade:db](/docs/recipe/magento2.md#magentoupgradedb) – Upgrades magento database + * [magento:maintenance:disable](/docs/recipe/magento2.md#magentomaintenancedisable) – Disables maintenance mode * [magento:cache:flush](/docs/recipe/magento2.md#magentocacheflush) – Flushes Magento Cache * [deploy:publish](/docs/recipe/common.md#deploypublish) – Publishes the release * [deploy:symlink](/docs/recipe/deploy/symlink.md#deploysymlink) – Creates symlink to release @@ -56,7 +58,7 @@ The magento2 recipe is based on the [common](/docs/recipe/common.md) recipe. ## Configuration ### static_content_locales -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L23) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L26) By default setup:static-content:deploy uses `en_US`. To change that, put `set('static_content_locales', 'en_US de_DE');` @@ -68,7 +70,7 @@ in you deployer script. ### magento_themes -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L40) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L43) You can also set the themes to run against. By default it'll deploy all themes - `add('magento_themes', ['Magento/luma', 'Magento/backend']);` @@ -92,14 +94,14 @@ set('magento_themes', [ ### static_deploy_options -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L45) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L48) Static content deployment options, e.g. '--no-parent' ### split_static_deployment -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L48) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L51) Deploy frontend and adminhtml together as default @@ -109,7 +111,7 @@ false ### static_content_locales_backend -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L51) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L54) Use the default languages for the backend as default @@ -119,7 +121,7 @@ Use the default languages for the backend as default ### magento_themes_backend -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L55) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L58) backend themes to deploy. Only used if split_static_deployment=true This setting supports the same options/structure as [magento_themes](/docs/recipe/magento2.md#magento_themes) @@ -130,7 +132,7 @@ This setting supports the same options/structure as [magento_themes](/docs/recip ### static_content_jobs -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L61) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L64) Also set the number of conccurent jobs to run. The default is 1 Update using: `set('static_content_jobs', '1');` @@ -141,7 +143,7 @@ Update using: `set('static_content_jobs', '1');` ### content_version -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L63) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L66) @@ -151,7 +153,7 @@ return time(); ### magento_dir -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L68) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L71) Magento directory relative to repository root. Use "." (default) if it is not located in a subdirectory @@ -161,7 +163,7 @@ Magento directory relative to repository root. Use "." (default) if it is not lo ### shared_files -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L71) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L74) Overrides [shared_files](/docs/recipe/deploy/shared.md#shared_files) from `recipe/deploy/shared.php`. @@ -176,7 +178,7 @@ Overrides [shared_files](/docs/recipe/deploy/shared.md#shared_files) from `recip ### shared_dirs -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L75) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L78) Overrides [shared_dirs](/docs/recipe/deploy/shared.md#shared_dirs) from `recipe/deploy/shared.php`. @@ -201,7 +203,7 @@ Overrides [shared_dirs](/docs/recipe/deploy/shared.md#shared_dirs) from `recipe/ ### writable_dirs -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L89) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L92) Overrides [writable_dirs](/docs/recipe/deploy/writable.md#writable_dirs) from `recipe/deploy/writable.php`. @@ -219,7 +221,7 @@ Overrides [writable_dirs](/docs/recipe/deploy/writable.md#writable_dirs) from `r ### clear_paths -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L96) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L99) Overrides [clear_paths](/docs/recipe/deploy/clear_paths.md#clear_paths) from `recipe/deploy/clear_paths.php`. @@ -238,7 +240,7 @@ Overrides [clear_paths](/docs/recipe/deploy/clear_paths.md#clear_paths) from `re ### bin/magento -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L105) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L108) @@ -248,7 +250,7 @@ Overrides [clear_paths](/docs/recipe/deploy/clear_paths.md#clear_paths) from `re ### magento_version -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L107) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L110) @@ -260,20 +262,30 @@ return $matches[0] ?? '2.0'; ``` -### maintenance_mode_status_active -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L114) +### config_import_needed +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L117) +:::info Autogenerated +The value of this configuration is autogenerated on access. +::: + + + + +### database_upgrade_needed +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L131) + + +:::info Autogenerated +The value of this configuration is autogenerated on access. +::: + -```php title="Default value" -// detect maintenance mode active -$maintenanceModeStatusOutput = run("{{bin/php}} {{release_or_current_path}}/{{bin/magento}} maintenance:status"); -return strpos($maintenanceModeStatusOutput, MAINTENANCE_MODE_ACTIVE_OUTPUT_MSG) !== false; -``` ### enable_zerodowntime -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L121) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L146) Deploy without setting maintenance mode if possible @@ -282,8 +294,18 @@ true ``` +### use_redis_cache_id +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L149) + +deploy with auto updating cache index_prefix + +```php title="Default value" +false +``` + + ### artifact_file -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L309) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L304) artifact deployment section settings section @@ -294,7 +316,7 @@ settings section ### artifact_dir -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L310) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L305) @@ -304,7 +326,7 @@ settings section ### artifact_excludes_file -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L311) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L306) @@ -314,7 +336,7 @@ settings section ### artifact_path -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L313) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L308) @@ -327,7 +349,7 @@ return get('artifact_dir') . '/' . get('artifact_file'); ### bin/tar -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L320) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L315) :::info Autogenerated @@ -338,14 +360,14 @@ The value of this configuration is autogenerated on access. ### additional_shared_files -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L381) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L376) Array of shared files that will be added to the default shared_files without overriding ### additional_shared_dirs -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L383) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L378) Array of shared directories that will be added to the default shared_dirs without overriding @@ -355,7 +377,7 @@ Array of shared directories that will be added to the default shared_dirs withou ## Tasks ### magento:compile -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L125) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L153) Compiles magento di. @@ -363,7 +385,7 @@ Tasks ### magento:deploy:assets -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L131) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L159) Deploys assets. @@ -371,7 +393,7 @@ Deploys assets. ### magento:deploy:assets:adminhtml -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L145) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L173) Deploys assets for backend only. @@ -379,7 +401,7 @@ Deploys assets for backend only. ### magento:deploy:assets:frontend -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L150) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L178) Deploys assets for frontend only. @@ -387,7 +409,7 @@ Deploys assets for frontend only. ### magento:sync:content_version -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L198) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L226) Syncs content version. @@ -395,7 +417,7 @@ Syncs content version. ### magento:maintenance:enable -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L208) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L236) Enables maintenance mode. @@ -403,15 +425,23 @@ Enables maintenance mode. ### magento:maintenance:disable -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L213) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L241) Disables maintenance mode. +### magento:maintenance:enable-if-needed +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L246) + +Set maintenance mode if needed. + + + + ### magento:config:import -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L218) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L253) Config Import. @@ -419,7 +449,7 @@ Config Import. ### magento:upgrade:db -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L253) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L262) Upgrades magento database. @@ -427,7 +457,7 @@ Upgrades magento database. ### magento:cache:flush -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L280) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L273) Flushes Magento Cache. @@ -435,7 +465,7 @@ Flushes Magento Cache. ### deploy:magento -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L285) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L278) Magento2 deployment operations. @@ -444,13 +474,15 @@ Magento2 deployment operations. This task is group task which contains next tasks: * [magento:build](/docs/recipe/magento2.md#magentobuild) +* [magento:maintenance:enable-if-needed](/docs/recipe/magento2.md#magentomaintenanceenable-if-needed) * [magento:config:import](/docs/recipe/magento2.md#magentoconfigimport) * [magento:upgrade:db](/docs/recipe/magento2.md#magentoupgradedb) +* [magento:maintenance:disable](/docs/recipe/magento2.md#magentomaintenancedisable) * [magento:cache:flush](/docs/recipe/magento2.md#magentocacheflush) ### magento:build -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L293) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L288) Magento2 build operations. @@ -463,7 +495,7 @@ This task is group task which contains next tasks: ### deploy -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L299) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L294) Deploys your project. @@ -479,7 +511,7 @@ This task is group task which contains next tasks: ### artifact:package -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L330) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L325) Packages all relevant files in an artifact. @@ -487,7 +519,7 @@ tasks section ### artifact:upload -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L340) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L335) Uploads artifact in release folder for extraction. @@ -495,7 +527,7 @@ Uploads artifact in release folder for extraction. ### artifact:extract -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L345) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L340) Extracts artifact in release path. @@ -503,7 +535,7 @@ Extracts artifact in release path. ### build:remove-generated -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L351) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L346) Clears generated files prior to building. @@ -511,7 +543,7 @@ Clears generated files prior to building. ### build:prepare -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L356) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L351) Prepare local artifact build. @@ -519,10 +551,28 @@ Prepare local artifact build. ### deploy:additional-shared -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L387) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L382) Adds additional files and dirs to the list of shared files and dirs. +### magento:set_cache_prefix +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L393) + +Update cache id_prefix. + +Update cache id_prefix on deploy so that you are compiling against a fresh cache +Reference Issue: https://github.com/davidalger/capistrano-magento2/issues/151 +use set('use_redis_cache_id') in your deployer script to enable + + +### magento:cleanup_cache_prefix +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L426) + +Cleanup cache id_prefix env files. + +After successful deployment, move the tmp_env.php file to env.php ready for next deployment + + diff --git a/docs/recipe/provision/php.md b/docs/recipe/provision/php.md index 0ccbdb9da..abf3a5986 100644 --- a/docs/recipe/provision/php.md +++ b/docs/recipe/provision/php.md @@ -18,7 +18,7 @@ require 'recipe/provision/php.php'; ```php title="Default value" -return ask(' What PHP version to install? ', '8.1', ['5.6', '7.4', '8.0', '8.1']); +return ask(' What PHP version to install? ', '8.2', ['5.6', '7.4', '8.0', '8.1', '8.2']); ``` diff --git a/recipe/magento2.php b/recipe/magento2.php index 7ff560521..6f8dbebb9 100644 --- a/recipe/magento2.php +++ b/recipe/magento2.php @@ -8,10 +8,13 @@ use Deployer\Exception\GracefulShutdownException; use Deployer\Exception\RunException; use Deployer\Host\Host; +use Symfony\Component\VarExporter\VarExporter; const CONFIG_IMPORT_NEEDED_EXIT_CODE = 2; const DB_UPDATE_NEEDED_EXIT_CODE = 2; const MAINTENANCE_MODE_ACTIVE_OUTPUT_MSG = 'maintenance mode is active'; +const ENV_CONFIG_FILE_PATH = 'app/etc/env.php'; +const TMP_ENV_CONFIG_FILE_PATH = 'app/etc/env_tmp.php'; add('recipes', ['magento2']); @@ -142,6 +145,9 @@ // Deploy without setting maintenance mode if possible set('enable_zerodowntime', true); +//deploy with auto updating cache index_prefix +set('use_redis_cache_id', false); + // Tasks desc('Compiles magento di'); task('magento:compile', function () { @@ -378,6 +384,57 @@ function magentoDeployAssetsSplit(string $area) add('shared_dirs', get('additional_shared_dirs')); }); +/** + * Update cache id_prefix on deploy so that you are compiling against a fresh cache + * Reference Issue: https://github.com/davidalger/capistrano-magento2/issues/151 + * use set('use_redis_cache_id') in your deployer script to enable + **/ +desc('Update cache id_prefix'); +task('magento:set_cache_prefix', function () { + //download current env config + $tmpConfigFile = tempnam(sys_get_temp_dir(), 'deployer_config'); + download('{{deploy_path}}/shared/' . ENV_CONFIG_FILE_PATH, $tmpConfigFile); + $envConfigArray = include($tmpConfigFile); + //set prefix to `alias_releasename_` + $prefixUpdate = get('alias') . '_' . get('release_name') . '_'; + + //update id_prefix to include release name + $envConfigArray['cache']['frontend']['default']['id_prefix'] = $prefixUpdate; + $envConfigArray['cache']['frontend']['page_cache']['id_prefix'] = $prefixUpdate; + + //Generate configuration array as string + $envConfigStr = ' Date: Fri, 29 Sep 2023 10:30:48 +0200 Subject: [PATCH 6/7] DD#0000: feat: Magento2: Add support for preload keys (#3567) * DD#0000: feat: Magento2: Add support for preload keys - Also updated to remove the config set and instead manually add the hocks to your deployer file - And move var-exporter into the main composer require - https://github.com/deployphp/deployer/pull/3453#issuecomment-1497248859 * DD#0000: feat: Reverted composer updates * DD#0000: feat: Updated docs * DD#0000: feat: Updated replace to use preg to make sure it only checks beginning of string Updated readme use better grammer * DD#0000: feat: Updated md docs (cherry picked from commit 48193c6cfc2ae4aa9bda33c9292f8913937a3642) --- docs/recipe/magento2.md | 74 +++++++++++++++++++---------------------- recipe/magento2.php | 28 +++++++++------- 2 files changed, 50 insertions(+), 52 deletions(-) diff --git a/docs/recipe/magento2.md b/docs/recipe/magento2.md index 4c20f6b35..52840a6bd 100644 --- a/docs/recipe/magento2.md +++ b/docs/recipe/magento2.md @@ -294,18 +294,8 @@ true ``` -### use_redis_cache_id -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L149) - -deploy with auto updating cache index_prefix - -```php title="Default value" -false -``` - - ### artifact_file -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L304) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L301) artifact deployment section settings section @@ -316,7 +306,7 @@ settings section ### artifact_dir -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L305) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L302) @@ -326,7 +316,7 @@ settings section ### artifact_excludes_file -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L306) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L303) @@ -336,7 +326,7 @@ settings section ### artifact_path -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L308) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L305) @@ -349,7 +339,7 @@ return get('artifact_dir') . '/' . get('artifact_file'); ### bin/tar -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L315) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L312) :::info Autogenerated @@ -360,14 +350,14 @@ The value of this configuration is autogenerated on access. ### additional_shared_files -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L376) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L373) Array of shared files that will be added to the default shared_files without overriding ### additional_shared_dirs -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L378) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L375) Array of shared directories that will be added to the default shared_dirs without overriding @@ -377,7 +367,7 @@ Array of shared directories that will be added to the default shared_dirs withou ## Tasks ### magento:compile -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L153) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L150) Compiles magento di. @@ -385,7 +375,7 @@ Tasks ### magento:deploy:assets -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L159) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L156) Deploys assets. @@ -393,7 +383,7 @@ Deploys assets. ### magento:deploy:assets:adminhtml -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L173) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L170) Deploys assets for backend only. @@ -401,7 +391,7 @@ Deploys assets for backend only. ### magento:deploy:assets:frontend -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L178) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L175) Deploys assets for frontend only. @@ -409,7 +399,7 @@ Deploys assets for frontend only. ### magento:sync:content_version -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L226) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L223) Syncs content version. @@ -417,7 +407,7 @@ Syncs content version. ### magento:maintenance:enable -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L236) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L233) Enables maintenance mode. @@ -425,7 +415,7 @@ Enables maintenance mode. ### magento:maintenance:disable -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L241) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L238) Disables maintenance mode. @@ -433,7 +423,7 @@ Disables maintenance mode. ### magento:maintenance:enable-if-needed -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L246) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L243) Set maintenance mode if needed. @@ -441,7 +431,7 @@ Set maintenance mode if needed. ### magento:config:import -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L253) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L250) Config Import. @@ -449,7 +439,7 @@ Config Import. ### magento:upgrade:db -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L262) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L259) Upgrades magento database. @@ -457,7 +447,7 @@ Upgrades magento database. ### magento:cache:flush -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L273) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L270) Flushes Magento Cache. @@ -465,7 +455,7 @@ Flushes Magento Cache. ### deploy:magento -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L278) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L275) Magento2 deployment operations. @@ -482,7 +472,7 @@ This task is group task which contains next tasks: ### magento:build -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L288) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L285) Magento2 build operations. @@ -495,7 +485,7 @@ This task is group task which contains next tasks: ### deploy -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L294) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L291) Deploys your project. @@ -511,7 +501,7 @@ This task is group task which contains next tasks: ### artifact:package -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L325) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L322) Packages all relevant files in an artifact. @@ -519,7 +509,7 @@ tasks section ### artifact:upload -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L335) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L332) Uploads artifact in release folder for extraction. @@ -527,7 +517,7 @@ Uploads artifact in release folder for extraction. ### artifact:extract -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L340) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L337) Extracts artifact in release path. @@ -535,7 +525,7 @@ Extracts artifact in release path. ### build:remove-generated -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L346) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L343) Clears generated files prior to building. @@ -543,7 +533,7 @@ Clears generated files prior to building. ### build:prepare -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L351) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L348) Prepare local artifact build. @@ -551,7 +541,7 @@ Prepare local artifact build. ### deploy:additional-shared -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L382) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L379) Adds additional files and dirs to the list of shared files and dirs. @@ -559,17 +549,21 @@ Adds additional files and dirs to the list of shared files and dirs. ### magento:set_cache_prefix -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L393) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L394) Update cache id_prefix. Update cache id_prefix on deploy so that you are compiling against a fresh cache Reference Issue: https://github.com/davidalger/capistrano-magento2/issues/151 -use set('use_redis_cache_id') in your deployer script to enable +To use this feature, add the following to your deployer scripts: +```php +after('deploy:shared', 'magento:set_cache_prefix'); +after('deploy:magento', 'magento:cleanup_cache_prefix'); +``` ### magento:cleanup_cache_prefix -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L426) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L434) Cleanup cache id_prefix env files. diff --git a/recipe/magento2.php b/recipe/magento2.php index 6f8dbebb9..9ac060619 100644 --- a/recipe/magento2.php +++ b/recipe/magento2.php @@ -145,9 +145,6 @@ // Deploy without setting maintenance mode if possible set('enable_zerodowntime', true); -//deploy with auto updating cache index_prefix -set('use_redis_cache_id', false); - // Tasks desc('Compiles magento di'); task('magento:compile', function () { @@ -387,7 +384,11 @@ function magentoDeployAssetsSplit(string $area) /** * Update cache id_prefix on deploy so that you are compiling against a fresh cache * Reference Issue: https://github.com/davidalger/capistrano-magento2/issues/151 - * use set('use_redis_cache_id') in your deployer script to enable + * To use this feature, add the following to your deployer scripts: + * ```php + * after('deploy:shared', 'magento:set_cache_prefix'); + * after('deploy:magento', 'magento:cleanup_cache_prefix'); + * ``` **/ desc('Update cache id_prefix'); task('magento:set_cache_prefix', function () { @@ -398,6 +399,17 @@ function magentoDeployAssetsSplit(string $area) //set prefix to `alias_releasename_` $prefixUpdate = get('alias') . '_' . get('release_name') . '_'; + //check for preload keys and update + if (isset($envConfigArray['cache']['frontend']['default']['backend_options']['preload_keys'])) { + $oldPrefix = $envConfigArray['cache']['frontend']['default']['id_prefix']; + $preloadKeys = $envConfigArray['cache']['frontend']['default']['backend_options']['preload_keys']; + $newPreloadKeys = []; + foreach ($preloadKeys as $preloadKey) { + $newPreloadKeys[] = preg_replace('/^' . $oldPrefix . '/', $prefixUpdate, $preloadKey); + } + $envConfigArray['cache']['frontend']['default']['backend_options']['preload_keys'] = $newPreloadKeys; + } + //update id_prefix to include release name $envConfigArray['cache']['frontend']['default']['id_prefix'] = $prefixUpdate; $envConfigArray['cache']['frontend']['page_cache']['id_prefix'] = $prefixUpdate; @@ -414,10 +426,6 @@ function magentoDeployAssetsSplit(string $area) //link the env to the tmp version run('{{bin/symlink}} {{deploy_path}}/shared/' . TMP_ENV_CONFIG_FILE_PATH . ' {{release_path}}/' . ENV_CONFIG_FILE_PATH); }); -//get current env config -if (get('use_redis_cache_id')) { - after('deploy:shared', 'magento:set_cache_prefix'); -} /** * After successful deployment, move the tmp_env.php file to env.php ready for next deployment @@ -430,10 +438,6 @@ function magentoDeployAssetsSplit(string $area) // Symlink shared dir to release dir run('{{bin/symlink}} {{deploy_path}}/shared/' . ENV_CONFIG_FILE_PATH . ' {{release_path}}/' . ENV_CONFIG_FILE_PATH); }); -//get current env config -if (get('use_redis_cache_id')) { - after('deploy:magento', 'magento:cleanup_cache_prefix'); -} desc('Prepares an artifact on the target server'); From 7e1f087b2f332fc6896d6ce3808558323ae0ea92 Mon Sep 17 00:00:00 2001 From: Mykola Orlenko Date: Fri, 29 Sep 2023 10:34:18 +0200 Subject: [PATCH 7/7] reverse clear cache of magento and opcache --- recipe/magento2.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipe/magento2.php b/recipe/magento2.php index 9ac060619..e68417249 100644 --- a/recipe/magento2.php +++ b/recipe/magento2.php @@ -460,8 +460,8 @@ function magentoDeployAssetsSplit(string $area) task( 'artifact:finish', [ - 'magento:cache:flush', 'cachetool:clear:opcache', + 'magento:cache:flush', 'deploy:cleanup', 'deploy:unlock', ]