aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/functions_content.php
diff options
context:
space:
mode:
authorTristan Darricau <tristan.darricau@sensiolabs.com>2016-03-25 11:48:29 +0100
committerTristan Darricau <tristan.darricau@sensiolabs.com>2016-03-25 11:48:29 +0100
commit2a7c514cd074352796b3087a8263dcc552a5c807 (patch)
tree73b9ee2b956633bb77acf1f3ad23d32c8f44fcda /phpBB/includes/functions_content.php
parent3eb6f7176ac44b5786379162fc73df3abd196646 (diff)
parent7f9ba9849b2bd3c97fd9a828ddb46c83199b9c55 (diff)
downloadforums-2a7c514cd074352796b3087a8263dcc552a5c807.tar
forums-2a7c514cd074352796b3087a8263dcc552a5c807.tar.gz
forums-2a7c514cd074352796b3087a8263dcc552a5c807.tar.bz2
forums-2a7c514cd074352796b3087a8263dcc552a5c807.tar.xz
forums-2a7c514cd074352796b3087a8263dcc552a5c807.zip
Merge branch '3.1.x' into 3.2.x
* 3.1.x: [ticket/14437] Make sure attachments array is properly ordered before processing [ticket/14437] Preserve attachment ID order by ordering by attach_id [ticket/14437] Sort attachments after assigning inline attachments [ticket/14437] Correctly assume index from attachment display order
Diffstat (limited to 'phpBB/includes/functions_content.php')
-rw-r--r--phpBB/includes/functions_content.php30
1 files changed, 15 insertions, 15 deletions
diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php
index df4a51db98..fd7fc478bd 100644
--- a/phpBB/includes/functions_content.php
+++ b/phpBB/includes/functions_content.php
@@ -1091,17 +1091,8 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count_a
unset($new_attachment_data);
}
- // Sort correctly
- if ($config['display_order'])
- {
- // Ascending sort
- krsort($attachments);
- }
- else
- {
- // Descending sort
- ksort($attachments);
- }
+ // Make sure attachments are properly ordered
+ ksort($attachments);
foreach ($attachments as $attachment)
{
@@ -1309,8 +1300,6 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count_a
$attachments = $compiled_attachments;
unset($compiled_attachments);
- $tpl_size = sizeof($attachments);
-
$unset_tpl = array();
preg_match_all('#<!\-\- ia([0-9]+) \-\->(.*?)<!\-\- ia\1 \-\->#', $message, $matches, PREG_PATTERN_ORDER);
@@ -1318,8 +1307,7 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count_a
$replace = array();
foreach ($matches[0] as $num => $capture)
{
- // Flip index if we are displaying the reverse way
- $index = ($config['display_order']) ? ($tpl_size-($matches[1][$num] + 1)) : $matches[1][$num];
+ $index = $matches[1][$num];
$replace['from'][] = $matches[0][$num];
$replace['to'][] = (isset($attachments[$index])) ? $attachments[$index] : sprintf($user->lang['MISSING_INLINE_ATTACHMENT'], $matches[2][array_search($index, $matches[1])]);
@@ -1334,6 +1322,18 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count_a
$unset_tpl = array_unique($unset_tpl);
+ // Sort correctly
+ if ($config['display_order'])
+ {
+ // Ascending sort
+ krsort($attachments);
+ }
+ else
+ {
+ // Descending sort
+ ksort($attachments);
+ }
+
// Needed to let not display the inlined attachments at the end of the post again
foreach ($unset_tpl as $index)
{