From: Aaron Schulz Date: Wed, 17 Aug 2016 22:43:48 +0000 (-0700) Subject: Make doAtomicSection() return the callback result X-Git-Tag: 1.31.0-rc.0~6013^2 X-Git-Url: http://git.cyclocoop.org/%40spipnet%40?a=commitdiff_plain;h=3e68b2085df9865e939b7b671b8486ddebba0c46;p=lhc%2Fweb%2Fwiklou.git Make doAtomicSection() return the callback result This makes the method a bit more convenient Change-Id: Ic140e200cddcdf8e1a09b65c94d2da3aed62756d --- diff --git a/includes/db/Database.php b/includes/db/Database.php index 78975fff17..2041aca9bb 100644 --- a/includes/db/Database.php +++ b/includes/db/Database.php @@ -2658,12 +2658,14 @@ abstract class DatabaseBase implements IDatabase { final public function doAtomicSection( $fname, callable $callback ) { $this->startAtomic( $fname ); try { - call_user_func_array( $callback, [ $this, $fname ] ); + $res = call_user_func_array( $callback, [ $this, $fname ] ); } catch ( Exception $e ) { $this->rollback( $fname ); throw $e; } $this->endAtomic( $fname ); + + return $res; } final public function begin( $fname = __METHOD__ ) { diff --git a/includes/db/IDatabase.php b/includes/db/IDatabase.php index af024b8517..a871082c5a 100644 --- a/includes/db/IDatabase.php +++ b/includes/db/IDatabase.php @@ -1342,6 +1342,7 @@ interface IDatabase { * * @param string $fname Caller name (usually __METHOD__) * @param callable $callback Callback that issues DB updates + * @return mixed $res Result of the callback (since 1.28) * @throws DBError * @throws RuntimeException * @throws UnexpectedValueException