[wp-trac] Re: [WordPress Trac] #4677: Automatic REPAIR TABLE
tablename after MySQL error 127
WordPress Trac
wp-trac at lists.automattic.com
Fri Jul 27 16:21:32 GMT 2007
#4677: Automatic REPAIR TABLE tablename after MySQL error 127
------------------------------------------+---------------------------------
Reporter: markjaquith | Owner: anonymous
Type: enhancement | Status: new
Priority: normal | Milestone: 2.4 (future)
Component: General | Version: 2.2.1
Severity: major | Resolution:
Keywords: mysql error 127 repair table |
------------------------------------------+---------------------------------
Comment (by Otto42):
You could do this with a plugin. You'll need to extend the $wpdb class to
do it. I have not tested any of this, of course...
{{{
class my_wpdb extends wpdb {
// override the print_error function
function print_error($str = '') {
if (mysql_errno($this->dbh) == 127 ) {
// do REPAIR TABLE or whatever
}
else {
parent::print_error($str);
}
}
// copy constructor to handle the annoying missing table variables
problem
function my_wpdb($old_wpdb) {
// casting an object to an array returns the vars in the
object
// in the array.. so $vars['posts']='wp_posts'. Handy, no?
$vars = (array)$old_wpdb;
extract($vars, EXTR_OVERWRITE);
}
}
// create a new object for the database
$my_wpdb = new my_wpdb($wpdb);
// assign it back to the main database
$wpdb = $my_wpdb;
}}}
That should work, I think. Should work in a plugin too. But of course, it
won't work if you get the 127 error before the plugins get loaded.
--
Ticket URL: <http://trac.wordpress.org/ticket/4677#comment:3>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list