Skip to content

Commit

Permalink
Add reprocess attachment as an upgrade option
Browse files Browse the repository at this point in the history
Signed by Shawn Bulen, bulens@pacbell.net
  • Loading branch information
sbulen committed Oct 30, 2022
1 parent c425b64 commit aa2f168
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions Themes/default/languages/Install.english.php
Expand Up @@ -271,6 +271,7 @@
$txt['upgrade_debug_info'] = 'Output extra debugging information.';
$txt['upgrade_empty_errorlog'] = 'Empty error log before upgrading.';
$txt['upgrade_delete_karma'] = 'Delete all karma settings and info from the DB';
$txt['upgrade_reprocess_attachments'] = 'Rerun attachment conversion';
$txt['upgrade_stats_collection'] = 'Allow Simple Machines to collect basic stats monthly.';
$txt['upgrade_stats_info'] = 'If enabled, this will allow Simple Machines to visit your site once a month to collect basic statistics. This will help us make decisions as to which configurations to optimise the software for. For more information please visit our <a href="%1$s" target="_blank" rel="noopener">info page</a>.';
$txt['upgrade_migrate_settings_file'] = 'Migrate to a new Settings file.';
Expand Down
13 changes: 13 additions & 0 deletions other/upgrade.php
Expand Up @@ -1446,6 +1446,9 @@ function UpgradeOptions()
// Emptying the error log?
$_SESSION['empty_error'] = !empty($_POST['empty_error']);

// Reprocessing attachments?
$_SESSION['reprocess_attachments'] = !empty($_POST['reprocess_attachments']);

$changes = array();

// Add proxy settings.
Expand Down Expand Up @@ -1690,6 +1693,7 @@ function DatabaseChanges()

$upcontext['delete_karma'] = !empty($_SESSION['delete_karma']);
$upcontext['empty_error'] = !empty($_SESSION['empty_error']);
$upcontext['reprocess_attachments'] = !empty($_SESSION['reprocess_attachments']);

// All possible files.
// Name, < version, insert_on_complete
Expand Down Expand Up @@ -4307,6 +4311,15 @@ function template_upgrade_options()
<label for="delete_karma">', $txt['upgrade_delete_karma'], '</label>
</li>';

// If attachment step has been run previously, offer an option to do it again.
// Helpful if folks had improper attachment folders specified previously.
if (!empty($modSettings['attachments_21_done']))
echo '
<li>
<input type="checkbox" name="reprocess_attachments" id="reprocess_attachments" value="1">
<label for="reprocess_attachments">', $txt['upgrade_reprocess_attachments'], '</label>
</li>';

echo '
<li>
<input type="checkbox" name="stats" id="stats" value="1"', empty($modSettings['allow_sm_stats']) && empty($modSettings['enable_sm_stats']) ? '' : ' checked="checked"', '>
Expand Down
4 changes: 2 additions & 2 deletions other/upgrade_2-1_mysql.sql
Expand Up @@ -439,8 +439,8 @@ if (!empty($modSettings['currentAttachmentUploadDir']) && !is_array($modSettings
else
$modSettings['attachmentUploadDir'] = @json_decode($modSettings['attachmentUploadDir'], true);

// No need to do this if we already did it previously...
if (empty($modSettings['attachments_21_done']))
// No need to do this if we already did it previously... Unless requested...
if (empty($modSettings['attachments_21_done']) || !empty($upcontext['reprocess_attachments']))
$is_done = false;
else
$is_done = true;
Expand Down

0 comments on commit aa2f168

Please sign in to comment.