MediaWiki REL1_28
Go to the documentation of this file.
30 protected $doWork;
32 protected $doCachedWork;
34 protected $fallback;
36 protected $error;
52 public function __construct( $type, $key, array $callbacks ) {
53 parent::__construct( $type, $key );
54 foreach ( [ 'doWork', 'doCachedWork', 'fallback', 'error' ] as $name ) {
55 if ( isset( $callbacks[$name] ) ) {
56 if ( !is_callable( $callbacks[$name] ) ) {
57 throw new MWException( "Invalid callback provided for '$name' function." );
58 }
59 $this->$name = $callbacks[$name];
60 }
61 }
62 if ( !isset( $this->doWork ) ) {
63 throw new MWException( "No callback provided for 'doWork' function." );
64 }
65 $this->cacheable = isset( $this->doCachedWork );
66 }
68 public function doWork() {
69 return call_user_func_array( $this->doWork, [] );
70 }
72 public function getCachedWork() {
73 if ( $this->doCachedWork ) {
74 return call_user_func_array( $this->doCachedWork, [] );
75 }
76 return false;
77 }
79 public function fallback() {
80 if ( $this->fallback ) {
81 return call_user_func_array( $this->fallback, [] );
82 }
83 return false;
84 }
86 public function error( $status ) {
87 if ( $this->error ) {
88 return call_user_func_array( $this->error, [ $status ] );
89 }
90 return false;
91 }
MediaWiki exception.
Convenience class for dealing with PoolCounters using callbacks.
__construct( $type, $key, array $callbacks)
Build a PoolCounterWork class from a type, key, and callback map.
error( $status)
Do something with the error, like showing it to the user.
Retrieve the work from cache.
Actually perform the work, caching it if needed.
Class for dealing with PoolCounters using class members.
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
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist 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
the array() calling protocol came about after MediaWiki 1.4rc1.
Allows to change the fields on the form that will be generated $name
Definition hooks.txt:304
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:37