From 4a0ef95a579384038c781fd341688bf5fed9bdc2 Mon Sep 17 00:00:00 2001 From: dennisxrow Date: Thu, 22 Mar 2018 15:59:40 +0100 Subject: [PATCH] Workaround for Argument 1 passed to eZPublishEventSearch::delete() must be an instance of eZContentObject, null given Co-authored-by: xinyuexrow --- classes/eZPublishEventSearch.php | 29 +++++++++++------------------ search/plugins/ezdual/ezdual.php | 4 ++-- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/classes/eZPublishEventSearch.php b/classes/eZPublishEventSearch.php index e78e6c2..68dda91 100644 --- a/classes/eZPublishEventSearch.php +++ b/classes/eZPublishEventSearch.php @@ -47,29 +47,22 @@ public static function update(eZContentObject $object, $commit = true) } } - public static function delete(eZContentObject $object, $commit = true) + public static function delete($contentObjectId, $commit = true) { - $ezpublishevent_ini = eZINI::instance( 'ezpublishevent.ini' ); - if($ezpublishevent_ini->hasVariable( 'Settings', 'EventClassIdentifier' )) + $client = eZPublishSolarium::createSolariumClient(); + $query = $client->createSelect(); + $query->setQuery('meta_id_si:' . $contentObjectId); + $resulttest = $client->select($query); + if ($resulttest->getNumFound() != 0) { - $classidentifier = $ezpublishevent_ini->variable( 'Settings', 'EventClassIdentifier' ); - if ($object->ClassIdentifier == $classidentifier) - { - $client = eZPublishSolarium::createSolariumClient(); - $query = $client->createSelect(); - $query->setQuery('meta_id_si:' . $object->ID); - $resulttest = $client->select($query); - if ($resulttest->getNumFound() != 0) - { - $update = $client->createUpdate(); - $update->addDeleteQuery('meta_id_si:' . $object->ID); - $update->addCommit(); - $deleteResult = $client->update($update); - } - } + $update = $client->createUpdate(); + $update->addDeleteQuery('meta_id_si:' . $contentObjectId); + $update->addCommit(); + $deleteResult = $client->update($update); } } + public static function commit() { $client = eZPublishSolarium::createSolariumClient(); diff --git a/search/plugins/ezdual/ezdual.php b/search/plugins/ezdual/ezdual.php index 660e85d..6aea6a2 100644 --- a/search/plugins/ezdual/ezdual.php +++ b/search/plugins/ezdual/ezdual.php @@ -60,10 +60,10 @@ function removeObject( $contentObject, $commit = null ) */ function removeObjectById( $contentObjectId, $commit = null ) { - $contentObject = eZContentObject::fetch( $contentObjectId); - eZPublishEventSearch::delete( $contentObject, $commit ); + eZPublishEventSearch::delete( $contentObjectId, $commit ); return parent::removeObjectById( $contentObjectId, $commit ); } + /** * Clean up search index for current installation.