Skip to content

Support --all and multiple post IDs for embed cache clear - #101

Open
wprashed wants to merge 2 commits into
wp-cli:mainfrom
wprashed:fix-67-embed-cache-clear-all
Open

wprashed wants to merge 2 commits into
wp-cli:mainfrom
wprashed:fix-67-embed-cache-clear-all

Conversation

@wprashed

Copy link
Copy Markdown

Resolves #67.

Summary

This PR adds support for --all and passing multiple post IDs to wp embed cache clear:

  • Updates synopsis from <post_id> to [<post_id>...] [--all].
  • Errors if neither post IDs nor --all is provided (Error: Please specify one or more post IDs, or use --all.).
  • When --all is passed, deletes all _oembed_% metadata from postmeta and all oembed_cache posts from posts.
  • When multiple post IDs are passed, clears oEmbed cache for each post ID, emitting success per post or warning if no cache exists for that post.
  • Retains backward compatibility for single post ID clearing.
  • Includes Behat feature tests for missing arguments, multiple post IDs, and --all.

@wprashed
wprashed requested a review from a team as a code owner October 13, 2026 09:59
@github-actions

Copy link
Copy Markdown
Contributor

Hello! 👋

Thanks for opening this pull request! Please check out our contributing guidelines. We appreciate you taking the initiative to contribute to this project.

Contributing isn't limited to just code. We encourage you to contribute in the way that best fits your abilities, by writing tutorials, giving a demo at your local meetup, helping other users with their support questions, or revising our documentation.

Here are some useful Composer commands to get you started:

  • composer install: Install dependencies.
  • composer test: Run the full test suite.
  • composer phpcs: Check for code style violations.
  • composer phpcbf: Automatically fix code style violations.
  • composer phpunit: Run unit tests.
  • composer behat: Run behavior-driven tests.

To run a single Behat test, you can use the following command:

# Run all tests in a single file
composer behat features/some-feature.feature

# Run only a specific scenario (where 123 is the line number of the "Scenario:" title)
composer behat features/some-feature.feature:123

You can find a list of all available Behat steps in our handbook.

@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 46cf1556-8510-4419-b6b5-2401cb18415a
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added command:embed Related to 'embed' command command:embed-cache-clear Related to 'embed cache clear' command command:embed-cache Related to 'embed cache' command scope:testing Related to testing labels Oct 13, 2026
@codecov

codecov Bot commented Oct 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@swissspidy

Copy link
Copy Markdown
Member

Please see #74 and especially #74 (comment)

This needs more discussion first for a more holistic approach.

@ernilambar
ernilambar requested a balanced review from Copilot October 13, 2026 10:07
Copilot stopped reviewing on behalf of ernilambar due to an error October 13, 2026 10:07

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.

Note

Copilot was unable to run its full agentic suite in this review.

Copilot review overview

5 open findings
What changed in this PR

This PR expands the wp embed cache clear command to support clearing caches for multiple posts at once or clearing all oEmbed caches globally, and adds behavioral tests for the new CLI UX.

Changes:

  • Allow passing multiple <post_id> values to wp embed cache clear, emitting per-post success/warning messages.
  • Add --all to delete all oEmbed-related caches, including oembed_cache posts.
  • Add Behat/Cucumber feature scenarios covering missing args, multi-post clears, partial clears, and --all.
File Description
src/​Cache_Command.php Adds multi-ID support and --all mode to clear oEmbed caches, with updated CLI messaging.
features/​cache.feature Adds new acceptance tests validating the updated CLI behavior and exit codes.

🧠 Review effort: Lite


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/Cache_Command.php
Comment on lines +72 to +73
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
$wpdb->query( "DELETE FROM {$wpdb->postmeta} WHERE meta_key LIKE '_oembed_%'" );
Comment thread src/Cache_Command.php
Comment on lines +62 to +68
$all = Utils\get_flag_value( $assoc_args, 'all', false );

if ( empty( $args ) && ! $all ) {
WP_CLI::error( 'Please specify one or more post IDs, or use --all.' );
}

if ( $all ) {
Comment thread src/Cache_Command.php
Comment on lines +73 to +77
$wpdb->query( "DELETE FROM {$wpdb->postmeta} WHERE meta_key LIKE '_oembed_%'" );

// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
$wpdb->query( "DELETE FROM {$wpdb->posts} WHERE post_type = 'oembed_cache'" );

Comment thread src/Cache_Command.php
Comment on lines +76 to +77
$wpdb->query( "DELETE FROM {$wpdb->posts} WHERE post_type = 'oembed_cache'" );

Comment thread src/Cache_Command.php
$post_metas = array_filter(
$post_metas,
function ( $v ) {
return '_oembed_' === substr( $v, 0, 8 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

command:embed Related to 'embed' command command:embed-cache Related to 'embed cache' command command:embed-cache-clear Related to 'embed cache clear' command scope:testing Related to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support --all for wp embed cache clear

3 participants