MediaWiki  1.23.15
DeferredUpdates.php
Go to the documentation of this file.
1 <?php
29 interface DeferrableUpdate {
33  function doUpdate();
34 }
35 
45  private static $updates = array();
46 
51  public static function addUpdate( DeferrableUpdate $update ) {
52  array_push( self::$updates, $update );
53  }
54 
62  public static function addHTMLCacheUpdate( $title, $table ) {
63  self::addUpdate( new HTMLCacheUpdate( $title, $table ) );
64  }
65 
72  public static function addCallableUpdate( $callable ) {
73  self::addUpdate( new MWCallableUpdate( $callable ) );
74  }
75 
82  public static function doUpdates( $commit = '' ) {
84 
85  wfProfileIn( __METHOD__ );
86 
87  $updates = array_merge( $wgDeferredUpdateList, self::$updates );
88 
89  // No need to get master connections in case of empty updates array
90  if ( !count( $updates ) ) {
91  wfProfileOut( __METHOD__ );
92 
93  return;
94  }
95 
96  $dbw = false;
97  $doCommit = $commit == 'commit';
98  if ( $doCommit ) {
99  $dbw = wfGetDB( DB_MASTER );
100  }
101 
103  foreach ( $updates as $update ) {
104  try {
105  $update->doUpdate();
106 
107  if ( $doCommit && $dbw->trxLevel() ) {
108  $dbw->commit( __METHOD__, 'flush' );
109  }
110  } catch ( MWException $e ) {
111  // We don't want exceptions thrown during deferred updates to
112  // be reported to the user since the output is already sent.
113  // Instead we just log them.
114  if ( !$e instanceof ErrorPageError ) {
116  }
117  }
118  }
119 
121  wfProfileOut( __METHOD__ );
122  }
123 
128  public static function clearPendingUpdates() {
130  $wgDeferredUpdateList = self::$updates = array();
131  }
132 }
DB_MASTER
const DB_MASTER
Definition: Defines.php:56
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
wfGetDB
& wfGetDB( $db, $groups=array(), $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:3714
wfProfileIn
wfProfileIn( $functionname)
Begin profiling of a function.
Definition: Profiler.php:33
DeferrableUpdate\doUpdate
doUpdate()
Perform the actual work.
DeferredUpdates\addCallableUpdate
static addCallableUpdate( $callable)
Add a callable update.
Definition: DeferredUpdates.php:72
DeferredUpdates\clearPendingUpdates
static clearPendingUpdates()
Clear all pending updates without performing them.
Definition: DeferredUpdates.php:128
DeferredUpdates\doUpdates
static doUpdates( $commit='')
Do any deferred updates and clear the list.
Definition: DeferredUpdates.php:82
$wgDeferredUpdateList
$wgDeferredUpdateList
Definition: Setup.php:597
MWException
MediaWiki exception.
Definition: MWException.php:26
DeferredUpdates\$updates
static $updates
Store of updates to be deferred until the end of the request.
Definition: DeferredUpdates.php:45
DeferredUpdates
Class for managing the deferred updates.
Definition: DeferredUpdates.php:41
DeferredUpdates\addUpdate
static addUpdate(DeferrableUpdate $update)
Add an update to the deferred list.
Definition: DeferredUpdates.php:51
wfProfileOut
wfProfileOut( $functionname='missing')
Stop profiling of a function.
Definition: Profiler.php:46
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
HTMLCacheUpdate
Class to invalidate the HTML cache of all the pages linking to a given title.
Definition: HTMLCacheUpdate.php:29
$title
presenting them properly to the user as errors is done by the caller $title
Definition: hooks.txt:1324
DeferredUpdates\addHTMLCacheUpdate
static addHTMLCacheUpdate( $title, $table)
HTMLCacheUpdates are the most common deferred update people use.
Definition: DeferredUpdates.php:62
MWCallableUpdate
Deferrable Update for closure/callback.
Definition: CallableUpdate.php:6
as
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
MWExceptionHandler\logException
static logException(Exception $e)
Log an exception to the exception log (if enabled).
Definition: MWExceptionHandler.php:351
DeferrableUpdate
Interface that deferrable updates should implement.
Definition: DeferredUpdates.php:29
ErrorPageError
An error page which can definitely be safely rendered using the OutputPage.
Definition: ErrorPageError.php:27
$e
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
Definition: hooks.txt:1632