commit 3c5735a183be64c14ee4bcf814ee296be431ed41 Author: fago Date: Mon Nov 21 10:17:07 2011 +0100 patch by xjm, fago: fix exception handling diff --git a/core/modules/comment/comment.entity.inc b/core/modules/comment/comment.entity.inc index 9df0470..9bd4c59 100644 --- a/core/modules/comment/comment.entity.inc +++ b/core/modules/comment/comment.entity.inc @@ -115,6 +115,7 @@ class CommentStorageController extends EntityDatabaseStorageController { * Overrides EntityDatabaseStorageController::preSave(). * * @see comment_int_to_alphadecimal() + * @see comment_increment_alphadecimal() */ protected function preSave(EntityInterface $comment) { global $user; diff --git a/core/modules/entity/entity.class.inc b/core/modules/entity/entity.class.inc index 50ffc94..0693a64 100644 --- a/core/modules/entity/entity.class.inc +++ b/core/modules/entity/entity.class.inc @@ -77,11 +77,11 @@ interface EntityInterface { /** * Saves an entity permanently. * - * @throws EntityStorageException - * In case of failures an exception is thrown. - * * @return * Either SAVED_NEW or SAVED_UPDATED, depending on the operation performed. + * + * @throws EntityStorageException + * In case of failures an exception is thrown. */ public function save(); @@ -111,11 +111,6 @@ interface EntityInterface { } /** - * Defines an exception thrown when storage operations fail. - */ -class EntityStorageException extends Exception { } - -/** * Defines a base entity class. * * Default implementation of EntityInterface. diff --git a/core/modules/entity/entity.controller.inc b/core/modules/entity/entity.controller.inc index 2379867..af8e983 100644 --- a/core/modules/entity/entity.controller.inc +++ b/core/modules/entity/entity.controller.inc @@ -406,30 +406,37 @@ interface EntityStorageControllerInterface extends DrupalEntityControllerInterfa /** * Deletes permanently saved entities. * - * In case of failures, an exception is thrown. - * * @param $ids * An array of entity IDs. + * + * @throws EntityStorageException + * In case of failures, an exception is thrown. */ public function delete($ids); /** * Saves the entity permanently. * - * In case of failures, an exception is thrown. - * * @param EntityInterface $entity * The entity to save. * * @return * SAVED_NEW or SAVED_UPDATED is returned depending on the operation * performed. + * + * @throws EntityStorageException + * In case of failures, an exception is thrown. */ public function save(EntityInterface $entity); } /** + * Defines an exception thrown when storage operations fail. + */ +class EntityStorageException extends Exception { } + +/** * Implements the entity storage controller interface for the database. */ class EntityDatabaseStorageController extends DrupalDefaultEntityController implements EntityStorageControllerInterface { @@ -463,11 +470,9 @@ class EntityDatabaseStorageController extends DrupalDefaultEntityController impl db_ignore_slave(); } catch (Exception $e) { - if (isset($transaction)) { - $transaction->rollback(); - } + $transaction->rollback(); watchdog_exception($this->entityType, $e); - throw $e; + throw new EntityStorageException($e->getMessage, $e->getCode, $e); } } @@ -507,7 +512,7 @@ class EntityDatabaseStorageController extends DrupalDefaultEntityController impl catch (Exception $e) { $transaction->rollback(); watchdog_exception($this->entityType, $e); - throw $e; + throw new EntityStorageException($e->getMessage(), $e->getCode(), $e); } } diff --git a/core/modules/entity/tests/entity_test.module b/core/modules/entity/tests/entity_test.module index 2ce4ec7..6034b06 100644 --- a/core/modules/entity/tests/entity_test.module +++ b/core/modules/entity/tests/entity_test.module @@ -33,7 +33,7 @@ function entity_test_entity_info() { * A boolean indicating that the internal cache should be reset. * * @return Entity - * The loaded entity object, or FALSE on failure. + * The loaded entity object, or FALSE if the entity cannot be loaded. */ function entity_test_load($id, $reset = FALSE) { $result = entity_load('entity_test', array($id), array(), $reset);