Doesn't work with WP Super Cache enabled #164

Merged
merged 1 commit into from Dec 4, 2012

Projects

None yet

5 participants

@pkaeding

I just set up wp-cli version a45bfd0. If I run it from outside my wordpress installation, it correctly prompts me to prove the --path argument. If I run wp --version, I see wp-cli 0.7.0-alpha, so that looks good. However, if I run any other command, either from the WP install folder, or by providing --path pointing to it, all I see is the HTML of my homepage.

Have I just misconfigured something?

@scribu
Member
scribu commented Sep 14, 2012

Are you sure it's the html of your homepage or a warning that WP isn't installed or something like that?

@pkaeding

No, it is my homepage content. I saved it to a file and opened it in a browser to be sure it wasn't just my site's chrome wrapping an error message or something, but it is actually just the HTML from my home page.

@scribu
Member
scribu commented Sep 14, 2012

That's weird. Do you have any caching plugins active, like WP Super Cache?

@pkaeding

Yes, as a matter of fact, I do use WP Super Cache. Is this what is causing the problem?

@scribu
Member
scribu commented Sep 14, 2012

Only way to find out is by removing it, particularly the files in wp-content.

@pkaeding

Okay, WP Super Cache seems to be involved. I disabled the cache, and then wp help returned the expected output.

I don't want to disable the cache, though. I guess I could disable the cache before using wp-cli, and re-enable it afterwards, but that sucks.

Is it possible to have wp-cli not get cached responses?

@pkaeding

Wow, after having just upgraded the core WP code, and a handful of plugins in under 2 minutes (including toggling WP Super Cache off & on), this is amazing! Upgrades have always been a bit of a pain, since I don't like the idea of making the WP installation writable by the user that it runs as.

While I still think it would be great if we could get wp-cli and wp super cache to play well together, this is still an amazing tool! Thanks!

@andreascreten
Member

I did some tests with WP Super Cache and WP-CLI and for me everything works great. Can you send us some screenshots of your WP Super Cache settings?

@pkaeding
pkaeding commented Nov 9, 2012

Sure, here are are what seem to be the interesting parts of my WP Super Cache config screens: https://dl.dropbox.com/u/2397175/wpsupercache.pdf. I have the CDN options disabled, so I omitted that screen, but let me know if you want to see that, or anything else that might help.

Thanks!

@getsource
Member

Does it work any better if you change to using mod_rewrite to serve cached files?

@markjaquith

I ran into similar problems with Batcache. Here was my solution:

In wp-config.php, instead of blindly defining WP_CACHE, make sure we're not running on the command line:

if( !defined( 'WP_CACHE' ) && PHP_SAPI !== 'cli' )
    define( 'WP_CACHE', true );
@markjaquith

Two options that I see:

  1. WP-CLI could define WP_CACHE as false
  2. Individuals could use my snippet to not set WP_CACHE when on the command line
@scribu
Member
scribu commented Dec 1, 2012

WP-CLI could define WP_CACHE as false

I don't see how. Whether it does it before or after wp-config.php is loaded, they'll get a "constant is already defined" error.

Similar problem with WP_DEBUG: #177

@markjaquith

But isn't that just a warning? Not the end of the world...

@scribu
Member
scribu commented Dec 1, 2012

Not the end of the world, but definitely annoying if you have WP_DEBUG on, as any development install should have.

@markjaquith

Ah yeah. So, then I'd recommend option 2: that people add that simple PHP_SAPI !== 'cli' check before defining WP_CACHE. I'm trying to think of a way that WP-CLI could help guide people to that solution...

@scribu
Member
scribu commented Dec 1, 2012

Another solution would be to move the PHP_SAPI !== 'cli' check into Core, before loading wp-content/advanced-cache.php.

@getsource
Member

The only concern I have about the "let's rely on others or core to set WP_CACHE to false" approach is that part of the primary purpose of wp-cli is the upgrade both plugins and core. In these cases, wp-cli will fail to upgrade, and will never get to the point where it will work without manual intervention.

Perhaps we could provide a flag to force it, with the foreknowledge that it will toss a warning if it fails?
It is still an option to force the define via a config file including PHP, but that's a bit of a significant workaround.

@markjaquith

What about tricking WordPress into thinking that WP-CLI runs are is_admin()? All caching backends I know of bail for that.

@scribu
Member
scribu commented Dec 4, 2012

That could work.

@scribu
Member
scribu commented Dec 4, 2012

f28cdcc seems to do the trick.

@scribu scribu merged commit 40c9256 into master Dec 4, 2012
@getsource
Member

Nice!

@scribu scribu added a commit that referenced this pull request Dec 30, 2012
@scribu scribu never load advanced-cache.php. see #164 8f3b660
@westonruter westonruter pushed a commit to xwp/wordpress-develop that referenced this pull request Jun 2, 2016
@aaronjorbin aaronjorbin Introduce filters for skipping parts of the bootstrap process
Non web interfaces with WordPress (such as wp-cli) need to be able to bypass certain checks in the bootstrap process. This introduces three new filters to allow for those checks to be skipped.

1. Provides a way of forcefully bypassing wp_maintenance().
2. Provides a way of forcefully bypassing wp_debug_mode(). See wp-cli/wp-cli#177
3. Provide a way of forcefully skipping loading wp-content/advance-cache.php. See wp-cli/wp-cli#164

These filters should not be used by plugins (in fact, they run before plugins are loaded, so they can't be used by plugins). In general, they should only be used in non-web interactions with WordPress.

See #34936.
Props jorbin, DrewAPicture.


git-svn-id: https://develop.svn.wordpress.org/trunk@37626 602fd350-edb4-49c9-b593-d223f7449a82
f1fdf6a
@markjaquith markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request Jun 2, 2016
@aaronjorbin aaronjorbin Introduce filters for skipping parts of the bootstrap process
Non web interfaces with WordPress (such as wp-cli) need to be able to bypass certain checks in the bootstrap process. This introduces three new filters to allow for those checks to be skipped.

1. Provides a way of forcefully bypassing wp_maintenance().
2. Provides a way of forcefully bypassing wp_debug_mode(). See wp-cli/wp-cli#177
3. Provide a way of forcefully skipping loading wp-content/advance-cache.php. See wp-cli/wp-cli#164

These filters should not be used by plugins (in fact, they run before plugins are loaded, so they can't be used by plugins). In general, they should only be used in non-web interactions with WordPress.

See #34936.
Props jorbin, DrewAPicture.

Built from https://develop.svn.wordpress.org/trunk@37626


git-svn-id: http://core.svn.wordpress.org/trunk@37594 1a063a9b-81f0-0310-95a4-ce76da25c4cd
cedaaaf
@LoreleiAurora LoreleiAurora pushed a commit to CompositeUK/clone.WordPress-Core that referenced this pull request Jun 2, 2016
@aaronjorbin aaronjorbin Introduce filters for skipping parts of the bootstrap process
Non web interfaces with WordPress (such as wp-cli) need to be able to bypass certain checks in the bootstrap process. This introduces three new filters to allow for those checks to be skipped.

1. Provides a way of forcefully bypassing wp_maintenance().
2. Provides a way of forcefully bypassing wp_debug_mode(). See wp-cli/wp-cli#177
3. Provide a way of forcefully skipping loading wp-content/advance-cache.php. See wp-cli/wp-cli#164

These filters should not be used by plugins (in fact, they run before plugins are loaded, so they can't be used by plugins). In general, they should only be used in non-web interactions with WordPress.

See #34936.
Props jorbin, DrewAPicture.

Built from https://develop.svn.wordpress.org/trunk@37626


git-svn-id: https://core.svn.wordpress.org/trunk@37594 1a063a9b-81f0-0310-95a4-ce76da25c4cd
1e28db0
@chutzimir chutzimir pushed a commit to chutzimir/wordpress that referenced this pull request Jun 2, 2016
jorbin Introduce filters for skipping parts of the bootstrap process
Non web interfaces with WordPress (such as wp-cli) need to be able to bypass certain checks in the bootstrap process. This introduces three new filters to allow for those checks to be skipped.

1. Provides a way of forcefully bypassing wp_maintenance().
2. Provides a way of forcefully bypassing wp_debug_mode(). See wp-cli/wp-cli#177
3. Provide a way of forcefully skipping loading wp-content/advance-cache.php. See wp-cli/wp-cli#164

These filters should not be used by plugins (in fact, they run before plugins are loaded, so they can't be used by plugins). In general, they should only be used in non-web interactions with WordPress.

See #34936.
Props jorbin, DrewAPicture.

Built from https://develop.svn.wordpress.org/trunk@37626


git-svn-id: http://core.svn.wordpress.org/trunk@37594 1a063a9b-81f0-0310-95a4-ce76da25c4cd
f07b80f
@svn2github svn2github pushed a commit to svn2github/wp-svn-2-git that referenced this pull request Jun 3, 2016
jorbin Introduce filters for skipping parts of the bootstrap process
Non web interfaces with WordPress (such as wp-cli) need to be able to bypass certain checks in the bootstrap process. This introduces three new filters to allow for those checks to be skipped.

1. Provides a way of forcefully bypassing wp_maintenance().
2. Provides a way of forcefully bypassing wp_debug_mode(). See wp-cli/wp-cli#177
3. Provide a way of forcefully skipping loading wp-content/advance-cache.php. See wp-cli/wp-cli#164

These filters should not be used by plugins (in fact, they run before plugins are loaded, so they can't be used by plugins). In general, they should only be used in non-web interactions with WordPress.

See #34936.
Props jorbin, DrewAPicture.

Built from https://develop.svn.wordpress.org/trunk@37626


git-svn-id: http://core.svn.wordpress.org/trunk@37594 1a063a9b-81f0-0310-95a4-ce76da25c4cd
e3709c1
@voldemortensen voldemortensen pushed a commit to voldemortensen/WordPress that referenced this pull request Jun 14, 2016
jorbin Introduce filters for skipping parts of the bootstrap process
Non web interfaces with WordPress (such as wp-cli) need to be able to bypass certain checks in the bootstrap process. This introduces three new filters to allow for those checks to be skipped.

1. Provides a way of forcefully bypassing wp_maintenance().
2. Provides a way of forcefully bypassing wp_debug_mode(). See wp-cli/wp-cli#177
3. Provide a way of forcefully skipping loading wp-content/advance-cache.php. See wp-cli/wp-cli#164

These filters should not be used by plugins (in fact, they run before plugins are loaded, so they can't be used by plugins). In general, they should only be used in non-web interactions with WordPress.

See #34936.
Props jorbin, DrewAPicture.


git-svn-id: http://develop.svn.wordpress.org/trunk@37626 602fd350-edb4-49c9-b593-d223f7449a82
7fe98a8
@janblaha janblaha pushed a commit to janblaha/wordpress that referenced this pull request Jul 7, 2016
jorbin Introduce filters for skipping parts of the bootstrap process
Non web interfaces with WordPress (such as wp-cli) need to be able to bypass certain checks in the bootstrap process. This introduces three new filters to allow for those checks to be skipped.

1. Provides a way of forcefully bypassing wp_maintenance().
2. Provides a way of forcefully bypassing wp_debug_mode(). See wp-cli/wp-cli#177
3. Provide a way of forcefully skipping loading wp-content/advance-cache.php. See wp-cli/wp-cli#164

These filters should not be used by plugins (in fact, they run before plugins are loaded, so they can't be used by plugins). In general, they should only be used in non-web interactions with WordPress.

See #34936.
Props jorbin, DrewAPicture.

Built from https://develop.svn.wordpress.org/trunk@37626
1bd64bb
@staylor staylor pushed a commit to staylor/develop.svn.wordpress.org that referenced this pull request Aug 18, 2016
jorbin Introduce filters for skipping parts of the bootstrap process
Non web interfaces with WordPress (such as wp-cli) need to be able to bypass certain checks in the bootstrap process. This introduces three new filters to allow for those checks to be skipped.

1. Provides a way of forcefully bypassing wp_maintenance().
2. Provides a way of forcefully bypassing wp_debug_mode(). See wp-cli/wp-cli#177
3. Provide a way of forcefully skipping loading wp-content/advance-cache.php. See wp-cli/wp-cli#164

These filters should not be used by plugins (in fact, they run before plugins are loaded, so they can't be used by plugins). In general, they should only be used in non-web interactions with WordPress.

See #34936.
Props jorbin, DrewAPicture.


git-svn-id: https://develop.svn.wordpress.org@37626 602fd350-edb4-49c9-b593-d223f7449a82
ee66e3a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment