From 6828567ed067b382f68910dba6d59b603fc782a4 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Thu, 11 Mar 2010 11:52:19 -0800 Subject: [PATCH] Add forgotten scripts/fixup_files.php to clean up "the h bug" --- scripts/fixup_files.php | 77 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100755 scripts/fixup_files.php diff --git a/scripts/fixup_files.php b/scripts/fixup_files.php new file mode 100755 index 0000000000..18feaf2218 --- /dev/null +++ b/scripts/fixup_files.php @@ -0,0 +1,77 @@ +#!/usr/bin/env php +. + */ + +define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); + +$longoptions = array('dry-run'); + +$helptext = <<title = 'h'; +$f->mimetype = 'h'; +$f->size = 0; +$f->protected = 0; +$f->find(); +echo "Found $f->N bad items:\n"; + +while ($f->fetch()) { + echo "$f->id $f->url"; + + $data = File_redirection::lookupWhere($f->url); + if ($dry) { + if (is_array($data)) { + echo " (unchanged)\n"; + } else { + echo " (unchanged, but embedding lookup failed)\n"; + } + } else { + // NULL out the mime/title/size/protected fields + $sql = sprintf("UPDATE file " . + "SET mimetype=null,title=null,size=null,protected=null " . + "WHERE id=%d", + $f->id); + $f->query($sql); + $f->decache(); + + if (is_array($data)) { + if ($f->saveOembed($data, $f->url)) { + echo " (ok)\n"; + } else { + echo " (ok, no embedding data)\n"; + } + } else { + echo " (ok, but embedding lookup failed)\n"; + } + } +} + +echo "done.\n"; + -- 2.39.5