MediaWiki  1.33.0
Go to the documentation of this file.
1 <?php
11  private $dbw;
13  private $fname;
15  private $callback;
24  public function __construct( IDatabase $dbw, $fname, callable $callback, array $conns = [] ) {
25  $this->dbw = $dbw;
26  $this->fname = $fname;
27  $this->callback = $callback;
28  // Register DB connections for which uncommitted changes are related to this update
29  $conns[] = $dbw;
30  foreach ( $conns as $conn ) {
31  if ( $conn->trxLevel() ) {
32  $conn->onTransactionResolution( [ $this, 'cancelOnRollback' ], $fname );
33  }
34  }
35  }
37  public function doUpdate() {
38  if ( $this->callback ) {
39  $this->dbw->doAtomicSection( $this->fname, $this->callback );
40  }
41  }
47  public function cancelOnRollback( $trigger ) {
48  if ( $trigger === IDatabase::TRIGGER_ROLLBACK ) {
49  $this->callback = null;
50  }
51  }
53  public function getOrigin() {
54  return $this->fname;
55  }
56 }
Callback wrapper that has an originating method.
Definition: DeferrableCallback.php:8
__construct(IDatabase $dbw, $fname, callable $callback, array $conns=[])
Definition: AtomicSectionUpdate.php:24
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
Basic database interface for live and lazy-loaded relation database handles.
Definition: IDatabase.php:38
cancelOnRollback( $trigger)
Definition: AtomicSectionUpdate.php:47
Perform the actual work.
Definition: AtomicSectionUpdate.php:37
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
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("", 2))
Deferrable Update for closure/callback updates via IDatabase::doAtomicSection()
Definition: AtomicSectionUpdate.php:9
Definition: AtomicSectionUpdate.php:53
string $fname
Definition: AtomicSectionUpdate.php:13
IDatabase $dbw
Definition: AtomicSectionUpdate.php:11
callable null $callback
Definition: AtomicSectionUpdate.php:15
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
Interface that deferrable updates should implement.
Definition: DeferrableUpdate.php:9
onTransactionResolution(callable $callback, $fname=__METHOD__)
Run a callback as soon as the current transaction commits or rolls back.