7use UtfNormal\Validator;
74 if ( !is_string( $pageName ) ) {
75 throw new \MWException(
'$pageName must be a string' );
83 $pageName = Validator::cleanUp( $pageName );
90 'converttitles' =>
true,
92 'titles' => $pageName,
104 $ret = $this->
http->get( $url, [], __METHOD__ );
106 if (
$ret ===
false ) {
107 wfDebugLog(
"MediaWikiSite",
"call to external site failed: $url" );
113 if ( !is_array( $data ) ) {
114 wfDebugLog(
"MediaWikiSite",
"call to <$url> returned bad json: " .
$ret );
118 $page = static::extractPageRecord( $data, $pageName );
120 if ( isset(
$page[
'missing'] ) ) {
121 wfDebugLog(
"MediaWikiSite",
"call to <$url> returned a marker for a missing page title! "
126 if ( isset(
$page[
'invalid'] ) ) {
127 wfDebugLog(
"MediaWikiSite",
"call to <$url> returned a marker for an invalid page title! "
132 if ( !isset(
$page[
'title'] ) ) {
133 wfDebugLog(
"MediaWikiSite",
"call to <$url> did not return a page title! " .
$ret );
137 return $page[
'title'];
152 if ( isset( $externalData[
'query'][
'pages'] ) ) {
153 $pages = array_values( $externalData[
'query'][
'pages'] );
154 if ( count( $pages ) === 1 ) {
161 if ( !is_array( $externalData ) || !isset( $externalData[
'query'] ) ) {
166 'normalized' =>
'from',
167 'converted' =>
'from',
168 'redirects' =>
'from',
171 foreach ( $structs
as $listId => $fieldId ) {
173 if ( !isset( $externalData[
'query'][$listId] ) ) {
177 $collectedHits = array_filter(
178 array_values( $externalData[
'query'][$listId] ),
179 function ( $a )
use ( $fieldId, $pageTitle ) {
180 return $a[$fieldId] === $pageTitle;
185 if ( $fieldId ===
'from' && is_array( $collectedHits ) ) {
186 switch ( count( $collectedHits ) ) {
190 $pageTitle = $collectedHits[0][
'to'];
195 } elseif ( $fieldId ===
'title' && is_array( $collectedHits ) ) {
198 switch ( count( $collectedHits ) ) {
202 return array_shift( $collectedHits );
Apache License January http
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
wfAppendQuery( $url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
Various HTTP related functions.
Service for normalizing a page name using a MediaWiki api.
static extractPageRecord( $externalData, $pageTitle)
Get normalization record for a given page title from an API response.
__construct(Http $http=null)
normalizePageName( $pageName, $apiUrl)
Returns the normalized form of the given page title, using the normalization rules of the given site.
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
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
namespace are movable Hooks may change this value to override the return value of MWNamespace::isMovable(). 'NewDifferenceEngine' do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached $page
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