2010
OK, so the question marks may have (probably) came from when I upgraded from MySQL 4 to MySQL 5 not from the WordPress upgrade. I just didn’t notice when I did the upgrade. It was a quick thing. Anyway, I confirmed that the data in the field was actually a question mark combined with another character and then whipped up a simple PHP script to fix it all. I’ve managed to fix most of the issues but not all. There are some posts that I may have to edit by hand or just ignore. Oh, and the code below assumes the Zend Framework is in your path.
require_once 'Zend/Loader/Autoloader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
$db = new Zend_Db_Adapter_Pdo_Mysql(array(
'host' => 'NOPE',
'username' => 'NOPE',
'password' => 'NOPE',
'dbname' => 'NOPE'));
$sql = 'SELECT ID, post_content FROM wp_posts where post_content like \'%.?%\'';
$result = $db->fetchAll($sql);
$table='wp_posts';
foreach ($result as $row)
{
$newContent = str_replace('.?', '.', $row['post_content']);
$wheres = array("ID={$row['ID']}");
$params = array('post_content' => $newContent);
$db->update($table, $params, $wheres);
}


No Comments »