No need to pass $this in static function:
$prune_age_options = WatchdogPruneSettings::prune_age_options($this);
As per Alexpot comment https://www.drupal.org/node/2858062#comment-11983172
Also need following code cleanup for t() function.
protected static function prune_age_options($classRef) {
$prune_age_options = [
'' => $classRef->t('None - do not prune based on age'),
'-1 MONTH' => $classRef->t('1 month'),
'-2 MONTHS' => $classRef->t('2 months'),
'-3 MONTHS' => $classRef->t('3 months'),
'-6 MONTHS' => $classRef->t('6 months'),
'-9 MONTHS' => $classRef->t('9 months'),
'-12 MONTHS' => $classRef->t('12 months (1 year)'),
'-18 MONTHS' => $classRef->t('18 months (1.5 years)'),
'-24 MONTHS' => $classRef->t('24 months (2 years)'),
'-30 MONTHS' => $classRef->t('30 months (2.5 years)'),
'-36 MONTHS' => $classRef->t('36 months (3 years)'),
];
return $prune_age_options;
}
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | watchdog-prune-static-function-2860499-2.patch | 2.05 KB | smaaz |
Comments
Comment #2
smaaz commentedPlease find the attached file patch.
Comment #3
vickynandode commentedVerified the patch, it's working fine
Changed the status to RTBC
Comment #7
vishwac9 commentedThanks, learning new things everyday. It does seems a good issue as static methods belongs to a Class and not to any instance objects. Anyways Will follow the issue as commented on by Alex Pott, as his comment looks confusing to me.