Skip to content

Commit

Permalink
Workaround for Argument 1 passed to eZPublishEventSearch::delete() mu…
Browse files Browse the repository at this point in the history
…st be an instance of eZContentObject, null given

Co-authored-by: xinyuexrow <wang@xrow.de>
  • Loading branch information
dennisxrow and xinyuexrow committed Mar 22, 2018
1 parent a0079a5 commit 4a0ef95
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 20 deletions.
29 changes: 11 additions & 18 deletions classes/eZPublishEventSearch.php
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions search/plugins/ezdual/ezdual.php
Expand Up @@ -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.
Expand Down

0 comments on commit 4a0ef95

Please sign in to comment.