cache-command icon indicating copy to clipboard operation
cache-command copied to clipboard

Add pluck/patch commands for caches and transients

Open petitphp opened this issue 2 years ago • 10 comments

Add commands for plucking and patching values from object cache and transient.

Fixes #26

petitphp avatar Jul 25 '23 14:07 petitphp

I cannot reproduce the failures for the functional tests locally :

$ composer behat                                                                 
> run-behat-tests
...................................................................... 70
...................................................................... 140
...................................................................... 210
...................................................................... 280
...................................................................... 350
................

20 scénarios (20 succès)
366 étapes (366 succès)
4m20.27s (10.47Mb)

Seem's like the mu-plugins used to set up those scenarios are not loaded.

petitphp avatar Aug 28 '23 14:08 petitphp

Unfortunately can't reproduce locally either.

Looks like $current_value is null, so the wp_cache_get() call in the patch() method is returning null for some reason..?

Adding some WP_CLI::log( var_export( wp_cache_get( 'my_key' ), true ) ); calls to within $set_foo could help debug this.

swissspidy avatar Aug 30 '23 10:08 swissspidy

I manage to reproduce the failling tests locally after rebasing main in the branch, I'll look into it.

Scratch that, it was an issue with the rebase 🥲

petitphp avatar Sep 07 '23 07:09 petitphp

@danielbachhuber I've split the tests into dedicated files and update them to use When I run if they're expected to succeed.

In https://github.com/wp-cli/cache-command/pull/89/commits/327d99a13cef3601fd8304006efaeb9396821e88 I added two debug statement to try to understand why the tests are failing in Github CI.

petitphp avatar Sep 07 '23 08:09 petitphp

@danielbachhuber I was finally able to fix the failures for the functional tests. It was related to the use of STDIN to get the new value, which didn't properly handle the case where it was empty.

All tests are green on my fork.

petitphp avatar Sep 18 '23 19:09 petitphp

What's left to do on this PR?

johnbillion avatar Nov 10 '23 14:11 johnbillion

Hi @johnbillion, sorry for the delay.

I didn't had the time to look at Daniel comments yet. I'll try to check them this week and finish up this PR for a new review.

petitphp avatar Nov 15 '23 08:11 petitphp

Hi @danielbachhuber,

I've refactored the feature tests to address your feedbacks, this should be good to go.

All tests workflows using MySQL are green, the ones with SQLite are failing, but doesn't seem related to this PR specifically (eg: Functional - WP latest on 8.2 with SQLite).

petitphp avatar Dec 12 '23 08:12 petitphp

SQLite errors are known, see #92

swissspidy avatar Jan 08 '24 12:01 swissspidy

Hi, this PR should be ready for final review, the failling tests are related to SQLite errors and not to the changes in this PR.

petitphp avatar Apr 19 '24 18:04 petitphp

Codecov Report

Attention: Patch coverage is 84.87395% with 18 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/Transient_Command.php 83.33% 10 Missing :warning:
src/Cache_Command.php 86.44% 8 Missing :warning:

:loudspeaker: Thoughts on this report? Let us know!

codecov[bot] avatar May 05 '25 18:05 codecov[bot]

Thanks for all the work on this, @petitphp !

schlessera avatar May 05 '25 22:05 schlessera