Skip to content

Commit

Permalink
Merge pull request #867 from guillaumelecerf/EZP-22232
Browse files Browse the repository at this point in the history
Fix EZP-22232: Fatal Error when calling eZContentOperationCollection::re...
  • Loading branch information
yannickroger committed Jan 28, 2014
2 parents 3254636 + 66fa4f5 commit 556cf75
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
12 changes: 11 additions & 1 deletion kernel/content/ezcontentoperationcollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand Down
29 changes: 29 additions & 0 deletions tests/tests/kernel/content/ezcontentoperationcollection_test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
/**
* File containing eZContentOperationCollectionTest class
*
* @copyright Copyright (C) 1999-2014 eZ Systems AS. All rights reserved.
* @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
* @version //autogentag//
* @package tests
*/

class eZContentOperationCollectionTest extends ezpDatabaseTestCase
{
public function __construct( $name = NULL, array $data = array(), $dataName = '' )
{
parent::__construct( $name, $data, $dataName );
$this->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 );
}
}
1 change: 1 addition & 0 deletions tests/tests/kernel/content/suite.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public function __construct()

$this->addTestSuite( 'ezpContentPublishingBehaviourTest' );
$this->addTestSuite( 'eZContentOperationDeleteObjectRegression' );
$this->addTestSuite( 'eZContentOperationCollectionTest' );
}

public static function suite()
Expand Down

0 comments on commit 556cf75

Please sign in to comment.