Make doAtomicSection() return the callback result
authorAaron Schulz <aschulz@wikimedia.org>
Wed, 17 Aug 2016 22:43:48 +0000 (15:43 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Wed, 17 Aug 2016 22:43:48 +0000 (15:43 -0700)
This makes the method a bit more convenient

Change-Id: Ic140e200cddcdf8e1a09b65c94d2da3aed62756d

includes/db/Database.php
includes/db/IDatabase.php

index 78975ff..2041aca 100644 (file)
@@ -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__ ) {
index af024b8..a871082 100644 (file)
@@ -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