From: Mikael Nordfeldth Date: Thu, 27 Jul 2017 17:39:55 +0000 (+0200) Subject: Quote URL on dupe search and better logging on upgrade X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=586aaa596e2277a2c4bea9cae476014a2837a41d;p=quix0rs-gnu-social.git Quote URL on dupe search and better logging on upgrade --- diff --git a/classes/File.php b/classes/File.php index 9cfdb94c56..67b87efd0d 100644 --- a/classes/File.php +++ b/classes/File.php @@ -735,16 +735,18 @@ class File extends Managed_DataObject $dupfile = new File(); // First we find file entries that would be duplicates of this when shortened // ... and we'll just throw the dupes out the window for now! It's already so borken. - $dupfile->query(sprintf('SELECT * FROM file WHERE LEFT(url, 191) = "%1$s"', $file->shortenedurl)); + $dupfile->query(sprintf('SELECT * FROM file WHERE LEFT(url, 191) = %1$s', $dupfile->_quote($file->shortenedurl))); // Leave one of the URLs in the database by using ->find(true) (fetches first entry) if ($dupfile->find(true)) { print "\nShortening url entry for $table id: {$file->id} ["; $orig = clone($dupfile); + $origurl = $dupfile->url; // save for logging purposes $dupfile->url = $file->shortenedurl; // make sure it's only 191 chars from now on $dupfile->update($orig); print "\nDeleting duplicate entries of too long URL on $table id: {$file->id} ["; // only start deleting with this fetch. while($dupfile->fetch()) { + common_log(LOG_INFO, sprintf('Deleting duplicate File entry of %1$d: %2$d (original URL: %3$s collides with these first 191 characters: %4$s', $dupfile->id, $file->id, $origurl, $file->shortenedurl)); print "."; $dupfile->delete(); }