Page MenuHomePhabricator

Add dialog to purge opcode/data caches
ClosedPublic

Authored by meitros on Sep 5 2015, 7:02 PM.
Tags
None
Referenced Files
F14045802: D14064.id34053.diff
Wed, Nov 13, 11:40 AM
F14045354: D14064.id.diff
Wed, Nov 13, 3:14 AM
F14044517: D14064.diff
Tue, Nov 12, 5:22 PM
F14036695: D14064.id34068.diff
Sun, Nov 10, 11:39 AM
F14022222: D14064.id34067.diff
Wed, Nov 6, 3:45 PM
F14022221: D14064.id34053.diff
Wed, Nov 6, 3:45 PM
F14014959: D14064.id34068.diff
Sun, Nov 3, 10:57 AM
F14010956: D14064.id34068.diff
Thu, Oct 31, 2:01 PM

Details

Reviewers
epriestley
Group Reviewers
Blessed Reviewers
Commits
Restricted Diffusion Commit
rPae0348aac931: Add dialog to purge opcode/data caches
Summary

Reachable via the cache config page, restricted to admins only. This makes it convenient to hotfix phabricator without requiring a restart.

Test Plan
  • Local dev machine doesn't have apc, so I get the not installed message.
  • Faked the name and isEnabled parameters, verified dialog shows up as expected.
  • Didn't test clear code

Diff Detail

Repository
rP Phabricator
Branch
purge2
Lint
Lint Passed
Unit
Tests Skipped
Build Status
Buildable 7953
Build 8936: [Placeholder Plan] Wait for 30 Seconds
Build 8935: arc lint + arc unit

Event Timeline

meitros retitled this revision from to RFC: Add controller to purge apc.
meitros updated this object.
meitros edited the test plan for this revision. (Show Details)
meitros added a reviewer: epriestley.

Conceptually fine but I want to smooth it down a bit before upstreaming it. Probably put it here with other cache stuff:

purge.png (1×2 px, 328 KB)

When clicked, pop a confirmation dialog with the caveat that only the current web frontend will be purged. Show "no caches are configured" if nothing is purgeable.

When the user confirms, clear both APC and OPCache (if they're installed), then tell the user which cache(s) were cleared.

That's like 200x more work so feel free to not bother and I'll just commandeer this at some point.

I'll do it, but not for a few days

meitros retitled this revision from RFC: Add controller to purge apc to Add dialog to purge opcode/data caches.Sep 10 2015, 3:19 AM
meitros updated this object.
meitros edited the test plan for this revision. (Show Details)
meitros edited edge metadata.

add current web frontend caveat

epriestley edited edge metadata.

Looks great! Couple of minor simplicity/clarity/fragility things in line, if they make sense.

src/applications/cache/spec/PhabricatorDataCacheSpec.php
122–131

This feels a little redundant (both cache specs implement similar code) and a little fragile (changing human-readable text in pht() generally should not affect program behavior, but it will here).

How about this instead?

Add these to PhabricatorCacheSpec (or pick some better names if these feel too clunky):

  • private $clearCacheCallback;
  • setClearCacheCallback($callback)
  • getClearCacheCallback()
  • (Optionally, isClearable(), which just tests if a callback is set, but maybe testing for a null return from getClearCacheCallback() would be good enough.)

Then, when building the caches, use $this->setClearCacheCallback('apc_clear_cache');, etc., to specify how to clear the cache.

src/applications/config/controller/PhabricatorConfigPurgeCacheController.php
4

This should likely extend PhabricatorConfigController instead.

It can then inherit the shouldRequireAdmin() implementation automatically, and doesn't need an explicit implementation.

15

Minor nit, but maybe define $cancel_uri = $this->getApplicationURI('cache/'); here to slightly reduce repetition, as this URI is hard-coded in three places in the remainder of the controller.

54

Consider naming the button "Clear Cache" for clarity.

This revision now requires changes to proceed.Sep 10 2015, 11:22 AM
meitros edited edge metadata.

fixes. Didn't think of a less clunky name for clearCacheCallback

I forgot to retest, so if you accept hold off on pulling until I do

epriestley edited edge metadata.

I think I caught two minor things. This works properly for me locally (with both cache types available).

src/applications/cache/spec/PhabricatorDataCacheSpec.php
49

Incorrect / redundant with the call below inside the ini_get() clause?

src/applications/config/controller/PhabricatorConfigPurgeCacheController.php
24–25

If one of these caches is missing but the other is present (e.g., we have OpCache but not APCu) I think this will try to clear a null callback and produce an error like this:

PHP Warning: call_user_func() expects parameter 1 to be a valid callback, no array or string given in ... on line ...

Likely fix is testing if the callbacks are set before invoking them.

This revision now requires changes to proceed.Sep 10 2015, 5:22 PM
meitros edited edge metadata.

fixes and minor changes. also retested

This revision is now accepted and ready to land.Sep 10 2015, 9:18 PM
This revision was automatically updated to reflect the committed changes.