X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=scripts%2Ffixup_utf8.php;h=2af6f9cb047643e838116d293d5c1a57cdb70e04;hb=013647f0ba29949e9025330b9692ad3113b1d644;hp=1693760914e32e96c6227e4715fd3c669728aead;hpb=ed21af0d1db3c5937523af130d26dd573b473fc3;p=quix0rs-gnu-social.git diff --git a/scripts/fixup_utf8.php b/scripts/fixup_utf8.php old mode 100644 new mode 100755 index 1693760914..2af6f9cb04 --- a/scripts/fixup_utf8.php +++ b/scripts/fixup_utf8.php @@ -1,8 +1,8 @@ #!/usr/bin/env php + +Fixup records in a database that stored the data incorrectly (pre-0.7.4 for StatusNet). + +ENDOFHELP; + +require_once INSTALLDIR.'/scripts/commandline.inc'; +require_once 'DB.php'; class UTF8FixerUpper { @@ -45,7 +42,7 @@ class UTF8FixerUpper { $this->args = $args; - if (array_key_exists('max_date', $args)) { + if (!empty($args['max_date'])) { $this->max_date = strftime('%Y-%m-%d %H:%M:%S', strtotime($args['max_date'])); } else { $this->max_date = strftime('%Y-%m-%d %H:%M:%S', time()); @@ -148,7 +145,7 @@ class UTF8FixerUpper echo "$id..."; - $result =& $this->dbu->execute($sth, array($content, $rendered, $id)); + $result = $this->dbu->execute($sth, array($content, $rendered, $id)); if (PEAR::isError($result)) { echo "ERROR: " . $result->getMessage() . "\n"; @@ -212,7 +209,7 @@ class UTF8FixerUpper echo "$id..."; - $result =& $this->dbu->execute($sth, array($fullname, $location, $bio, $id)); + $result = $this->dbu->execute($sth, array($fullname, $location, $bio, $id)); if (PEAR::isError($result)) { echo "ERROR: " . $result->getMessage() . "\n"; @@ -252,7 +249,7 @@ class UTF8FixerUpper $sql = 'SELECT id, fullname, location, description FROM user_group ' . 'WHERE LENGTH(fullname) != CHAR_LENGTH(fullname) '. 'OR LENGTH(location) != CHAR_LENGTH(location) '. - 'OR LENGTH(description) != CHAR_LENGTH(description) '; + 'OR LENGTH(description) != CHAR_LENGTH(description) '. 'AND modified < "'.$this->max_date.'" '. 'ORDER BY modified DESC'; @@ -276,7 +273,7 @@ class UTF8FixerUpper echo "$id..."; - $result =& $this->dbu->execute($sth, array($fullname, $location, $description, $id)); + $result = $this->dbu->execute($sth, array($fullname, $location, $description, $id)); if (PEAR::isError($result)) { echo "ERROR: " . $result->getMessage() . "\n"; @@ -333,7 +330,7 @@ class UTF8FixerUpper echo "$id..."; - $result =& $this->dbu->execute($sth, array($content, $rendered, $id)); + $result = $this->dbu->execute($sth, array($content, $rendered, $id)); if (PEAR::isError($result)) { echo "ERROR: " . $result->getMessage() . "\n"; @@ -356,9 +353,9 @@ class UTF8FixerUpper } } -$max_date = ($argc > 1) ? $argv[1] : null; -$max_id = ($argc > 2) ? $argv[2] : null; -$min_id = ($argc > 3) ? $argv[3] : null; +$max_date = (count($args) > 0) ? $args[0] : null; +$max_id = (count($args) > 1) ? $args[1] : null; +$min_id = (count($args) > 2) ? $args[2] : null; $fixer = new UTF8FixerUpper(array('max_date' => $max_date, 'max_notice' => $max_id,