diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2014-04-11 12:50:29 +0200 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2014-04-25 11:52:20 +0200 |
commit | 37751b51f95a3f05ea9a40f74978989edd2af69e (patch) | |
tree | 65d2d1f4fe69bca0f94c02744bac31380aad8bfa | |
parent | 418747ed341f0c4d2f1d1c1b5ea177fadde9ce7e (diff) | |
download | forums-37751b51f95a3f05ea9a40f74978989edd2af69e.tar forums-37751b51f95a3f05ea9a40f74978989edd2af69e.tar.gz forums-37751b51f95a3f05ea9a40f74978989edd2af69e.tar.bz2 forums-37751b51f95a3f05ea9a40f74978989edd2af69e.tar.xz forums-37751b51f95a3f05ea9a40f74978989edd2af69e.zip |
[ticket/12371] Do not add unlimited users as responders
We run into the risc that the data is longer then the character limit
of the table column. However as we trim the users list anyway, we can
also just stop adding them and display "many others" instead of "x others"
PHPBB3-12371
-rw-r--r-- | phpBB/language/en/common.php | 7 | ||||
-rw-r--r-- | phpBB/phpbb/notification/type/post.php | 23 |
2 files changed, 27 insertions, 3 deletions
diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index 677b228cc6..956b593476 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -422,14 +422,16 @@ $lang = array_merge($lang, array( 'NOT_WATCHING_FORUM' => 'You are no longer subscribed to updates on this forum.', 'NOT_WATCHING_TOPIC' => 'You are no longer subscribed to this topic.', 'NOTIFICATIONS' => 'Notifications', - // This applies for NOTIFICATION_BOOKMARK, NOTIFICATION_POST, and NOTIFICATION_QUOTE. + // This applies for NOTIFICATION_BOOKMARK and NOTIFICATION_POST. // %1$s will return a list of users that's concatenated using "," and "and" - see STRING_LIST // Once the user count reaches 5 users or more, the list is trimmed using NOTIFICATION_X_OTHERS + // Once the user count reaches 20 users or more, the list is trimmed using NOTIFICATION_MANY_OTHERS // Examples: // A replied... // A and B replied... // A, B and C replied... // A, B, C and 2 others replied... + // A, B, C and many others replied... 'NOTIFICATION_BOOKMARK' => array( 1 => '%1$s replied to the topic ā%2$sā you have bookmarked.', ), @@ -454,7 +456,8 @@ $lang = array_merge($lang, array( 'NOTIFICATION_TOPIC_IN_QUEUE' => 'A new topic titled "%2$s" was posted by %1$s and needs approval.', 'NOTIFICATION_TYPE_NOT_EXIST' => 'The notification type "%s" is missing from the file system.', 'NOTIFICATION_ADMIN_ACTIVATE_USER' => 'The user ā%1$sā is newly registered and requires activation.', - // Used in conjuction with NOTIFICATION_BOOKMARK, NOTIFICATION_POST, and NOTIFICATION_QUOTE. + // Used in conjuction with NOTIFICATION_BOOKMARK and NOTIFICATION_POST. + 'NOTIFICATION_MANY_OTHERS' => 'many others', 'NOTIFICATION_X_OTHERS' => array( 2 => '%d others', ), diff --git a/phpBB/phpbb/notification/type/post.php b/phpBB/phpbb/notification/type/post.php index 987651887f..826be0c992 100644 --- a/phpBB/phpbb/notification/type/post.php +++ b/phpBB/phpbb/notification/type/post.php @@ -210,7 +210,11 @@ class post extends \phpbb\notification\type\base } } - if ($trimmed_responders_cnt) + if ($trimmed_responders_cnt > 20) + { + $usernames[] = $this->user->lang('NOTIFICATION_MANY_OTHERS'); + } + else if ($trimmed_responders_cnt) { $usernames[] = $this->user->lang('NOTIFICATION_X_OTHERS', $trimmed_responders_cnt); } @@ -403,6 +407,14 @@ class post extends \phpbb\notification\type\base $responders = ($responders === null) ? array() : $responders; + // Do not add more then 25 responder, + // we trim the username list to "a, b, c and x others" anyway + // so there is no use to add all of them anyway. + if (sizeof($responders) > 25) + { + return array(); + } + foreach ($responders as $responder) { // Do not add them as a responder multiple times @@ -420,6 +432,15 @@ class post extends \phpbb\notification\type\base $this->set_data('responders', $responders); $serialized_data = serialize($this->get_data(false)); + + // If the data is longer then 4000 characters, it would cause a SQL error + // so we just don't add the username to the list, when this would be the + // case. + if (utf8_strlen($serialized_data) >= 4000) + { + return array(); + } + return array('notification_data' => $serialized_data); } } |