function nodewords_update_6159 in Nodewords: D6 Meta Tags 6
Same name and namespace in other branches
- 6.2 nodewords.install \nodewords_update_6159()
Implements hook_update_N().
1 string reference to 'nodewords_update_6159'
- nodewords_uninstall in ./
nodewords.install - Implements hook_uninstall().
File
- ./
nodewords.install, line 1154 - Installation file for nodewords.module.
Code
function nodewords_update_6159(&$sandbox) {
$ret = array();
if (!isset($sandbox['progress'])) {
$sandbox['progress'] = 0;
$sandbox['max'] = (int) db_result(db_query("SELECT COUNT(*) FROM {nodewords} WHERE name = 'robots'"));
$sandbox['current_mtid'] = 0;
}
if ($sandbox['max']) {
$metatags = db_query_range("SELECT * FROM {nodewords} WHERE name = 'robots' AND mtid > %d ORDER BY mtid ASC", $sandbox['current_mtid'], 0, 20);
while ($metatag = db_fetch_object($metatags)) {
// The errors are suppressed to allow the update function to fix as
// much rows as possible; if the call to unserialize returns an error,
// then the content of that row is possibly corrupted.
if (($content = @unserialize($metatag->content)) !== FALSE) {
if (isset($content['value'])) {
if (($value = @unserialize($content['value'])) !== FALSE) {
db_query("UPDATE {nodewords} SET content = '%s' WHERE mtid = %d", serialize($value), $metatag->mtid);
}
}
}
$sandbox['current_mtid'] = $metatag->mtid;
$sandbox['progress']++;
}
}
$ret['#finished'] = empty($sandbox['max']) ? 1 : $sandbox['progress'] / $sandbox['max'];
if ($ret['#finished'] == 1) {
variable_set('nodewords_update_6159', TRUE);
$ret[] = array(
'success' => TRUE,
'query' => 'Corrected the values saved in the database',
);
}
return $ret;
}