This module allows you to clear the cache remotely. This can be useful if you have multisite installation with multiple databases. Very simple and straight forward. Needed for a a big multisite install, no CLI access and trying to log in to over 20 websites can be a bit time consuming (especially with same cookie domain).

Now have got a simple local file that makes cURL requests to all required sites and all process takes a minute rather than 20.

Have searched for module with this functionality however did not find such a module thus wrote this one.

Link to project page:
https://drupal.org/sandbox/centas/2116669

Link to git:
http://drupalcode.org/sandbox/centas/2116669.git/tree/refs/heads/7.x-1.x

Git clone:
git clone http://git.drupal.org/sandbox/centas/2116669.git clear_cache_remotely

Drupal 7

Manual reviews of other projects

https://drupal.org/node/2122451#comment-8015021
https://drupal.org/node/2080721#comment-8015161
https://drupal.org/node/2137845#comment-8187121

Comments

centas’s picture

Title: Clear Cache Remotely » [D7] Clear Cache Remotely
oresh’s picture

Status: Active » Needs review
saitanay’s picture

Status: Needs review » Needs work

Hi Centas,

Similar Existing Modules

The project looks to be a good idea, as there is currently no out of the box way to clear caches without logging in / cli - as listed on https://drupal.org/node/42055

Coding / Formatting Standards

The code is clean and I could see no issues in it.

Allow IP whitelist by wildcard

One feature that I would like to see in the module configuration page is whitelisting IPs by wildcards - Ex: 106.51.161.* rather than individual IPs.

Too small for project application

Also I am afraid if this module will be eligible for a Project application - As the guideline #2.3 in Project application checklist ( https://drupal.org/node/1587704 ) says

Ensure your project contains a minimum of handwritten code.
We are currently discussing how much code we need, but everything with less than 120 lines of code or less than 5 functions cannot be seriously reviewed, that means we can't make sure you're able to write secure code and use Drupal's APIs correctly.

I am afraid if this pretty small module with <90 lines of code and 4 functions might not be eligible for an application.

Best
Tanay

centas’s picture

Assigned: Unassigned » centas

Fair point. Will take a look to see how can possibly make it a little more useful (think the wildcard white listing of IPs seems quite sensible).

centas’s picture

Status: Needs work » Needs review

Have extended the module a little.
Added:

  1. IP address wildcard check
  2. Clearing CSS / JS / Theme cache separately
  3. Possibility to clear cache tables one by one
  4. Also now supports Boost module cache clearing
PA robot’s picture

We are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then we will take a look at your project right away :-)

Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).

I'm a robot and this is an automated message from Project Applications Scraper.

saitanay’s picture

Status: Needs review » Needs work

Hi centas,

The module looks good now. I have a couple of small suggestions.

.

1 README.txt The Readme file and the project description shall be updated with example urls for the various options available. Currently the urls pattterns are not clearly illustrated in the readme file. Add more examples.

.

2 Unset Variables Unset all the variables you are setting in hook_uninstall

.

3 Config Page Url The config page url is at a very high level - admin/settings/clear_cache_remotely. Change it to an appropriate category in the administration area. If every module adds an entry at the top level, the toolbar will be cluttered. Suggested - /admin/config/development/performanceclear_cache_remotely .

.

4 URL Builder [Optional] Additionally, if you are looking at adding more options to the module, consider a small form, which would be a url builder, on the config page where user can select various options - like Enter Key, then choose what caches to clear etc and he will be shown in a text area the completely built url.

Best
Tanay

centas’s picture

Status: Needs work » Needs review

I have done the points 1,2 and 3 as per https://drupal.org/node/2116697#comment-7991537

I am not too sure about point 4 though yet, would love to keep the module simple for now and if gets approved and used, see what other people would say. Not sure its worth creating a whole URLs generator as the module is quite straight forward.

centas’s picture

Assigned: centas » Unassigned

Unassigning it from myself to no one, probably should have done it before as it might look like it "needs work" as was assigned to author.

centas’s picture

Issue tags: +PAreview: review bonus

Added review bonus tag

centas’s picture

Issue summary: View changes

Adding review links

klausi’s picture

Issue summary: View changes
Issue tags: -PAreview: review bonus

Removing review bonus tag, you have not done all manual reviews, you just posted the output of an automated review tool. Make sure to read through the source code of the other projects, as requested on the review bonus page.

klausi’s picture

Status: Needs review » Needs work

Sorry for the delay. Make sure to review more project applications to complete your review bonus and this will get finished faster.

manual review:

  1. _clear_cache_remotely_run(): @return doc block is wrong, this function does not return anything?
  2. _clear_cache_remotely_run(): so this looks a bit vulnerable to DOS attacks. If I install the module and forget to setup a secret key then anyone can call the menu path with "0" as key and clear the cache repeatedly until the site goes down. I think you should add an empty() check for the key before continuing.

But otherwise looks almost ready, the DOS could be considered a security issue, so this is a blocker right now.

centas’s picture

Status: Needs work » Needs review

@klausi, thanks for your review.

A very good point in regards to possible DoS attack bug, have added a check to see if the module secret key is set up, and if its not, terminate the script there and then.

Was debating on changing JSON string response to "You have not set you security key" but decided not to as in not to give away the information on why request has failed. Hope that makes sense.

Also, removed the @return from doc block.

P.S. Getting there with the reviews, hopefully will get into it at some point :)

idebr’s picture

Status: Needs review » Needs work

Hi Centas,

Great idea for a module! Some pointer before you release:

  1. You can add your page callbacks for the admin interface to a seperate file, so they can be loaded when needed. Your .module file should be a small as reasonably possible to reduce memory load. You can read more on how to include files for page callbacks in hook_menu
  2. Can you add a description on the configuration page how the Secret key is used? Suggestion: 'The secret key is added to the Clear Cache Remotely URL as a safety measure, for example: http://yourdomain.com/clear_cache_remotely/all/[secret key]
  3. Instead of leaving the generation of the secret key to the administrator, can you generate a default secret key for example in hook_enable()? This will make sure Clear Cache Remotely uses a proper secret key by default and saves the site administrator some time.
  4. clear_cache_remotely.module:82 Instead using die(json_encode($result)), you can use return drupal_json_output($result). This will set the correct http reponse header.
  5. clear_cache_remotely.module:87 There is a mismatch in the replacement string (%ip vs. !ip). Suggestion: use @ip in both cases, since watchdog notices are typically in plain text.
  6. clear_cache_remotely.module:154 $ips_whitelist is not used in the default code path and is set explicitly later, so you don't have to initialize the variable here. You can safely remove this line.
centas’s picture

Status: Needs work » Needs review

@idebr, thanks for your review and points, have implemented them all.

Instead of hook_enable() I went with hook_install(). That way the default secret key will not get overwritten in case the administrator disabled the module and then enabled it again, thus making all the external calls to clear cache invalid.

centas’s picture

Issue summary: View changes
Issue tags: +PAreview: review bonus
dan.ashdown’s picture

Status: Needs review » Needs work

Hi centas,

Useful module thanks for creating.

Some minor things:

  1. The module package is currently "Other", subjective but I'd suggest putting it under "Performance and scalability"
  2. In your hook_menu, you have an empty line at the start which you don't have on other functions (minor inconsistency)
  3. In your hook_menu you're not initialising the $items array which you are doing for your form in admin.inc
  4. In "_clear_cache_remotely_run()" you're checking if the user has added a value for "clear_cache_remotely_key" using empty(). You don't need the functionality that empty() offer as the default is ''. I'd suggest just using:
    if (!$configuration_key) {
      return drupal_json_output($result);
    }
    
centas’s picture

Status: Needs work » Needs review

@Dan.Ashdown

1. Not really sure bout this one, according to the guidelines should be pretty much left empty in my module case: https://drupal.org/node/542202#package ?
2. Removed
3. Removed
4. Done

dan.ashdown’s picture

1) Ah, fair enough. Thanks for sharing the link too :)

klausi’s picture

Assigned: Unassigned » kscheirer
Status: Needs review » Reviewed & tested by the community
Issue tags: -PAreview: review bonus

Looks good to me! Assigning to kscheirer as he might have time to take a final look at this.

Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.

klausi’s picture

Assigned: kscheirer » Unassigned
Status: Reviewed & tested by the community » Fixed

no objections for more than a week, so ...

Thanks for your contribution, centas!

I updated your account so you can promote this to a full project and also create new projects as either a sandbox or a "full" project.

Here are some recommended readings to help with excellent maintainership:

You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and stay involved!

Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

Thanks to the dedicated reviewer(s) as well.

centas’s picture

Awesome news! Thank for the final review, just in time for London Drupal sprint! :)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.