Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
if (!$theme instanceof Extension) {
$themes = \Drupal::service('theme_handler')->listInfo();
if (!isset($themes[$theme])) {
return array();
}
$theme = $themes[$theme];
}
system_region_list() is retrieving info on all installed themes, when it just wants the extension object for the current theme. I'm not sure if there's a performance cost, but even if there isn't, it's clearer if the code just gets the one theme it wants.
Comment | File | Size | Author |
---|---|---|---|
#14 | 2647672-14.patch | 732 bytes | ranjith_kumar_k_u |
| |||
#2 | 2647672-2.drupal.system_region_list-get-theme.patch | 701 bytes | joachim |
Comments
Comment #2
joachim CreditAttribution: joachim commentedComment #3
joachim CreditAttribution: joachim commentedNote system_region_list() returns an empty array if the requested theme doesn't exist. So to preserve this behaviour, I'm catching the exception that getTheme() returns in that case.
Comment #14
ranjith_kumar_k_u CreditAttribution: ranjith_kumar_k_u at Zyxware Technologies commentedRe-rolled for 9.2
Comment #16
mitthukumawat CreditAttribution: mitthukumawat as a volunteer and at Zyxware Technologies for Drupal Association commentedPatch #14 applied cleanly in 9.2.x-dev and 9.3.x-dev versions. Thanks for the patch.
Comment #20
smustgrave CreditAttribution: smustgrave at Mobomo commentedIs this something that will require a test case?