Repository navigation
Conversation
|
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:
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:123You can find a list of all available Behat steps in our handbook. |
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
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. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
Please see #74 and especially #74 (comment) This needs more discussion first for a more holistic approach. |
There was a problem hiding this comment.
Note
Copilot was unable to run its full agentic suite in this review.
Copilot review overview
5 open findings
LIKE '_oembed_%'treats_as a single-character wildcard in SQL, so this can delete rows whose… · New--allcurrently takes precedence even if post IDs are also provided (it ignores$args). That’s… · New Both$wpdb->query()calls can returnfalseon failure, but the command always prints success.… · New Deleting from{$wpdb->posts}directly bypasses WordPress cleanup (e.g.,postmeta, term… · New The8is a magic number tied to the prefix length. Usingstrlen( '_oembed_' )(or a named… · New
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 towp embed cache clear, emitting per-post success/warning messages. - Add
--allto delete all oEmbed-related caches, includingoembed_cacheposts. - 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.
| // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching | ||
| $wpdb->query( "DELETE FROM {$wpdb->postmeta} WHERE meta_key LIKE '_oembed_%'" ); |
| $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 ) { |
| $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'" ); | ||
|
|
| $wpdb->query( "DELETE FROM {$wpdb->posts} WHERE post_type = 'oembed_cache'" ); | ||
|
|
| $post_metas = array_filter( | ||
| $post_metas, | ||
| function ( $v ) { | ||
| return '_oembed_' === substr( $v, 0, 8 ); |



Resolves #67.
Summary
This PR adds support for
--alland passing multiple post IDs towp embed cache clear:<post_id>to[<post_id>...] [--all].--allis provided (Error: Please specify one or more post IDs, or use --all.).--allis passed, deletes all_oembed_%metadata frompostmetaand alloembed_cacheposts fromposts.--all.