[ticket/14132] Use transaction for adding notifications to type table

This will prevent a race condition that might occur by two posts being
submitted at the same time with the notification type IDs not being
cached.

PHPBB3-14132
This commit is contained in:
Marc Alexander 2016-03-08 12:36:29 +01:00
parent f55a61d067
commit 10004c4032

View file

@ -923,6 +923,8 @@ class manager
{ {
$notification_type_ids = $this->cache->get('notification_type_ids'); $notification_type_ids = $this->cache->get('notification_type_ids');
$this->db->sql_transaction('begin');
if ($notification_type_ids === false) if ($notification_type_ids === false)
{ {
$notification_type_ids = array(); $notification_type_ids = array();
@ -957,6 +959,8 @@ class manager
$this->cache->put('notification_type_ids', $notification_type_ids); $this->cache->put('notification_type_ids', $notification_type_ids);
} }
$this->db->sql_transaction('commit');
return $notification_type_ids[$notification_type_name]; return $notification_type_ids[$notification_type_name];
} }