From 3e68b2085df9865e939b7b671b8486ddebba0c46 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 17 Aug 2016 15:43:48 -0700 Subject: [PATCH] Make doAtomicSection() return the callback result This makes the method a bit more convenient Change-Id: Ic140e200cddcdf8e1a09b65c94d2da3aed62756d --- includes/db/Database.php | 4 +++- includes/db/IDatabase.php | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) 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 -- 2.20.1