MediaWiki  1.29.1
Go to the documentation of this file.
1 <?php
13  protected $lockTypeMap = [
14  self::LOCK_SH => self::LOCK_SH,
15  self::LOCK_UW => self::LOCK_SH,
16  self::LOCK_EX => self::LOCK_EX
17  ];
19  protected function doGetLocksOnServer( $lockSrv, array $paths, $type ) {
21  if ( !count( $paths ) ) {
22  return $status; // nothing to lock
23  }
25  $db = $this->getConnection( $lockSrv ); // checked in isServerUp()
26  $bigints = array_unique( array_map(
27  function ( $key ) {
28  return Wikimedia\base_convert( substr( $key, 0, 15 ), 16, 10 );
29  },
30  array_map( [ $this, 'sha1Base16Absolute' ], $paths )
31  ) );
33  // Try to acquire all the locks...
34  $fields = [];
35  foreach ( $bigints as $bigint ) {
36  $fields[] = ( $type == self::LOCK_SH )
37  ? "pg_try_advisory_lock_shared({$db->addQuotes( $bigint )}) AS K$bigint"
38  : "pg_try_advisory_lock({$db->addQuotes( $bigint )}) AS K$bigint";
39  }
40  $res = $db->query( 'SELECT ' . implode( ', ', $fields ), __METHOD__ );
41  $row = $res->fetchRow();
43  if ( in_array( 'f', $row ) ) {
44  // Release any acquired locks if some could not be acquired...
45  $fields = [];
46  foreach ( $row as $kbigint => $ok ) {
47  if ( $ok === 't' ) { // locked
48  $bigint = substr( $kbigint, 1 ); // strip off the "K"
49  $fields[] = ( $type == self::LOCK_SH )
50  ? "pg_advisory_unlock_shared({$db->addQuotes( $bigint )})"
51  : "pg_advisory_unlock({$db->addQuotes( $bigint )})";
52  }
53  }
54  if ( count( $fields ) ) {
55  $db->query( 'SELECT ' . implode( ', ', $fields ), __METHOD__ );
56  }
57  foreach ( $paths as $path ) {
58  $status->fatal( 'lockmanager-fail-acquirelock', $path );
59  }
60  }
62  return $status;
63  }
69  protected function releaseAllLocks() {
72  foreach ( $this->conns as $lockDb => $db ) {
73  try {
74  $db->query( "SELECT pg_advisory_unlock_all()", __METHOD__ );
75  } catch ( DBError $e ) {
76  $status->fatal( 'lockmanager-fail-db-release', $lockDb );
77  }
78  }
80  return $status;
81  }
82 }
const LOCK_SH
Lock types; stronger locks have higher values.
Definition: LockManager.php:68
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set $status
Definition: hooks.txt:1049
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
Definition: database.txt:21
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string mapping parameter names to values & $type
Definition: hooks.txt:2536
Database error base class.
Definition: DBError.php:30
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
array $lockTypeMap
Mapping of lock types to the type actually used.
Definition: PostgreSqlLockManager.php:13
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
Definition: hooks.txt:2122
static newGood( $value=null)
Factory function for good results.
Definition: StatusValue.php:76
doGetLocksOnServer( $lockSrv, array $paths, $type)
Definition: PostgreSqlLockManager.php:19
Definition: NoLocalSettings.php:26
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
getConnection( $lockDb)
Get (or reuse) a connection to a lock DB.
Definition: DBLockManager.php:147
Version of LockManager based on using named/row DB locks.
Definition: DBLockManager.php:42
Definition: PostgreSqlLockManager.php:69
const LOCK_EX
Definition: LockManager.php:70
the array() calling protocol came about after MediaWiki 1.4rc1.
PostgreSQL version of DBLockManager that supports shared locks.
Definition: PostgreSqlLockManager.php:11