Skip to content

Commit

Permalink
Fix EZP-21138: deleted nodes remain in an eZ Flow block
Browse files Browse the repository at this point in the history
(cherry picked from commit 8529414)
  • Loading branch information
dpobel committed Jul 30, 2013
1 parent 115b8d2 commit feeef9e
Showing 1 changed file with 5 additions and 6 deletions.
Expand Up @@ -523,16 +523,15 @@ public static function cleanupRemovedItems()
$limit = 50;
do
{
$items = $db->arrayQuery( 'SELECT object_id FROM ezm_pool', array( 'offset' => $offset, 'limit' => $limit ) );
$items = $db->arrayQuery( 'SELECT node_id FROM ezm_pool', array( 'offset' => $offset, 'limit' => $limit ) );
if ( empty( $items ) )
break;

foreach( $items as $item )
{
$rows = $db->arrayQuery( 'SELECT id, status FROM ezcontentobject WHERE id = ' . $item['object_id'] );
if ( empty( $rows ) or // deleted
( count( $rows ) == 1 and $rows[0]['status'] == 2 ) ) // trashed
$itemArray[] = $item['object_id'];
$rows = $db->arrayQuery( 'SELECT node_id FROM ezcontentobject_tree WHERE node_id = ' . $item['node_id'] );
if ( empty( $rows ) )
$itemArray[] = $item['node_id'];
}

$offset += $limit;
Expand All @@ -543,7 +542,7 @@ public static function cleanupRemovedItems()
if ( $itemArrayCount > 0 )
{
$db->begin();
$db->query( 'DELETE FROM ezm_pool WHERE ' . $db->generateSQLINStatement( $itemArray, 'object_id' ) );
$db->query( 'DELETE FROM ezm_pool WHERE ' . $db->generateSQLINStatement( $itemArray, 'node_id' ) );
$db->commit();
}

Expand Down

0 comments on commit feeef9e

Please sign in to comment.