From 6a2a54dcb52cbfd9b5bf8546efb29414f2ec2227 Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Mon, 10 Jul 2017 19:39:26 +0200 Subject: [PATCH] Making upgrade.php somewhat more efficient by remember one-time-inits. --- scripts/upgrade.php | 52 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 45 insertions(+), 7 deletions(-) diff --git a/scripts/upgrade.php b/scripts/upgrade.php index f29c9f10bf..6752a3a161 100755 --- a/scripts/upgrade.php +++ b/scripts/upgrade.php @@ -20,8 +20,8 @@ define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); -$shortoptions = 'x::'; -$longoptions = array('extensions='); +$shortoptions = 'dfx::'; +$longoptions = array('debug', 'files', 'extensions='); $helptext = <<query($sql); } + // This is something we should only have to do once unless introducing new, bad code. + if (DEBUG) printfnq(sprintf('Storing in config that we have done %s', __METHOD__)); + common_config_set('fix', 'upgrade_initConversation', 1); + printfnq("DONE.\n"); } @@ -293,6 +317,11 @@ function initLocalGroup() function initNoticeReshare() { + if (common_config('fix', 'upgrade_initNoticeReshare') <= 1) { + printfnq(sprintf("Skipping %s, fixed by previous upgrade.\n", __METHOD__)); + return; + } + printfnq("Ensuring all reshares have the correct verb and object-type..."); $notice = new Notice(); @@ -312,6 +341,10 @@ function initNoticeReshare() } } + // This is something we should only have to do once unless introducing new, bad code. + if (DEBUG) printfnq(sprintf('Storing in config that we have done %s', __METHOD__)); + common_config_set('fix', 'upgrade_initNoticeReshare', 1); + printfnq("DONE.\n"); } @@ -424,20 +457,25 @@ function fixupFileGeometry() if ($file->find()) { while ($file->fetch()) { + if (DEBUG) printfnq(sprintf('Found file without width: %s\n', _ve($file->getFilename()))); + // Set file geometrical properties if available try { $image = ImageFile::fromFileObject($file); } catch (ServerException $e) { // We couldn't make out an image from the file. + if (DEBUG) printfnq(sprintf('Could not make an image out of the file.\n')); continue; } $orig = clone($file); $file->width = $image->width; $file->height = $image->height; + if (DEBUG) printfnq(sprintf('Setting image file and with to %sx%s.\n', $file->width, $file->height)); $file->update($orig); // FIXME: Do this more automagically inside ImageFile or so. if ($image->getPath() != $file->getPath()) { + if (DEBUG) printfnq(sprintf('Deleting the temporarily stored ImageFile.\n')); $image->unlink(); } unset($image);