Go to the documentation of this file.
24 'sysop' => static::getTestSysop(),
25 'uploader' => static::getTestUser(),
29 'wgAuth' =>
new MediaWiki\Auth\AuthManagerAuthPlugin,
31 'wgUser' => self::$users[
'sysop']->getUser(),
52 protected function editPage( $pageName, $text, $summary =
'', $defaultNs =
NS_MAIN ) {
70 if ( is_int(
$rev ) ) {
77 'comment' => $comment,
101 $appendModule =
false,
User $user =
null, $tokenType =
null
105 if ( is_null( $session ) ) {
110 $sessionObj = SessionManager::singleton()->getEmptySession();
112 if ( $session !==
null ) {
113 foreach ( $session
as $key =>
$value ) {
114 $sessionObj->set( $key,
$value );
123 if ( $tokenType !==
null ) {
124 if ( $tokenType ===
'auto' ) {
125 $tokenType = (
new ApiMain() )->getModuleManager()
126 ->getModule(
$params[
'action'],
'action' )->needsToken();
148 $module->getResult()->getResultData(
null, [
'Strip' =>
'all' ] ),
150 $context->getRequest()->getSessionArray()
153 if ( $appendModule ) {
154 $results[] = $module;
186 protected function doLogin( $testUser =
null ) {
189 if ( $testUser ===
null ) {
190 $testUser = static::getTestSysop();
191 } elseif ( is_string( $testUser ) && array_key_exists( $testUser, self::$users ) ) {
192 $testUser = self::$users[$testUser];
193 } elseif ( !$testUser instanceof
TestUser ) {
194 throw new MWException(
"Can't log in to undefined user $testUser" );
197 $wgUser = $testUser->getUser();
203 'action' =>
'tokens',
204 'type' =>
'edit|delete|protect|move|block|unblock|watch'
205 ], $session,
false,
$user->getUser() );
207 if ( !array_key_exists(
'tokens', $data[0] ) ) {
208 throw new MWException(
'Api failed to return a token list' );
211 return $data[0][
'tokens'];
215 if ( self::$errorFormatter ===
null ) {
226 return (
bool)array_filter(
227 self::getErrorFormatter()->arrayFromStatus( $ex->
getStatusValue() ),
229 return is_array(
$e ) &&
$e[
'code'] ===
$code;
239 $constraint = PHPUnit_Framework_Assert::logicalOr(
243 $this->assertThat( $groups, $constraint,
244 'ApiTestCase::setUp can be slow, tests must be "medium" or "large"'
getStatusValue()
Fetch the error status.
This is the main API class, used for both external and internal processing.
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
WebRequest clone which takes values from a provided array.
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Exception used to abort API execution with an error.
static newFromId( $id, $flags=0)
Load a page revision from a given revision ID number.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
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
testApiTestGroup()
@coversNothing
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
Wraps the user object, so we can also retain full access to properties like password if we log in via...
getTokenList(TestUser $user, $session=null)
doApiRequest(array $params, array $session=null, $appendModule=false, User $user=null, $tokenType=null)
Does the API request and returns the result.
namespace and then decline to actually register it file or subcat img or subcat $title
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
wfScript( $script='index')
Get the path to a specified script file, respecting file extensions; this is a wrapper around $wgScri...
This class represents the result of the API operations.
static getTokenTypeSalts()
Get the salts for known token types.
doApiRequestWithToken(array $params, array $session=null, User $user=null, $tokenType='auto')
Convenience function to access the token parameter of doApiRequest() more succinctly.
when a variable name is used in a it is silently declared as a new masking the global
static createList( $typeName, IContextSource $context, Title $title, array $ids)
Instantiate the appropriate list class for a given list of IDs.
static makeContent( $text, Title $title=null, $modelId=null, $format=null)
Convenience function for creating a Content object from a given textual representation.
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
editPage( $pageName, $text, $summary='', $defaultNs=NS_MAIN)
Edits or creates a page/revision.
$wgServer
URL of the server.
static getMain()
Get the RequestContext object associated with the main request.
ApiTestContext $apiContext
static getToken(User $user, MediaWiki\Session\Session $session, $salt)
Get a token from a salt.
static apiExceptionHasCode(ApiUsageException $ex, $code)
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable & $code
revisionDelete( $rev, array $value=[Revision::DELETED_TEXT=> 1], $comment='')
Revision-deletes a revision.
static getErrorFormatter()
doLogin( $testUser=null)
Previously this would do API requests to log in, as well as setting $wgUser and the request context's...
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc $rev
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
static factory( $code)
Get a cached or new language object for a given language code.
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
if(! $wgDBerrorLogTZ) $wgRequest
c Accompany it with the information you received as to the offer to distribute corresponding source complete source code means all the source code for all modules it contains
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
the array() calling protocol came about after MediaWiki 1.4rc1.