commented flag_lists failing updates

checked db table integrity, lokks like fine ...
This commit is contained in:
Bachir Soussi Chiadmi 2016-11-05 16:24:44 +01:00
parent 82bb633c3e
commit 2e0abeed03

View File

@ -204,22 +204,22 @@ function flag_lists_uninstall() {
db_delete('variable')->condition('name', 'flag_lists%', 'LIKE')->execute(); db_delete('variable')->condition('name', 'flag_lists%', 'LIKE')->execute();
$view_to_delete = views_get_view('flag_lists'); $view_to_delete = views_get_view('flag_lists');
if (!empty($view_to_delete)) { if (!empty($view_to_delete)) {
views_delete_view($view_to_delete); views_delete_view($view_to_delete);
} }
$view_to_delete =views_get_view('flag_lists_content'); $view_to_delete =views_get_view('flag_lists_content');
if (!empty($view_to_delete)) { if (!empty($view_to_delete)) {
views_delete_view($view_to_delete); views_delete_view($view_to_delete);
} }
$view_to_delete = views_get_view('flag_lists_user_lists'); $view_to_delete = views_get_view('flag_lists_user_lists');
if (!empty($view_to_delete)) { if (!empty($view_to_delete)) {
views_delete_view($view_to_delete); views_delete_view($view_to_delete);
} }
$view_to_delete = views_get_view('flag_lists_user_list'); $view_to_delete = views_get_view('flag_lists_user_list');
if (!empty($view_to_delete)) { if (!empty($view_to_delete)) {
views_delete_view($view_to_delete); views_delete_view($view_to_delete);
} }
@ -230,32 +230,32 @@ function flag_lists_uninstall() {
* Get rid of garbage list entries that are orphaned from a list * Get rid of garbage list entries that are orphaned from a list
*/ */
function flag_lists_update_7000() { function flag_lists_update_7000() {
$orphans = db_query("SELECT flc.fcid, flc.fid, flc.content_id, flc.uid, flcounts.content_type, count // $orphans = db_query("SELECT flc.fcid, flc.fid, flc.content_id, flc.uid, flcounts.content_type, count
FROM {flag_lists_content} flc // FROM {flag_lists_content} flc
JOIN {flag_lists_counts} flcounts ON flcounts.fid=flc.fid AND flc.content_id=flcounts.content_id // JOIN {flag_lists_counts} flcounts ON flcounts.fid=flc.fid AND flc.content_id=flcounts.content_id
LEFT JOIN {flag_lists_flags} flf ON flf.fid=flc.fid // LEFT JOIN {flag_lists_flags} flf ON flf.fid=flc.fid
WHERE flf.fid IS NULL"); // WHERE flf.fid IS NULL");
//
foreach ($orphans as $orphan) { // foreach ($orphans as $orphan) {
$num_deleted = db_delete('flag_lists_content') // $num_deleted = db_delete('flag_lists_content')
->condition('fid', $orphan->fid) // ->condition('fid', $orphan->fid)
->condition('fcid', $orphan->fcid) // ->condition('fcid', $orphan->fcid)
->condition('uid', $orphan->uid) // ->condition('uid', $orphan->uid)
->execute(); // ->execute();
//
if (!empty($num_deleted)) { // if (!empty($num_deleted)) {
drupal_set_message("Deleting flag_id: $orphan->fid flag_content_id: $orphan->fcid"); // drupal_set_message("Deleting flag_id: $orphan->fid flag_content_id: $orphan->fcid");
//
db_update('flag_lists_counts') // db_update('flag_lists_counts')
->fields(array( // ->fields(array(
'count' => ($orphan->count <= 1) ? 0 : $orphan->count - 1, // 'count' => ($orphan->count <= 1) ? 0 : $orphan->count - 1,
)) // ))
->condition('content_type', $orphan->content_type) // ->condition('content_type', $orphan->content_type)
->condition('fid', $orphan->fid) // ->condition('fid', $orphan->fid)
->condition('content_id', $orphan->content_id) // ->condition('content_id', $orphan->content_id)
->execute(); // ->execute();
} // }
} // }
} }
@ -263,48 +263,48 @@ function flag_lists_update_7000() {
* Update the flag_lists_flags table * Update the flag_lists_flags table
*/ */
function flag_lists_update_7301() { function flag_lists_update_7301() {
db_change_field('flag_lists_flags','content_type', 'entity_type', // db_change_field('flag_lists_flags','content_type', 'entity_type',
array( // array(
'type' => 'varchar', // 'type' => 'varchar',
'length' => '32', // 'length' => '32',
'not null' => TRUE, // 'not null' => TRUE,
'default' => '', // 'default' => '',
)); // ));
} }
/** /**
* Update the flag_lists_content table * Update the flag_lists_content table
*/ */
function flag_lists_update_7302() { function flag_lists_update_7302() {
db_drop_unique_key('flag_lists_content','fid_content_id_uid_sid'); // db_drop_unique_key('flag_lists_content','fid_content_id_uid_sid');
db_drop_index('flag_lists_content','content_type_content_id'); // db_drop_index('flag_lists_content','content_type_content_id');
db_drop_index('flag_lists_content','content_type_uid_sid'); // db_drop_index('flag_lists_content','content_type_uid_sid');
//
db_change_field('flag_lists_content','content_type', 'entity_type', // db_change_field('flag_lists_content','content_type', 'entity_type',
array( // array(
'type' => 'varchar', // 'type' => 'varchar',
'length' => '32', // 'length' => '32',
'not null' => TRUE, // 'not null' => TRUE,
'default' => '', // 'default' => '',
)); // ));
//
db_change_field('flag_lists_content','content_id', 'entity_id', // db_change_field('flag_lists_content','content_id', 'entity_id',
array( // array(
'type' => 'int', // 'type' => 'int',
'unsigned' => TRUE, // 'unsigned' => TRUE,
'not null' => TRUE, // 'not null' => TRUE,
'default' => 0, // 'default' => 0,
)); // ));
//
db_add_unique_key('flag_lists_content', // db_add_unique_key('flag_lists_content',
'fid_entity_id_uid_sid', // 'fid_entity_id_uid_sid',
array('fid', 'entity_id', 'uid', 'sid')); // array('fid', 'entity_id', 'uid', 'sid'));
db_add_index('flag_lists_content', // db_add_index('flag_lists_content',
'entity_type_uid_sid', // 'entity_type_uid_sid',
array('entity_type', 'uid', 'sid')); // array('entity_type', 'uid', 'sid'));
db_add_index('flag_lists_content', // db_add_index('flag_lists_content',
'entity_type_entity_id', // 'entity_type_entity_id',
array('entity_type', 'entity_id')); // array('entity_type', 'entity_id'));
} }
/** /**
@ -315,29 +315,29 @@ function flag_lists_update_7303() {
db_drop_index('flag_lists_counts','fid_content_type'); db_drop_index('flag_lists_counts','fid_content_type');
db_drop_index('flag_lists_counts','content_type_content_id'); db_drop_index('flag_lists_counts','content_type_content_id');
db_change_field('flag_lists_counts','content_type', 'entity_type', // db_change_field('flag_lists_counts','content_type', 'entity_type',
array( // array(
'type' => 'varchar', // 'type' => 'varchar',
'length' => '32', // 'length' => '32',
'not null' => TRUE, // 'not null' => TRUE,
'default' => '', // 'default' => '',
)); // ));
db_change_field('flag_lists_counts','content_id', 'entity_id', // db_change_field('flag_lists_counts','content_id', 'entity_id',
array( // array(
'type' => 'int', // 'type' => 'int',
'unsigned' => TRUE, // 'unsigned' => TRUE,
'not null' => TRUE, // 'not null' => TRUE,
'default' => 0, // 'default' => 0,
'disp-width' => '10', // 'disp-width' => '10',
), // ),
array('primary key' => array('fid', 'entity_id'))); // array('primary key' => array('fid', 'entity_id')));
db_add_index('flag_lists_counts', // db_add_index('flag_lists_counts',
'fid_entity_type', // 'fid_entity_type',
array('fid', 'entity_type')); // array('fid', 'entity_type'));
db_add_index('flag_lists_counts', // db_add_index('flag_lists_counts',
'entity_type_entity_id', // 'entity_type_entity_id',
array('entity_type', 'entity_id')); // array('entity_type', 'entity_id'));
} }
/** /**