define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
-$shortoptions = 'x::';
-$longoptions = array('extensions=');
+$shortoptions = 'dfx::';
+$longoptions = array('debug', 'files', 'extensions=');
$helptext = <<<END_OF_UPGRADE_HELP
php upgrade.php [options]
require_once INSTALLDIR.'/scripts/commandline.inc';
+
+if (!defined('DEBUG')) {
+ define('DEBUG', (bool)have_option('d', 'debug'));
+}
+
function main()
{
+ // "files" option enables possibly disk/resource intensive operations
+ // that aren't really _required_ for the upgrade
+ $iterate_files = (bool)have_option('f', 'files');
+
if (Event::handle('StartUpgrade')) {
fixupConversationURIs();
fixupNoticeConversation();
initConversation();
fixupGroupURI();
- fixupFileGeometry();
- deleteLocalFileThumbnailsWithoutFilename();
- deleteMissingLocalFileThumbnails();
- fixupFileThumbnailUrlhash();
- setFilehashOnLocalFiles();
+ if ($iterate_files) {
+ printfnq("Running file iterations:\n");
+ printfnq("* "); fixupFileGeometry();
+ printfnq("* "); deleteLocalFileThumbnailsWithoutFilename();
+ printfnq("* "); deleteMissingLocalFileThumbnails();
+ printfnq("* "); fixupFileThumbnailUrlhash();
+ printfnq("* "); setFilehashOnLocalFiles();
+ printfnq("DONE.\n");
+ } else {
+ printfnq("Skipping intensive/long-running file iteration functions (enable with -f, should be done at least once!)\n");
+ }
initGroupProfileId();
initLocalGroup();
function initConversation()
{
+ if (common_config('fix', 'upgrade_initConversation') <= 1) {
+ printfnq(sprintf("Skipping %s, fixed by previous upgrade.\n", __METHOD__));
+ return;
+ }
+
printfnq("Ensuring all conversations have a row in conversation table...");
$notice = new Notice();
$conv->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");
}
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();
}
}
+ // 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");
}
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);