diff options
author | Marc Alexander <admin@m-a-styles.de> | 2014-10-26 13:56:34 -0700 |
---|---|---|
committer | Marc Alexander <admin@m-a-styles.de> | 2014-10-26 13:56:34 -0700 |
commit | cb65cd363a2065b8e5a13eec5662c6aabc679cd9 (patch) | |
tree | ff1cc5a398ba57440c3a0711f3a35bf6e90649ca /phpBB/phpbb/notification | |
parent | 222bec0204fa600bd72df3bba8fc45131af41c83 (diff) | |
download | forums-cb65cd363a2065b8e5a13eec5662c6aabc679cd9.tar forums-cb65cd363a2065b8e5a13eec5662c6aabc679cd9.tar.gz forums-cb65cd363a2065b8e5a13eec5662c6aabc679cd9.tar.bz2 forums-cb65cd363a2065b8e5a13eec5662c6aabc679cd9.tar.xz forums-cb65cd363a2065b8e5a13eec5662c6aabc679cd9.zip |
[ticket/12703] Only query database for subscription types once
PHPBB3-12703
Diffstat (limited to 'phpBB/phpbb/notification')
-rw-r--r-- | phpBB/phpbb/notification/manager.php | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/phpBB/phpbb/notification/manager.php b/phpBB/phpbb/notification/manager.php index 81b450ebbd..971a53a16a 100644 --- a/phpBB/phpbb/notification/manager.php +++ b/phpBB/phpbb/notification/manager.php @@ -24,6 +24,9 @@ class manager protected $notification_types; /** @var array */ + protected $subscription_types; + + /** @var array */ protected $notification_methods; /** @var ContainerInterface */ @@ -524,33 +527,36 @@ class manager */ public function get_subscription_types() { - $subscription_types = array(); - - foreach ($this->notification_types as $type_name => $data) + if ($this->subscription_types === null) { - $type = $this->get_item_type_class($type_name); + $this->subscription_types = array(); - if ($type instanceof \phpbb\notification\type\type_interface && $type->is_available()) + foreach ($this->notification_types as $type_name => $data) { - $options = array_merge(array( - 'id' => $type->get_type(), - 'lang' => 'NOTIFICATION_TYPE_' . strtoupper($type->get_type()), - 'group' => 'NOTIFICATION_GROUP_MISCELLANEOUS', - ), (($type::$notification_option !== false) ? $type::$notification_option : array())); + $type = $this->get_item_type_class($type_name); + + if ($type instanceof \phpbb\notification\type\type_interface && $type->is_available()) + { + $options = array_merge(array( + 'id' => $type->get_type(), + 'lang' => 'NOTIFICATION_TYPE_' . strtoupper($type->get_type()), + 'group' => 'NOTIFICATION_GROUP_MISCELLANEOUS', + ), (($type::$notification_option !== false) ? $type::$notification_option : array())); - $subscription_types[$options['group']][$options['id']] = $options; + $this->subscription_types[$options['group']][$options['id']] = $options; + } } - } - // Move Miscellaneous to the very last section - if (isset($subscription_types['NOTIFICATION_GROUP_MISCELLANEOUS'])) - { - $miscellaneous = $subscription_types['NOTIFICATION_GROUP_MISCELLANEOUS']; - unset($subscription_types['NOTIFICATION_GROUP_MISCELLANEOUS']); - $subscription_types['NOTIFICATION_GROUP_MISCELLANEOUS'] = $miscellaneous; + // Move Miscellaneous to the very last section + if (isset($this->subscription_types['NOTIFICATION_GROUP_MISCELLANEOUS'])) + { + $miscellaneous = $this->subscription_types['NOTIFICATION_GROUP_MISCELLANEOUS']; + unset($this->subscription_types['NOTIFICATION_GROUP_MISCELLANEOUS']); + $this->subscription_types['NOTIFICATION_GROUP_MISCELLANEOUS'] = $miscellaneous; + } } - return $subscription_types; + return $this->subscription_types; } /** |