diff --git a/kernel/content/ezcontentoperationcollection.php b/kernel/content/ezcontentoperationcollection.php index de31628c528..891e0c58555 100644 --- a/kernel/content/ezcontentoperationcollection.php +++ b/kernel/content/ezcontentoperationcollection.php @@ -484,9 +484,19 @@ static public function updateSectionID( $objectID, $versionNum ) static public function removeOldNodes( $objectID, $versionNum ) { $object = eZContentObject::fetch( $objectID ); - + if ( !$object instanceof eZContentObject ) + { + eZDebug::writeError( 'Unable to find object #' . $objectID, __METHOD__ ); + return; + } $version = $object->version( $versionNum ); + if ( !$version instanceof eZContentObjectVersion ) + { + eZDebug::writeError( 'Unable to find version #' . $versionNum . ' for object #' . $objectID, __METHOD__ ); + return; + } + $moveToTrash = true; $assignedExistingNodes = $object->attribute( 'assigned_nodes' ); diff --git a/tests/tests/kernel/content/ezcontentoperationcollection_test.php b/tests/tests/kernel/content/ezcontentoperationcollection_test.php new file mode 100644 index 00000000000..28e693892fe --- /dev/null +++ b/tests/tests/kernel/content/ezcontentoperationcollection_test.php @@ -0,0 +1,29 @@ +setName( "eZContentOperationCollection Tests" ); + } + + /** + * Fatal Error when calling eZContentOperationCollection::removeOldNodes() + * with inexistant object/object version + * + * @link http://issues.ez.no/22232 + */ + public function testRemoveOldNodes() + { + eZContentOperationCollection::removeOldNodes( 1234, 1234 ); + } +} diff --git a/tests/tests/kernel/content/suite.php b/tests/tests/kernel/content/suite.php index a14fc6367a7..b830443c1e0 100644 --- a/tests/tests/kernel/content/suite.php +++ b/tests/tests/kernel/content/suite.php @@ -17,6 +17,7 @@ public function __construct() $this->addTestSuite( 'ezpContentPublishingBehaviourTest' ); $this->addTestSuite( 'eZContentOperationDeleteObjectRegression' ); + $this->addTestSuite( 'eZContentOperationCollectionTest' ); } public static function suite()