MediaWiki  1.29.1
AtomicSectionUpdate.php
Go to the documentation of this file.
1 <?php
2 
4 
11  private $dbw;
13  private $fname;
15  private $callback;
16 
23  public function __construct( IDatabase $dbw, $fname, callable $callback ) {
24  $this->dbw = $dbw;
25  $this->fname = $fname;
26  $this->callback = $callback;
27 
28  if ( $this->dbw->trxLevel() ) {
29  $this->dbw->onTransactionResolution( [ $this, 'cancelOnRollback' ], $fname );
30  }
31  }
32 
33  public function doUpdate() {
34  if ( $this->callback ) {
35  $this->dbw->doAtomicSection( $this->fname, $this->callback );
36  }
37  }
38 
39  public function cancelOnRollback( $trigger ) {
40  if ( $trigger === IDatabase::TRIGGER_ROLLBACK ) {
41  $this->callback = null;
42  }
43  }
44 
45  public function getOrigin() {
46  return $this->fname;
47  }
48 }
use
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:10
AtomicSectionUpdate\__construct
__construct(IDatabase $dbw, $fname, callable $callback)
Definition: AtomicSectionUpdate.php:23
DeferrableCallback
Callback wrapper that has an originating method.
Definition: DeferrableCallback.php:8
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
Wikimedia\Rdbms\IDatabase
Basic database interface for live and lazy-loaded relation database handles.
Definition: IDatabase.php:40
AtomicSectionUpdate\cancelOnRollback
cancelOnRollback( $trigger)
Definition: AtomicSectionUpdate.php:39
AtomicSectionUpdate\doUpdate
doUpdate()
Perform the actual work.
Definition: AtomicSectionUpdate.php:33
AtomicSectionUpdate
Deferrable Update for closure/callback updates via IDatabase::doAtomicSection()
Definition: AtomicSectionUpdate.php:9
AtomicSectionUpdate\getOrigin
getOrigin()
Definition: AtomicSectionUpdate.php:45
AtomicSectionUpdate\$fname
string $fname
Definition: AtomicSectionUpdate.php:13
AtomicSectionUpdate\$dbw
IDatabase $dbw
Definition: AtomicSectionUpdate.php:11
AtomicSectionUpdate\$callback
callable null $callback
Definition: AtomicSectionUpdate.php:15
DeferrableUpdate
Interface that deferrable updates should implement.
Definition: DeferrableUpdate.php:9