aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/notification/manager.php
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2018-10-27 22:26:29 +0200
committerMarc Alexander <admin@m-a-styles.de>2018-10-27 22:26:29 +0200
commit042f47fc3f2e33bbb9791b0dc66b7ea6ccaa8d94 (patch)
treea58e33275c93365ad0edafeb5c0a703bea88f3ea /phpBB/phpbb/notification/manager.php
parentfd95355c6129043e09d189c193ff5d1abde8db96 (diff)
parent175ffa869be0d353156e2e332136f63ade30a043 (diff)
downloadforums-042f47fc3f2e33bbb9791b0dc66b7ea6ccaa8d94.tar
forums-042f47fc3f2e33bbb9791b0dc66b7ea6ccaa8d94.tar.gz
forums-042f47fc3f2e33bbb9791b0dc66b7ea6ccaa8d94.tar.bz2
forums-042f47fc3f2e33bbb9791b0dc66b7ea6ccaa8d94.tar.xz
forums-042f47fc3f2e33bbb9791b0dc66b7ea6ccaa8d94.zip
Merge pull request #5420 from senky/ticket/15850
[ticket/15850] Fix "Duplicate entry" for notification types
Diffstat (limited to 'phpBB/phpbb/notification/manager.php')
-rw-r--r--phpBB/phpbb/notification/manager.php31
1 files changed, 9 insertions, 22 deletions
diff --git a/phpBB/phpbb/notification/manager.php b/phpBB/phpbb/notification/manager.php
index ac6bb3c6da..52c650df5d 100644
--- a/phpBB/phpbb/notification/manager.php
+++ b/phpBB/phpbb/notification/manager.php
@@ -899,32 +899,19 @@ class manager
*/
public function get_notification_type_id($notification_type_name)
{
- $notification_type_ids = $this->cache->get('notification_type_ids');
-
- $this->db->sql_transaction('begin');
-
- if ($notification_type_ids === false)
+ $sql = 'SELECT notification_type_id, notification_type_name
+ FROM ' . $this->notification_types_table;
+ $result = $this->db->sql_query($sql, 604800); // cache for one week
+ while ($row = $this->db->sql_fetchrow($result))
{
- $notification_type_ids = array();
-
- $sql = 'SELECT notification_type_id, notification_type_name
- FROM ' . $this->notification_types_table;
- $result = $this->db->sql_query($sql);
- while ($row = $this->db->sql_fetchrow($result))
- {
- $notification_type_ids[$row['notification_type_name']] = (int) $row['notification_type_id'];
- }
- $this->db->sql_freeresult($result);
-
- $this->cache->put('notification_type_ids', $notification_type_ids);
+ $notification_type_ids[$row['notification_type_name']] = (int) $row['notification_type_id'];
}
+ $this->db->sql_freeresult($result);
if (!isset($notification_type_ids[$notification_type_name]))
{
if (!isset($this->notification_types[$notification_type_name]) && !isset($this->notification_types['notification.type.' . $notification_type_name]))
{
- $this->db->sql_transaction('rollback');
-
throw new \phpbb\notification\exception('NOTIFICATION_TYPE_NOT_EXIST', array($notification_type_name));
}
@@ -934,13 +921,13 @@ class manager
));
$this->db->sql_query($sql);
+ // expose new notification type ID for this request
$notification_type_ids[$notification_type_name] = (int) $this->db->sql_nextid();
- $this->cache->put('notification_type_ids', $notification_type_ids);
+ // destroy cache, we have a new addition which we have to to load next time
+ $this->cache->destroy('sql', $this->notification_types_table);
}
- $this->db->sql_transaction('commit');
-
return $notification_type_ids[$notification_type_name];
}