In cache-install.inc, there's this code:
/**
* Overrides DrupalDatabaseCache::clear().
*/
function clear($cid = NULL, $wildcard = FALSE) {
// If there is a database cache, attempt to clear it whenever possible. The
// reason for doing this is that the database cache can accumulate data
// during installation due to any full bootstraps that may occur at the
// same time (for example, Ajax requests triggered by the installer). If we
// didn't try to clear it whenever this function is called, the data in the
// cache would become stale; for example, the installer sometimes calls
// variable_set(), which updates the {variable} table and then clears the
// cache to make sure that the next page request picks up the new value.
// Not actually clearing the cache here therefore leads old variables to be
// loaded on the first page requests after installation, which can cause
// subtle bugs, some of which would not be fixed unless the site
// administrator cleared the cache manually.
try {
if (class_exists('Database')) {
parent::clear($cid, $wildcard);
}
}
// If the attempt at clearing the cache causes an error, that means that
// either the database connection is not set up yet or the relevant cache
// table in the database has not yet been created, so we can safely do
// nothing here.
catch (Exception $e) {
}
}
However, the clear() method no longer exists; it was removed in #1272706: Remove backwards compatibility layer for cache API.
Given that this function apparently no longer gets called, I tried to reproduce some of the bugs described in the code comment (one I remember was that during 7.x-dev before this was added, the site name displayed incorrectly on the first page load after a new install) but I couldn't. So maybe if we're lucky something else changed such that we can just delete this, but I doubt it will be that simple...
Comments
Comment #1
pounardThere is still a possible silent bugs due to cache stall during install, the install backend remains a partial implementation that doesn't save caches but still delete cruft thanks to delete() deletePrefix() and flush(), we might want to keep it until we get back working on the install issue.
Comment #2
David_Rothstein CreditAttribution: David_Rothstein commentedOK, now I see why the previous bugs weren't reproducible. Kind of obvious actually: Since the installer cache wasn't overriding the methods it was supposed to be, they just fell back on using the regular database cache backend anyway, so the caches still got cleared.
What that means is that there is actually a different bug here. If the installer happened to call any code early on that tried to clear caches in particular ways, there would be a fatal error because the database isn't available yet. I guess it was just luck that that doesn't happen in the current codebase.
I see that #1323120: Convert cache system to PSR-0 actually fixed some of the bugs here, but there are a few remaining. The attached patch fixes them, and also adds a bunch of tests. We can't test the installer directly, but we can simulate it and thereby at least test that the installer's cache implementation does the correct thing. This is a little wonky and requires a fair amount of code, but it should be worth it.
The basic concept behind the tests is backportable to D7.
Comment #3
David_Rothstein CreditAttribution: David_Rothstein commentedThe original symptom of this bug has actually reappeared in Drupal 8 (see #1536262: Entering a site name when installing Drupal 8 has no effect until caches are cleared) although strangely the patch here doesn't seem to fix it, so maybe it's actually a different bug.
In any case, here's a reroll against the latest Drupal 8 codebase.
Comment #5
David_Rothstein CreditAttribution: David_Rothstein commentedThis version should work better.
It now contains fixes discussed in #1536262: Entering a site name when installing Drupal 8 has no effect until caches are cleared, as well as some other required alterations due to recent changes in Drupal core.
Comment #6
David_Rothstein CreditAttribution: David_Rothstein commentedComment #7
David_Rothstein CreditAttribution: David_Rothstein commentedMoving to major priority, since the tests in this patch will catch/prevent the bug at #1536262: Entering a site name when installing Drupal 8 has no effect until caches are cleared, and that bug is classified as major so this should be also.
Comment #8
catchThe patch looks good. With the test itself, would it be simpler to just use the DatabaseBackend and InstallBackend classes directly in the test? Seems like we could avoid both the page requests and the helper module in that case. This is explicitly testing the interaction of those classes with each other, so I think it's fine if it doesn't go through the cache factory.
Comment #9
David_Rothstein CreditAttribution: David_Rothstein commentedHm, I think you're right - there isn't any overwhelming reason the tests need to be using the cache() function, and removing it would simplify things.
Comment #10
David_Rothstein CreditAttribution: David_Rothstein commentedHere's a new version that does that, and yes, it makes the tests a lot simpler. We still need the helper module (so we can delete the cache table midway through the test), but the module is now tiny and the tests are more straightforward and don't have to make any page requests.
I also added the new invalidateTags() method to the list of tests performed here.
Comment #11
pounardThis patch is looking good (it is simple and quite straightforward), I won't do any whitespace review, if it passes tests it's enough for me. I'd say it's RTBC.
Comment #12
catchThis looks fine to me too, marking RTBC.
Comment #13
catch#10: installer-cache-1394648-10.patch queued for re-testing.
Comment #15
David_Rothstein CreditAttribution: David_Rothstein commentedThe conflict was here:
(The last line wasn't in the codebase before.)
Since there's no actual difference between the attached patch and the previous one, I'm boldly setting this back to RTBC...
Comment #17
David_Rothstein CreditAttribution: David_Rothstein commentedOops. Less boldly this time, but still trying it again :)
The only change is trivial, from this:
To this:
Comment #18
David_Rothstein CreditAttribution: David_Rothstein commentedActually, looking at the surrounding code we're probably better off doing this instead:
Trying that now.
Comment #19
catchI'll take the CNR change as an even less bold RTBC since this has come back green. I think the only thing that needs to be backported here is the tests (unless I missed something), so moving to 'normal task' for that. Committed/pushed to 8.x.
Comment #20
boombatower CreditAttribution: boombatower commentedJust backported the test only as per catch in #19. Was curious to try out my git backporting method using rebase. It works well (not to say test will pass). :)
Comment #22
xjmFatal error: Class 'DatabaseBackend' not found in /var/lib/drupaltestbot/sites/default/files/checkout/modules/simpletest/tests/cache.test on line 449
This class has probably been renamed during a PSR-0 conversion; check the change notices or git blame history (http://www.kernel.org/pub/software/scm/git/docs/git-blame.html, http://drupal.org/node/1462360#comment-5677360) to find the new name. Then, update the patch.
Comment #23
disasm CreditAttribution: disasm commentedattached is a patch that fixes the class names that were changed from 7.x->8.x. It also removes the tests for the methods that don't exist in the old implementation. This test is failing with the error:
PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'drupal8.simpletest320671test' doesn't exist: DELETE FROM {test} WHERE (cid = :db_condition_placeholder_0) ; Array ( [:db_condition_placeholder_0] => cache_one )
Comment #24
naxoc CreditAttribution: naxoc commentedThe tests run now. There was an assertion asserting false on something that would always be true
In
DrupalFakeCache
,isEmpty()
is overriden to do this:There are assertions testing this in the test. That may be fine, but I feel like we need some more documentation on it. It certainly had me scratching my head.
Comment #25
xjmThanks @naxoc and @disasm!
The issue is filed against 7.x currently, so we do want to test the D7 patches. (So we should remove the
-do-not-test
from the filename.) Ideally, we should also post a tests-only D7 patch along with the complete patch, in order to verify that the backported tests are providing coverage. Like so:Thanks for providing the interdiffs; it's very helpful.
Agreed @naxoc; this change makes me nervous. It seems to directly contradict the comment there? Here's the same hunk in the D8 patch:
Definitely asserting false, which means there's a difference in the functional code. We need to debug this further... Meanwhile, though, let's get those test-only and combined D7 patches for the bot to test. :)
Comment #26
David_Rothstein CreditAttribution: David_Rothstein commentedWell, the D8 patch contained a fix for the bug itself:
So if we want that test to pass we'd need to make a similar change in Drupal 7.
But I wonder if maybe we shouldn't bother with that (and just leave that test out instead).... I think the current behavior is wrong, but it's not causing any harm either so maybe for Drupal 7 we should just keep it as is.
Comment #27
kid_icarus CreditAttribution: kid_icarus commentedHere are the patches renamed and reuploaded per #25.