- Issue created by @gribnif
As mentioned in π Drupal\Core\Datetime::dateFormat() does not properly cache results Active , there is a bug in core that is being triggered by SmartDateTrait. The result is tons of extra queries to the database looking for a non-existent date format, like this:
SELECT "cid", "data", "created", "expire", "serialized", "tags", "checksum" FROM "cache_config" WHERE "cid" IN ( 'core.date_format.' ) ORDER BY "cid"
The reason for this is the $type
(second) parameter to \Drupal::service('date.formatter')->format()
, as used in SmartDateTrait. For instance, this line:
$datetime = \Drupal::service('date.formatter')->format($times[$part], '', $format);
should be:
$datetime = \Drupal::service('date.formatter')->format($times[$part], 'custom', $format);
So, even if the parent issue does get fixed, this patch avoids even the first attempt to load the incorrect format.
Active
4.2
Code