Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publishing via XMLRPC does not automatically clear the cache #744

Closed
raamdev opened this issue Apr 20, 2016 · 8 comments
Closed

Publishing via XMLRPC does not automatically clear the cache #744

raamdev opened this issue Apr 20, 2016 · 8 comments

Comments

@raamdev
Copy link
Contributor

raamdev commented Apr 20, 2016

As reported here, when publishing a post via XMLRPC Comet Cache does not properly detect this and clear the appropriate cache files. If, for example, someone publishes a new post, the home page cache does not get cleared and the new post is not visible.

This needs to be tested to confirm and researched to figure out what needs to be done to fix it.

@renzms
Copy link

renzms commented Oct 8, 2016

@raamdev

Status

Was able to replicate issue.
Using Test installation: WP 4.6.1, PHP 7.0, Comet Cache Pro Version 160917, WP CLI

Steps to reproduce

Note, I did not use XMLRPC.

I was informed by @jaswsinc that it would be okay to use XMLRPC, but I could actually use Wordpress Rest API to do this.

@jaswsinc writes...

The key thing is that XMLRPC is not a new protocol. It's just a fancy name for what is nothing more than an API like any other. XMLRPC is an outdated API for WordPress that is enabled by default now in all WP installs. It used to be enabled by a site owner, but now it is disabled by most system administrators because it is open to attacks and will increase the odds of your site being hit with a DDoS attack.

Basically, it just comes down to formulating a request that you will send to WordPress that speaks the XML language. Like any other API, you formulate that request, send it to the server over HTTP and get back a response.

  • Install and enable Comet Cache Pro. Enable Automatic Cache Clearing settings and configurations
  • Create some sample post/page(s) and create cache
  • Check cache is clearing automatically by adding/updating post/page(s)
  • Using WP RESTful CLI use command line for posting via SSH. (see command lines here:http://wp-cli.org/commands/post/)
  • Post using different commands and types of posts/pages. (e.g, public, private, draft, post, page, future, set post date and time, update post/page, delete post/page)
  • Check if cache has cleared

Results

Cache does not clear when posting via WP CLI. Deleting/Editing/Updating those post/page(s) via the WP dashboard does clear the cache. Comet Cache only recognizes and clears the cache when changes are done in the WP Dashboard.

@raamdev
Copy link
Contributor Author

raamdev commented Oct 10, 2016

@renzms Thanks for testing and for sharing that information.

@jaswsinc Can I get a time estimate on this?

@jaswrks
Copy link

jaswrks commented Oct 10, 2016

Testing via WP-CLI (over SSH) is not the same as testing via XMLRPC. The WP-CLI tool operates in a CLI context. Meaning, web server environment variables may not be present, depending on your configuration. For the best WP-CLI compatibility it is suggested that you enable one of these flags when dealing with Comet Cache.

--http=<http>
Perform operation against a remote WordPress install over HTTP.

--url=<url>
Pretend request came from given URL. In multisite, this argument is how the target site is specified.

We can improve compatibility with WP-CLI though. For example, by refactoring and taking a closer look at $_SERVER environment variable access on the part of Comet Cache. We will likely need new functions that can fall back on a DB lookup for things like the current host name, instead of failing when $_SERVER['HTTP_HOST'] is unavailable; e.g., when running in a CLI context. For this I estimate three days.

For XMLRPC compatibility I'm not sure. That's a web-based HTTP API, which means it doesn't operate in a CLI context like WP-CLI does. If automatic cache clearing is not working when posting via XMLRPC, it could be that we need to take a closer look at hooks we attach to. If someone can find out more about the problem for me, my estimate would be lower, but for now I'll say three additional days to research and fix this.

@raamdev
Copy link
Contributor Author

raamdev commented Oct 11, 2016

@jaswsinc Thanks!


@renzms writes...

Using WP RESTful CLI use command line for posting via SSH. (see command lines here:http://wp-cli.org/commands/post/)

That's really a separate issue than this XMLRPC issue. Can you please open another GitHub issue, "WP-CLI Compatibility: Create Post Command" and document your findings there (please also quote Jason's reply above Re: WP-CLI)? We'll have to research that issue separately.


@jaswsinc writes...

If automatic cache clearing is not working when posting via XMLRPC, it could be that we need to take a closer look at hooks we attach to. If someone can find out more about the problem for me

@renzms Could you do some more research on this? You'll probably need to get a client that connects to a WordPress installation via XMLRPC to publish/edit posts. See https://en.support.wordpress.com/xml-rpc/. Ping me on Slack if you have any additional questions.

@renzms
Copy link

renzms commented Oct 11, 2016

@raamdev Noted, I'll look into this more.

Created WP CLI issue here: #839

@renzms
Copy link

renzms commented Oct 11, 2016

@raamdev

Status

Was not able to replicate issue.
Using Test installation: WP 4.6.1, PHP 7.0, Comet Cache Pro Version 160917, WordPress Desktop App for MacOS (App connects via XML-RPC)

Steps

  • Install and enable Comet Cache Pro. Enable Automatic Cache Clearing settings and configurations
  • Create some sample post/page(s) and create cache
  • Check cache is clearing automatically by adding/updating post/page(s)
  • Using WP Desktop APP created and updated posts.
  • Tried different types of posts/pages. (e.g, public, private, draft, post, page, future, set post date and time, update post/page, delete post/page)
  • Check if cache has cleared

Results

Cache cleared when posting via WP Desktop App. Comet Cache recognizes and clears the cache when changes are done in the WP Desktop App.

@renzms
Copy link

renzms commented Oct 11, 2016

Additional testing done via https://github.com/letrunghieu/wordpress-xmlrpc-client

Using XML-RPC client with WP 4.6.1, PHP 7.0, Comet Cache Pro Version 160917, was not able to replicate issue.

  • Created PHP file for testing and executed via command line.
  • Cache automatically cleared and post was added/updated.

@raamdev
Copy link
Contributor Author

raamdev commented Oct 12, 2016

I also just ran a test using the WordPress iOS app on my iPhone (WordPress 4.6.1, Comet Cache Pro v160917, iOS v10.0.2, WordPress iOS App v6.5) and confirmed that updating an existing post clears the cache for that post, so I'm going to close this as resolved.

Thanks for the testing, @renzms! :-)

@raamdev raamdev closed this as completed Oct 12, 2016
@raamdev raamdev removed this from the Future Release milestone Nov 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants