Skip to content

Commit f8e7f31

Browse files
committed
Retain attachment dir indexes
When running the repair_settings with attachments directories with non continous indexes, the indexes was reset to a continous index. If one of the reindexed directories was selected as current attachment directory, it would point to the wrong, or non existing attachment directory index. Fix this by passing and using the current indexes. Non coninous indexes can happen if an attachment directory is removed that is not the last. Signed-off-by: Oscar Rydhé <[email protected]>
1 parent 31135de commit f8e7f31

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

repair_settings.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -773,10 +773,9 @@ function restoreAll()
773773
if (!(isset($array_settings) && is_array($array_settings)) && !is_array($settings[$setting]))
774774
$array_settings = @unserialize($settings[$setting]);
775775
if (!isset($array_settings) || !is_array($array_settings))
776-
$array_settings = array($settings[$setting]);
776+
$array_settings = array(1 => $settings[$setting]);
777777

778-
$item = 1;
779-
foreach ($array_settings as $array_setting)
778+
foreach ($array_settings as $item => $array_setting)
780779
{
781780
$suggested = false;
782781
echo '
@@ -1051,11 +1050,11 @@ function set_settings()
10511050
}
10521051
else
10531052
{
1054-
$attach_count = 1;
10551053
foreach ($setString as $key => $value)
10561054
if (strpos($value[0], 'attachmentUploadDir') == 0 && strpos($value[0], 'attachmentUploadDir') !== false)
10571055
{
1058-
$attach_dirs[$attach_count++] = $value[1];
1056+
$index = substr($value[0], strlen('attachmentUploadDir_'));
1057+
$attach_dirs[$index] = $value[1];
10591058
unset($setString[$key]);
10601059
}
10611060
}

0 commit comments

Comments
 (0)