Merge "Http::getProxy() method to get proxy configuration"
[lhc/web/wiklou.git] / includes / deferred / AtomicSectionUpdate.php
1 <?php
2
3 /**
4 * Deferrable Update for closure/callback updates via IDatabase::doAtomicSection()
5 * @since 1.27
6 */
7 class AtomicSectionUpdate implements DeferrableUpdate {
8 /** @var IDatabase */
9 private $dbw;
10 /** @var string */
11 private $fname;
12 /** @var Closure|callable */
13 private $callback;
14
15 /**
16 * @param IDatabase $dbw
17 * @param string $fname Caller name (usually __METHOD__)
18 * @param callable $callback
19 * @throws InvalidArgumentException
20 * @see IDatabase::doAtomicSection()
21 */
22 public function __construct( IDatabase $dbw, $fname, $callback ) {
23 $this->dbw = $dbw;
24 $this->fname = $fname;
25 if ( !is_callable( $callback ) ) {
26 throw new InvalidArgumentException( 'Not a valid callback/closure!' );
27 }
28 $this->callback = $callback;
29 }
30
31 public function doUpdate() {
32 $this->dbw->doAtomicSection( $this->fname, $this->callback );
33 }
34 }