Problem/Motivation
In Drupal\purge\Plugin\Purge\Purger\PurgerBase::getTimeHint() has the following condition:
if (!$this->hasRuntimeMeasurement()) {
throw new \LogicException('Since ::hasRuntimeMeasurement() returns TRUE, ::getTimeHint() needs to be implemented!');
}
because of this exception, Purger plugins must implement ::hasRuntimeMeasurement() and set it to return TRUE even if they do not have a Runtime Measurement. Alternatively, they could override this method to bypass the exception.
Proposed resolution
The condition should be reversed so it will look like this:
if ($this->hasRuntimeMeasurement()) {
throw new \LogicException('Since ::hasRuntimeMeasurement() returns TRUE, ::getTimeHint() needs to be implemented!');
}
Remaining tasks
- Write Patch
User interface changes
None.
API changes
This may cause some Purger plugins to throw an exception if they are doing something to bypass this logic.
Data model changes
None.
Comments
Comment #2
joshi.rohit100I faced the same problem while working on #2744413: KeyCDN purger
Comment #3
nielsvm commentedPlease, firstly, allow me to make you aware of the following commit that ends up in the next beta
8.x-3.0-beta5:I think there's a misunderstanding hiding in your words: "do not have a Runtime Measurement". This seems to imply that purgers need to do anything for runtime measurement when returning
TRUE. They do not, in fact, just setting it toTRUEwill turn on all the magic sauce entirely.No, what we in fact ask, is that the developer writing the purger... actively understands and thinks about the problem of runtime performance. This is also why there's no
::hasRuntimeMeasurement() {return TRUE;}in PurgerBase by default.Let's have a look at its (just updated) definition:
So, you just need to return TRUE, but understand what's going on.
Comment #4
nielsvm commentedFurther clarifying and pointing developers in the right direction.