Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Magento 2: use_redis_cache_id flag has no effect #3713

Closed
mfickers opened this issue Oct 23, 2023 · 2 comments
Closed

Magento 2: use_redis_cache_id flag has no effect #3713

mfickers opened this issue Oct 23, 2023 · 2 comments

Comments

@mfickers
Copy link

The use_redis_cache_id is ignored in custom deploy scripts extending the Magento 2 recipe.

Environment

  • Deployer version: v7.3.1
  • Deployment OS:

Steps to reproduce:

  1. Extend Magento 2 recipe
  2. Set flag "use_redis_cache_id" to true
<?php
namespace Deployer;

require 'recipe/magento2.php';

// Config
set('use_redis_cache_id', true);
  1. Generate tree for deploy
./vendor/bin/dep tree -f deploy.php deploy

Expected behavior:

Steps magento:set_cache_prefix and magento:cleanup_cache_prefix are included:

The task-tree for deploy:
└── deploy
    ├── deploy:prepare
    │   ├── deploy:info
    │   ├── deploy:setup
    │   ├── deploy:lock
    │   ├── deploy:release
    │   ├── deploy:update_code
    │   ├── deploy:shared
    │   ├── magento:set_cache_prefix  // after deploy:shared
    │   └── deploy:writable
    ├── deploy:vendors
    ├── deploy:clear_paths
    ├── deploy:magento
    │   ├── magento:build
    │   │   ├── magento:compile
    │   │   ├── magento:sync:content_version  // before magento:deploy:assets
    │   │   └── magento:deploy:assets
    │   ├── magento:maintenance:enable-if-needed
    │   ├── magento:config:import
    │   ├── magento:upgrade:db
    │   ├── magento:maintenance:disable
    │   └── magento:cache:flush
    ├── magento:cleanup_cache_prefix  // after deploy:magento
    └── deploy:publish
        ├── deploy:symlink
        ├── deploy:unlock
        ├── deploy:cleanup
        └── deploy:success

Actual behavior:

Steps magento:set_cache_prefix and magento:cleanup_cache_prefix are missing:

The task-tree for deploy:
└── deploy
    ├── deploy:prepare
    │   ├── deploy:info
    │   ├── deploy:setup
    │   ├── deploy:lock
    │   ├── deploy:release
    │   ├── deploy:update_code
    │   ├── deploy:shared
    │   └── deploy:writable
    ├── deploy:vendors
    ├── deploy:clear_paths
    ├── deploy:magento
    │   ├── magento:build
    │   │   ├── magento:compile
    │   │   ├── magento:sync:content_version  // before magento:deploy:assets
    │   │   └── magento:deploy:assets
    │   ├── magento:maintenance:enable-if-needed
    │   ├── magento:config:import
    │   ├── magento:upgrade:db
    │   ├── magento:maintenance:disable
    │   └── magento:cache:flush
    └── deploy:publish
        ├── deploy:symlink
        ├── deploy:unlock
        ├── deploy:cleanup
        └── deploy:success
@mfickers
Copy link
Author

I suspect that this was broken by this commit: bf1d11d

This change moved the check to around the hooks. The problem is, the flag will always be false when this condition is executed, as this happens during parsing of the recipe and not at runtime.

According to this comment #3453 (comment), the change was made to prevent the steps from showing up if they are not executed. If anyone has an idea on how to fix this without breaking this behavior, I'll gladly create a PR.

As a workaround I've re-declared the missing steps in my script:

<?php
namespace Deployer;

require 'recipe/magento2.php';

// Config
set('use_redis_cache_id', true);

// Workaround
if (get('use_redis_cache_id')) {
    after('deploy:shared', 'magento:set_cache_prefix');
}
if (get('use_redis_cache_id')) {
    after('deploy:magento', 'magento:cleanup_cache_prefix');
}

@mfickers
Copy link
Author

Looks like this is already fixed in master, as part of this PR: #3567. The flag has been removed and the user should instead include the steps in their script. I'm closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant