fix bug : deleted entities crash site when in usser flag_lists
This commit is contained in:
parent
f21817dec1
commit
8ec6b54b6c
@ -33,3 +33,5 @@ login_tobogan (pd with field permission et donc field collection)
|
|||||||
- https://www.drupal.org/node/1365764#comment-10286257
|
- https://www.drupal.org/node/1365764#comment-10286257
|
||||||
- logintoboggan-exempting_lt_preauth_role_from_user_permissions_js-1365764-52.patch
|
- logintoboggan-exempting_lt_preauth_role_from_user_permissions_js-1365764-52.patch
|
||||||
- interdiff-1365764-23-52-do-not-test.diff
|
- interdiff-1365764-23-52-do-not-test.diff
|
||||||
|
flag_lists
|
||||||
|
- https://www.drupal.org/project/flag_lists/issues/2114731
|
||||||
|
55
flag_lists-remove_deleted_entity-2114731-2.patch
Normal file
55
flag_lists-remove_deleted_entity-2114731-2.patch
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
diff --git a/flag_lists.module b/flag_lists.module
|
||||||
|
index d829113..b3c04f0 100644
|
||||||
|
--- a/flag_lists.module
|
||||||
|
+++ b/flag_lists.module
|
||||||
|
@@ -1587,6 +1587,32 @@ function flag_lists_fix_link(&$link, $action) {
|
||||||
|
return $fcid;
|
||||||
|
}
|
||||||
|
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Remove all entries of entity_id and type
|
||||||
|
+ *
|
||||||
|
+ * @param $entity_id
|
||||||
|
+ * Entity id which has been flagged.
|
||||||
|
+ * @param $type
|
||||||
|
+ * The entity type.
|
||||||
|
+ */
|
||||||
|
+ function _flag_lists_remove_entity($entity_id, $type) {
|
||||||
|
+ $query = db_select('flag_lists_content')
|
||||||
|
+ ->condition('entity_id', $entity_id)
|
||||||
|
+ ->condition('entity_type', $type);
|
||||||
|
+ $query->fields('flag_lists_content', array('fcid', 'fid', 'uid', 'sid'));
|
||||||
|
+ $items = $query->execute()->fetchAll();
|
||||||
|
+
|
||||||
|
+ if ($items) {
|
||||||
|
+ foreach ($items as $key => $value) {
|
||||||
|
+ db_delete('flag_lists_content')
|
||||||
|
+ ->condition('fcid', $value->fcid)
|
||||||
|
+ ->execute();
|
||||||
|
+ watchdog('flag_lists', t('Deleted entry @fcid from flat_lists_content', array('@fcid' => $value->fcid)));
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
/**
|
||||||
|
* Updates the flag count for this content
|
||||||
|
*/
|
||||||
|
@@ -1766,3 +1792,17 @@ function flag_lists_views_form_substitutions() {
|
||||||
|
$select_all_placeholder => drupal_render($select_all),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+/**
|
||||||
|
+ * Implements hook_entity_delete
|
||||||
|
+ */
|
||||||
|
+function flag_lists_entity_delete($entity, $type) {
|
||||||
|
+ foreach (flag_get_flags($type) as $flag) {
|
||||||
|
+ if (isset($entity->vid)) {
|
||||||
|
+ $items = _flag_lists_remove_entity($entity->vid, $type);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+
|
@ -23,9 +23,9 @@ files[] = includes/flag_lists_handler_filter_list.inc
|
|||||||
description = Allows users to create personal flag lists.
|
description = Allows users to create personal flag lists.
|
||||||
|
|
||||||
|
|
||||||
; Information added by Drupal.org packaging script on 2016-09-07
|
; Information added by Drupal.org packaging script on 2017-10-02
|
||||||
version = "7.x-3.1"
|
version = "7.x-3.2"
|
||||||
core = "7.x"
|
core = "7.x"
|
||||||
project = "flag_lists"
|
project = "flag_lists"
|
||||||
datestamp = "1473230043"
|
datestamp = "1506952771"
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ function flag_lists_schema() {
|
|||||||
'type' => array(
|
'type' => array(
|
||||||
'type' => 'varchar',
|
'type' => 'varchar',
|
||||||
'length' => '32',
|
'length' => '32',
|
||||||
'not null' => FALSE,
|
'not null' => TRUE,
|
||||||
'default' => '')
|
'default' => '')
|
||||||
),
|
),
|
||||||
'primary key' => array('name', 'type'),
|
'primary key' => array('name', 'type'),
|
||||||
@ -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'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -385,3 +385,16 @@ function flag_lists_update_7305() {
|
|||||||
'not null' => TRUE,
|
'not null' => TRUE,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the flag_lists_types table
|
||||||
|
*/
|
||||||
|
function flag_lists_update_7306() {
|
||||||
|
db_change_field('flag_lists_types','type', 'type',
|
||||||
|
array(
|
||||||
|
'type' => 'varchar',
|
||||||
|
'length' => '32',
|
||||||
|
'not null' => TRUE,
|
||||||
|
'default' => '',
|
||||||
|
));
|
||||||
|
}
|
||||||
|
@ -141,7 +141,7 @@ function flag_lists_menu() {
|
|||||||
'type' => MENU_LOCAL_TASK,
|
'type' => MENU_LOCAL_TASK,
|
||||||
);
|
);
|
||||||
$items['user/%user/flag/lists/%'] = array(
|
$items['user/%user/flag/lists/%'] = array(
|
||||||
'title' =>drupal_ucfirst(variable_get('flag_lists_name', 'list')
|
'title' =>drupal_ucfirst(variable_get('flag_lists_name', 'list')
|
||||||
. ' ' . 'content'),
|
. ' ' . 'content'),
|
||||||
'page callback' => 'flag_lists_user_list',
|
'page callback' => 'flag_lists_user_list',
|
||||||
'page arguments' => array(1, 4),
|
'page arguments' => array(1, 4),
|
||||||
@ -573,7 +573,7 @@ function flag_lists_ops_form_submit($form, &$form_state) {
|
|||||||
foreach ($user_flag_lists as $key => $op) {
|
foreach ($user_flag_lists as $key => $op) {
|
||||||
// Iterate over all flags by this user
|
// Iterate over all flags by this user
|
||||||
list($k1,$k2,$owner,$ofid) = explode('_', $key);
|
list($k1,$k2,$owner,$ofid) = explode('_', $key);
|
||||||
|
|
||||||
foreach ($ops as $op) {
|
foreach ($ops as $op) {
|
||||||
// Iterate over all selected items
|
// Iterate over all selected items
|
||||||
list($nid,$fid) = array_merge( explode('-', $op), array(FALSE));
|
list($nid,$fid) = array_merge( explode('-', $op), array(FALSE));
|
||||||
@ -1009,7 +1009,7 @@ function flag_lists_get_user_flags($content_type = NULL, $account = NULL, $use_f
|
|||||||
foreach ($flags as $key => $flag) {
|
foreach ($flags as $key => $flag) {
|
||||||
if (!isset($flag->module)) {
|
if (!isset($flag->module)) {
|
||||||
// Assume flag is from flag module
|
// Assume flag is from flag module
|
||||||
$flags[$key]->module = 'flag';
|
$flags[$key]->module = 'flag';
|
||||||
}
|
}
|
||||||
// Strip out any list templates
|
// Strip out any list templates
|
||||||
if (stristr($flag->name, 'fl_template') !== FALSE) {
|
if (stristr($flag->name, 'fl_template') !== FALSE) {
|
||||||
@ -1408,7 +1408,7 @@ function flag_lists_page($action = NULL, $flag_name = NULL, $entity_id = NULL) {
|
|||||||
|
|
||||||
// Shorten up the variables that affect the behavior of this page.
|
// Shorten up the variables that affect the behavior of this page.
|
||||||
$js = isset($_REQUEST['js']);
|
$js = isset($_REQUEST['js']);
|
||||||
$token = $_REQUEST['token'];
|
$token = isset($_REQUEST['token']) ? $_REQUEST['token'] : '';
|
||||||
|
|
||||||
// Specifically $_GET to avoid getting the $_COOKIE variable by the same key.
|
// Specifically $_GET to avoid getting the $_COOKIE variable by the same key.
|
||||||
$has_js = isset($_GET['has_js']);
|
$has_js = isset($_GET['has_js']);
|
||||||
@ -1444,7 +1444,7 @@ function flag_lists_page($action = NULL, $flag_name = NULL, $entity_id = NULL) {
|
|||||||
else {
|
else {
|
||||||
drupal_set_message($error);
|
drupal_set_message($error);
|
||||||
drupal_access_denied();
|
drupal_access_denied();
|
||||||
return;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1481,6 +1481,45 @@ function flag_lists_fix_link(&$link, $action) {
|
|||||||
$link = str_replace('/flag/' . $action . '/', '/flag-lists/' . $action . '/', $link);
|
$link = str_replace('/flag/' . $action . '/', '/flag-lists/' . $action . '/', $link);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove all entries of entity_id and type
|
||||||
|
*
|
||||||
|
* @param $entity_id
|
||||||
|
* Entity id which has been flagged.
|
||||||
|
* @param $type
|
||||||
|
* The entity type.
|
||||||
|
*/
|
||||||
|
function _flag_lists_remove_entity($entity_id, $type) {
|
||||||
|
$query = db_select('flag_lists_content')
|
||||||
|
->condition('entity_id', $entity_id)
|
||||||
|
->condition('entity_type', $type);
|
||||||
|
$query->fields('flag_lists_content', array('fcid', 'fid', 'uid', 'sid'));
|
||||||
|
$items = $query->execute()->fetchAll();
|
||||||
|
|
||||||
|
if ($items) {
|
||||||
|
foreach ($items as $key => $value) {
|
||||||
|
db_delete('flag_lists_content')
|
||||||
|
->condition('fcid', $value->fcid)
|
||||||
|
->execute();
|
||||||
|
watchdog('flag_lists', t('Deleted entry @fcid from flat_lists_content', array('@fcid' => $value->fcid)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements hook_entity_delete
|
||||||
|
*/
|
||||||
|
function flag_lists_entity_delete($entity, $type) {
|
||||||
|
foreach (flag_get_flags($type) as $flag) {
|
||||||
|
if (isset($entity->vid)) {
|
||||||
|
$items = _flag_lists_remove_entity($entity->vid, $type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flags, or unflags, an item.
|
* Flags, or unflags, an item.
|
||||||
*
|
*
|
||||||
|
@ -7,11 +7,27 @@ class flag_lists_handler_filter_template extends views_handler_filter_in_operato
|
|||||||
function get_value_options() {
|
function get_value_options() {
|
||||||
if (!isset($this->value_options)) {
|
if (!isset($this->value_options)) {
|
||||||
$this->value_title = t('List templates');
|
$this->value_title = t('List templates');
|
||||||
|
$this->value_options = array();
|
||||||
$templates = flag_lists_get_templates();
|
$templates = flag_lists_get_templates();
|
||||||
foreach ($templates as $template) {
|
if (empty($templates)) {
|
||||||
$options[$template->name] = $template->name;
|
drupal_set_message(
|
||||||
|
t('No templates found, create a flag lists <a href="@url">template</a>',
|
||||||
|
array('@url' => url('/admin/structure/flags/lists/template') )),
|
||||||
|
'info');
|
||||||
|
}
|
||||||
|
else if ($templates['0'] === FALSE) {
|
||||||
|
drupal_set_message(
|
||||||
|
t('No enabled template found, enable the built in flag lists <a href="@url">template</a>',
|
||||||
|
array('@url' => url('/admin/structure/flags/manage/fl_template') )),
|
||||||
|
'warning');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
foreach ($templates as $template) {
|
||||||
|
$options[$template->name] = $template->name;
|
||||||
|
}
|
||||||
|
$this->value_options = $options;
|
||||||
}
|
}
|
||||||
$this->value_options = $options;
|
|
||||||
}
|
}
|
||||||
|
return $this->value_options;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,10 @@ function materio_admin_permission() {
|
|||||||
'title' => t('access duplicate mails list'),
|
'title' => t('access duplicate mails list'),
|
||||||
'description' => t('access duplicate mails list.'),
|
'description' => t('access duplicate mails list.'),
|
||||||
),
|
),
|
||||||
|
'access missing flags list' => array(
|
||||||
|
'title' => t('access missing flags list'),
|
||||||
|
'description' => t('access missing flags list.'),
|
||||||
|
),
|
||||||
'materio admin fix term reference field' => array(
|
'materio admin fix term reference field' => array(
|
||||||
'title' => t('Materio admin fix term reference field'),
|
'title' => t('Materio admin fix term reference field'),
|
||||||
'description' => t('Materio admin fix term reference field.'),
|
'description' => t('Materio admin fix term reference field.'),
|
||||||
@ -55,6 +59,15 @@ function materio_admin_menu() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(module_exists('flag') && module_exists('flag_lists')){
|
||||||
|
$items['admin/people/missingflags'] = array(
|
||||||
|
'title' => "Missing Flags",
|
||||||
|
'page callback' => 'materio_missingflags',
|
||||||
|
'access callback' => 'user_access',
|
||||||
|
'access arguments' => array('access missing flags list'),
|
||||||
|
'type' => MENU_LOCAL_TASK
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// fix term ref field lost with taxonomy
|
// fix term ref field lost with taxonomy
|
||||||
$items['admin/config/content/materio'] = array(
|
$items['admin/config/content/materio'] = array(
|
||||||
@ -114,6 +127,43 @@ function materio_duplicatemails(){
|
|||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function materio_missingflags(){
|
||||||
|
$flags = db_query('SELECT fcid,fid,entity_type,entity_id,uid FROM {flag_lists_content}');
|
||||||
|
|
||||||
|
foreach ($flags as $key => $value) {
|
||||||
|
// $entity = entity_load($value->entity_type, array($value->entity_id));
|
||||||
|
$query = new EntityFieldQuery();
|
||||||
|
$query
|
||||||
|
->entityCondition('entity_type', $value->entity_type)
|
||||||
|
->propertyCondition('nid', $value->entity_id);
|
||||||
|
$entity = $query->execute();
|
||||||
|
|
||||||
|
if(!isset($entity['node'])){
|
||||||
|
$missingentities[$value->fid] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bail out early if there are no duplicates.
|
||||||
|
if (!$missingentities) {
|
||||||
|
return t('No missing entities in flags.');
|
||||||
|
}else{
|
||||||
|
dsm($missingentities);
|
||||||
|
}
|
||||||
|
|
||||||
|
// delete flags with missing entities
|
||||||
|
foreach ($missingentities as $fid => $value) {
|
||||||
|
db_delete('flag_lists_content')
|
||||||
|
->condition('fcid', $value->fcid)
|
||||||
|
->execute();
|
||||||
|
watchdog('flag_lists', t('Deleted entry @fcid from flat_lists_content', array('@fcid' => $value->fcid)));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Turn the data we've got into markup.
|
||||||
|
$output = t('@count missing entities in flag lists have been cleaned', array('@count'=> count($missingentities)));
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
function materio_admin_fix_termref_fields_form(){
|
function materio_admin_fix_termref_fields_form(){
|
||||||
drupal_set_title('Fix term reference fields', PASS_THROUGH);
|
drupal_set_title('Fix term reference fields', PASS_THROUGH);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user