Closed bor0 closed 7 years ago
@bor0 : This is the expected behavior for WordPress. The function get_post_meta()
runs through the WP Object Cache, so that it is only fetched once from the database within a given PHP process/request. WordPress is meant to be shutdown and restarted after every request, so this behavior rarely causes an issue.
In your wp shell
process, however, we start one single WP process and then keep that one going. This is why you're still hitting the cache with subsequent queries. They never hit the database, the information is already present in memory and fetched from there.
You can either flush the cache within the existing process yourself with wp_cache_flush()
, or restart the shell.
Related issue: https://github.com/wp-cli/ideas/issues/63
Thanks @schlessera. I called wp_suspend_cache_addition( true );
at the beginning of the shell and it works now. I thought it was a part of wp shell
.
cc @gedex
Steps to reproduce:
If you close and open wp shell again, it will return the correct value: