function db_maintenance_check_status in DB Maintenance 6.2
Same name and namespace in other branches
- 5.2 db_maintenance.module \db_maintenance_check_status()
1 call to db_maintenance_check_status()
- db_maintenance_optimize_tables in ./
db_maintenance.module - Perform the maintenance.
File
- ./
db_maintenance.module, line 379 - Optimizes database tables during cron runs.
Code
function db_maintenance_check_status($status, $op) {
// mysql return codes indicating okay/success all others assumed to be "bad"
$DB_MAINTENANCE_OKAY = array(
'Table is already up to date',
'OK',
);
foreach ($status as $key => $return) {
if (is_numeric($key) && !empty($return)) {
if (in_array($return['Msg_text'], $DB_MAINTENANCE_OKAY)) {
// everything okay only log if explicitly set or we did a repair
if (variable_get('db_maintenance_log', 0) || $op == 'REPAIR') {
watchdog('db_maintenance', 'Success: !op table !table, type: !type, message: !message', array(
'!op' => $op,
'!table' => $return['Table'],
'!type' => $return['Msg_type'],
'!message' => $return['Msg_text'],
));
}
}
else {
// problems encountered
watchdog('db_maintenance', 'Failure: !op table !table type: !type, message: !message', array(
'!op' => $op,
'!table' => $return['Table'],
'!type' => $return['Msg_type'],
'!message' => $return['Msg_text'],
), WATCHDOG_ERROR);
// attempt repair if config is set and makes sense
if (variable_get('db_maintenance_repair', 0) && $op == 'OPTIMIZE' && !empty($return['Table'])) {
$result = db_query('REPAIR TABLE %s', $return['Table']);
$status = array();
while ($status[] = db_fetch_array($result)) {
// get all of the rows
}
db_maintenance_check_status($status, 'REPAIR');
}
}
}
}
// check non-numeric entries (mysql has such a lovely return setup)
if (isset($status['Table']) && isset($status['Op']) && isset($status['Msg_type']) && isset($status['Msg_text'])) {
$new_status = array();
$new_status[] = array(
'Table' => $status['Table'],
'Op' => $status['Op'],
'Msg_type' => $status['Msg_type'],
'Msg_text' => $status['Msg_text'],
);
db_maintenance_check_status($new_status, $op);
}
}