Skip to content

CLI-1810: run sanitize before cache clear.#2003

Open
deepakmishra2 wants to merge 3 commits into
mainfrom
CLI-1810
Open

CLI-1810: run sanitize before cache clear.#2003
deepakmishra2 wants to merge 3 commits into
mainfrom
CLI-1810

Conversation

@deepakmishra2

Copy link
Copy Markdown
Contributor

This pull request adds a new --no-cache-clear option to the pull:database command, allowing users to skip the drush cache-rebuild step after pulling the database. This is useful in scenarios where cache should not be cleared immediately, such as when pending update hooks need to run first. The logic for script execution is updated accordingly, and a new test is added to verify this behavior.

New Feature:

  • Added a --no-cache-clear option to the pull:database command to allow skipping drush cache-rebuild after pulling the database. This is helpful when update hooks must run before cache is cleared.

Script Execution Logic:

  • Updated the script execution order and logic in PullDatabaseCommand to respect the new --no-cache-clear flag, ensuring drush sql-sanitize still runs while drush cache-rebuild is skipped if the flag is set. [1] [2]

Testing:

  • Added a new test testPullDatabaseNoCacheClear to verify that when --no-cache-clear is used, drush sql-sanitize runs but drush cache-rebuild does not.
  • Updated existing test order to match the new script execution sequence.

Copilot AI review requested due to automatic review settings June 5, 2026 12:19
@codecov

codecov Bot commented Jun 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.43%. Comparing base (48d43fc) to head (477cb7b).

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #2003   +/-   ##
=========================================
  Coverage     92.42%   92.43%           
- Complexity     1957     1960    +3     
=========================================
  Files           123      123           
  Lines          7093     7102    +9     
=========================================
+ Hits           6556     6565    +9     
  Misses          537      537           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown

Try the dev build for this PR: https://acquia-cli.s3.amazonaws.com/build/pr/2003/acli.phar

curl -OL https://acquia-cli.s3.amazonaws.com/build/pr/2003/acli.phar
chmod +x acli.phar

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the post-pull:database script behavior to (1) run drush sql:sanitize before cache rebuild and (2) optionally skip cache rebuild via a new CLI flag, which supports workflows where update hooks must run before caches are rebuilt.

Changes:

  • Added --no-cache-clear to pull:database to skip drush cache:rebuild while still running drush sql:sanitize.
  • Reordered script execution so drush sql:sanitize runs before cache rebuild.
  • Added a PHPUnit test covering the --no-cache-clear behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/Command/Pull/PullDatabaseCommand.php Adds --no-cache-clear and updates script execution logic to sanitize first and conditionally rebuild caches.
src/Command/CommandBase.php Reorders shared “execute all scripts” flow to sanitize before cache rebuild.
tests/phpunit/src/Commands/Pull/PullDatabaseCommandTest.php Updates existing test expectations and adds coverage for skipping cache rebuild.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@deepakmishra2 deepakmishra2 added bug Something isn't working enhancement labels Jun 5, 2026
$this->runDrushSqlSanitize($outputCallback, $this->checklist);
if (!$noCacheClear) {
$this->runDrushCacheClear($outputCallback, $this->checklist);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why limit noCacheClear with noScript? it should act regardless of the script or noScript.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is if a user specifically run drush cr with --no-cache-clear. we are providing a new option to them

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the same option will work if you keep it out of the if/else case. That way it can be used in drush cr without as well.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh that makes sense if there is no option provided, we should keep that in a separate if. Let me refactor this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants