public function RegistryCheck::run in URLs queuer 8
Perform the check and determine the severity level.
Diagnostic checks determine whether something you are checking for is in shape, for instance CMI settings on which your plugin depends. Any check reporting self::SEVERITY_ERROR in their run() methods, will cause purge to stop working. Any other severity level will let the purgers proceed operating but you may report any warning through getRecommendation() to be shown on Drupal's status report, purge_ui or any other diagnostic listing.
public function run() {
if (...check..) {
return self::SEVERITY_OK;
}
return self::SEVERITY_WARNING;
}
@warning As diagnostic checks can be expensive, this method is called as rarely as possible. Checks derived from DiagnosticCheckBase will only see the check getting executed when any of the getter methods are called.
Return value
int Integer, matching either of the following constants:
- \Drupal\purge\Plugin\Purge\DiagnosticCheck\DiagnosticCheckInterface::SEVERITY_INFO
- \Drupal\purge\Plugin\Purge\DiagnosticCheck\DiagnosticCheckInterface::SEVERITY_OK
- \Drupal\purge\Plugin\Purge\DiagnosticCheck\DiagnosticCheckInterface::SEVERITY_WARNING
- \Drupal\purge\Plugin\Purge\DiagnosticCheck\DiagnosticCheckInterface::SEVERITY_ERROR
Throws
\Drupal\purge\Plugin\Purge\DiagnosticCheck\Exception\CheckNotImplementedCorrectly Thrown when the return value is incorrect.
Overrides DiagnosticCheckInterface::run
File
- src/
Plugin/ Purge/ DiagnosticCheck/ RegistryCheck.php, line 62
Class
- RegistryCheck
- Tests if the URL queuer's traffic registry is in a healthy shape.
Namespace
Drupal\purge_queuer_url\Plugin\Purge\DiagnosticCheckCode
public function run() {
$this->value = $this->registry
->countUrls();
if ($this->value < 50) {
$this->recommendation = $this
->t("You need to spider your site to be able to queue URLs or paths, for example run: 'wget -r -nd --delete-after -l100 --spider http://site/'.");
return self::SEVERITY_WARNING;
}
elseif ($this->value > 7000) {
$this->recommendation = $this
->t("Your traffic database is huge, please consider tag based invalidation before your site becomes VERY slow!");
return self::SEVERITY_WARNING;
}
$this->recommendation = ' ';
return self::SEVERITY_OK;
}