$processor = new ApiMain( RequestContext::getMain(), $wgEnableWriteAPI );
// Last chance hook before executing the API
- wfRunHooks( 'ApiBeforeMain', array( &$processor ) );
+ Hooks::run( 'ApiBeforeMain', array( &$processor ) );
if ( !$processor instanceof ApiMain ) {
throw new MWException( 'ApiBeforeMain hook set $processor to a non-ApiMain class' );
}
// Run hook for extension authorization plugins
/** @var $result array */
$result = null;
- if ( !wfRunHooks( 'ImgAuthBeforeStream', array( &$title, &$path, &$name, &$result ) ) ) {
+ if ( !Hooks::run( 'ImgAuthBeforeStream', array( &$title, &$path, &$name, &$result ) ) ) {
wfForbidden( $result[0], $result[1], array_slice( $result, 2 ) );
return;
}
/**
* Get the page's content model id, see the CONTENT_MODEL_XXX constants.
*
- * @throws MWException
* @param int $flags A bit field; may be Title::GAID_FOR_UPDATE to select for update
* @return string Content model id
*/
$this->mContentModel = ContentHandler::getDefaultModelFor( $this );
}
- if ( !$this->mContentModel ) {
- throw new MWException( 'Failed to determine content model!' );
- }
-
return $this->mContentModel;
}
$formatter = $this->getFeedObject( $feedFormat, $specialClass );
- // Everything is passed implicitly via $wgRequest… :(
- // The row-getting functionality should maybe be factored out of ChangesListSpecialPage too…
+ // Parameters are passed via the request in the context… :(
+ $context = new DerivativeContext( $this );
+ $context->setRequest( new DerivativeRequest(
+ $this->getRequest(),
+ $this->params,
+ $this->getRequest()->wasPosted()
+ ) );
+
+ // The row-getting functionality should be factored out of ChangesListSpecialPage too…
$rc = new $specialClass();
+ $rc->setContext( $context );
$rows = $rc->getRows();
$feedItems = $rows ? ChangesFeed::buildItems( $rows ) : array();
* @return Status
* @since 1.25
*/
- public static function addTagsAccompanyingChangeWithChecks( array $tags,
- $rc_id, $rev_id, $log_id, $params, User $user ) {
+ public static function addTagsAccompanyingChangeWithChecks(
+ array $tags, $rc_id, $rev_id, $log_id, $params, User $user
+ ) {
// are we allowed to do this?
$result = self::canAddTagsAccompanyingChange( $tags, $user );
}
// do it!
- self::addTags( $tagsToAdd, $rc_id, $rev_id, $log_id, $params );
+ self::addTags( $tags, $rc_id, $rev_id, $log_id, $params );
return Status::newGood( true );
}
// hook: get difference engine
$differenceEngine = null;
- if ( !wfRunHooks( 'GetDifferenceEngine',
+ if ( !Hooks::run( 'GetDifferenceEngine',
array( $context, $old, $new, $refreshCache, $unhide, &$differenceEngine )
) ) {
return $differenceEngine;
*/
class JobQueueDB extends JobQueue {
const CACHE_TTL_SHORT = 30; // integer; seconds to cache info without re-validating
- const CACHE_TTL_LONG = 300; // integer; seconds to cache info that is kept up to date
const MAX_AGE_PRUNE = 604800; // integer; seconds a job can live once claimed
const MAX_JOB_RANDOM = 2147483647; // integer; 2^31 - 1, used for job_random
const MAX_OFFSET = 255; // integer; maximum number of rows to skip
* @return bool
*/
protected function doIsEmpty() {
- $key = $this->getCacheKey( 'empty' );
-
- $isEmpty = $this->cache->get( $key );
- if ( $isEmpty === 'true' ) {
- return true;
- } elseif ( $isEmpty === 'false' ) {
- return false;
- }
-
$dbr = $this->getSlaveDB();
try {
$found = $dbr->selectField( // unclaimed job
} catch ( DBError $e ) {
$this->throwDBException( $e );
}
- $this->cache->add( $key, $found ? 'false' : 'true', self::CACHE_TTL_LONG );
return !$found;
}
$dbw->commit( $method );
}
- $this->cache->set( $this->getCacheKey( 'empty' ), 'false', JobQueueDB::CACHE_TTL_LONG );
-
return;
}
* @return Job|bool
*/
protected function doPop() {
- if ( $this->cache->get( $this->getCacheKey( 'empty' ) ) === 'true' ) {
- return false; // queue is empty
- }
-
$dbw = $this->getMasterDB();
try {
$dbw->commit( __METHOD__, 'flush' ); // flush existing transaction
}
// Check if we found a row to reserve...
if ( !$row ) {
- $this->cache->set( $this->getCacheKey( 'empty' ), 'true', self::CACHE_TTL_LONG );
break; // nothing to do
}
JobQueue::incrStats( 'job-pop', $this->type );
* @return void
*/
protected function doFlushCaches() {
- foreach ( array( 'empty', 'size', 'acquiredcount' ) as $type ) {
+ foreach ( array( 'size', 'acquiredcount' ) as $type ) {
$this->cache->delete( $this->getCacheKey( $type ) );
}
}
$affected = $dbw->affectedRows();
$count += $affected;
JobQueue::incrStats( 'job-recycle', $this->type, $affected );
- // The tasks recycled jobs or release delayed jobs into the queue
- $this->cache->set( $this->getCacheKey( 'empty' ), 'false', self::CACHE_TTL_LONG );
$this->aggr->notifyQueueNonEmpty( $this->wiki, $this->type );
}
}
/**
* @param array $keys
* @param string $prefix
- * @return string
+ * @return string[]
*/
protected static function prefixCacheKeys( array $keys, $prefix ) {
$res = array();
private function benchHooks( $trials = 10 ) {
$start = microtime( true );
for ( $i = 0; $i < $trials; $i++ ) {
- wfRunHooks( 'Test' );
+ Hooks::run( 'Test' );
}
$delta = microtime( true ) - $start;
$pertrial = $delta / $trials;
$blacklist = $checkBlacklist;
- wfRunHooks( 'LocalisationChecksBlacklist', array( &$blacklist ) );
+ Hooks::run( 'LocalisationChecksBlacklist', array( &$blacklist ) );
return $blacklist;
}
* files in the languages directory.
*/
function __construct() {
- wfRunHooks( 'LocalisationIgnoredOptionalMessages',
+ Hooks::run( 'LocalisationIgnoredOptionalMessages',
array( &$this->mIgnoredMessages, &$this->mOptionalMessages ) );
$this->mLanguages = array_keys( Language::fetchLanguageNames( null, 'mwfile' ) );
}
// Give extensions a chance to optimize settings
- wfRunHooks( 'MaintenanceRefreshLinksInit', array( $this ) );
+ Hooks::run( 'MaintenanceRefreshLinksInit', array( $this ) );
# Don't generate extension images (e.g. Timeline)
$wgParser->clearTagHooks();
// Allow hooks to override the suggestion URL settings in a more
// general way than overriding the whole search engine...
-wfRunHooks( 'OpenSearchUrls', array( &$urls ) );
+Hooks::run( 'OpenSearchUrls', array( &$urls ) );
foreach ( $urls as $attribs ) {
print Xml::element( 'Url', $attribs );
unset( $params['thumbName'] );
// Do the hook first for older extensions that rely on it.
- if ( !wfRunHooks( 'ExtractThumbParameters', array( $thumbname, &$params ) ) ) {
+ if ( !Hooks::run( 'ExtractThumbParameters', array( $thumbname, &$params ) ) ) {
// Check hooks if parameters can be extracted
// Hooks return false if they manage to *resolve* the parameters
// This hook should be considered deprecated