37 $this->
dieUsage(
'The diff cannot be retrieved, ' .
38 'one revision does not exist or you do not have permission to view it.',
'baddiff' );
41 $contentHandler = $revision->getContentHandler();
42 $de = $contentHandler->createDifferenceEngine( $this->
getContext(),
50 if ( isset(
$params[
'fromtitle'] ) ) {
51 $vals[
'fromtitle'] =
$params[
'fromtitle'];
53 if ( isset(
$params[
'fromid'] ) ) {
54 $vals[
'fromid'] =
$params[
'fromid'];
56 $vals[
'fromrevid'] = $rev1;
57 if ( isset(
$params[
'totitle'] ) ) {
58 $vals[
'totitle'] =
$params[
'totitle'];
60 if ( isset(
$params[
'toid'] ) ) {
61 $vals[
'toid'] =
$params[
'toid'];
63 $vals[
'torevid'] = $rev2;
65 $difftext = $de->getDiffBody();
67 if ( $difftext ===
false ) {
69 'The diff cannot be retrieved. Maybe one or both revisions do ' .
70 'not exist or you do not have permission to view them.',
89 } elseif ( $titleText ) {
90 $title = Title::newFromText( $titleText );
92 $this->
dieUsageMsg( [
'invalidtitle', $titleText ] );
95 return $title->getLatestRevID();
96 } elseif ( $titleId ) {
97 $title = Title::newFromID( $titleId );
102 return $title->getLatestRevID();
105 'A title, a page ID, or a revision number is needed for both the from and the to parameters',
131 'action=compare&fromrev=1&torev=2'
132 =>
'apihelp-compare-example-1',
This abstract class implements many basic API functions, and is the base of all API classes.
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below.
extractRequestParams( $parseLimit=true)
Using getAllowedParams(), this function makes an array of the values provided by the user,...
dieUsageMsg( $error)
Output the error message related to a certain array.
getResult()
Get the result object.
getModuleName()
Get the name of the module being executed by this instance.
dieUsage( $description, $errorCode, $httpRespCode=0, $extradata=null)
Throw a UsageException, which will (if uncaught) call the main module's error handler and die with an...
getExamplesMessages()
Returns usage examples for this module.
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
revisionOrTitleOrId( $revision, $titleText, $titleId)
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
static setContentValue(array &$arr, $name, $value, $flags=0)
Add an output value to the array by name and mark as META_CONTENT.
getContext()
Get the base IContextSource object.
static newFromId( $id, $flags=0)
Load a page revision from a given revision ID number.
namespace and then decline to actually register it file or subcat img or subcat $title
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