Author: ts Date: Mon Jan 7 19:34:14 2008 New Revision: 7096 Log: - Fixed issue #12108: ezcPersistentStateTransformer::rowToStateArray() relying on definitions with reverse properties set, but it's not automatic.
Modified: trunk/PersistentObject/ChangeLog trunk/PersistentObject/src/internal/state_transformer.php trunk/PersistentObject/tests/persistent_session_test.php Modified: trunk/PersistentObject/ChangeLog ============================================================================== --- trunk/PersistentObject/ChangeLog [iso-8859-1] (original) +++ trunk/PersistentObject/ChangeLog [iso-8859-1] Mon Jan 7 19:34:14 2008 @@ -1,3 +1,10 @@ +1.3.4 - [RELEASEDATE] +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +- Fixed issue #12108: ezcPersistentStateTransformer::rowToStateArray() relying + on definitions with reverse properties set, but it's not automatic. + + 1.3.3 - Monday 17 December 2007 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Modified: trunk/PersistentObject/src/internal/state_transformer.php ============================================================================== --- trunk/PersistentObject/src/internal/state_transformer.php [iso-8859-1] (original) +++ trunk/PersistentObject/src/internal/state_transformer.php [iso-8859-1] Mon Jan 7 19:34:14 2008 @@ -35,11 +35,19 @@ */ public static function rowToStateArray( array $row, ezcPersistentObjectDefinition $def ) { + // Sanity check for reverse-lookup + // Issue #12108 + if ( count( $def->columns ) === 0 ) + { + throw new ezcPersistentObjectException( + "The PersistentObject definition for class {$def->class} was not initialized correctly.", + 'Missing reverse lookup for columns. Check the definition manager.' + ); + } + $result = array(); foreach ( $row as $key => $value ) { - // todo: everything in $row is of type string - // should we convert to the correct PHP type? if ( $key == $def->idProperty->columnName ) { $result[$def->idProperty->propertyName] = $value; Modified: trunk/PersistentObject/tests/persistent_session_test.php ============================================================================== --- trunk/PersistentObject/tests/persistent_session_test.php [iso-8859-1] (original) +++ trunk/PersistentObject/tests/persistent_session_test.php [iso-8859-1] Mon Jan 7 19:34:14 2008 @@ -1000,6 +1000,22 @@ $arr[0]->integer ); } + + /** + * Test case for issue #12108. + */ + public function testMissingReverseColumnLookup() + { + // Load def without def manager + $def = require dirname( __FILE__ ) . '/data/persistenttestobject.php'; + + try + { + ezcPersistentStateTransformer::rowToStateArray( array(), $def ); + $this->fail( 'Exception not thrown on state transformation without proper reverse-lookup.' ); + } + catch ( ezcPersistentObjectException $e ) {} + } } ?> -- svn-components mailing list svn-components@lists.ez.no http://lists.ez.no/mailman/listinfo/svn-components