7use UtfNormal\Validator;
76 if ( !is_string( $pageName ) ) {
77 throw new \MWException(
'$pageName must be a string' );
85 $pageName = Validator::cleanUp( $pageName );
92 'converttitles' =>
true,
94 'titles' => $pageName,
106 $ret = $this->
http->get( $url, [], __METHOD__ );
108 if (
$ret ===
false ) {
109 wfDebugLog(
"MediaWikiSite",
"call to external site failed: $url" );
115 if ( !is_array( $data ) ) {
116 wfDebugLog(
"MediaWikiSite",
"call to <$url> returned bad json: " .
$ret );
120 $page = static::extractPageRecord( $data, $pageName );
122 if ( isset( $page[
'missing'] ) ) {
123 wfDebugLog(
"MediaWikiSite",
"call to <$url> returned a marker for a missing page title! "
128 if ( isset( $page[
'invalid'] ) ) {
129 wfDebugLog(
"MediaWikiSite",
"call to <$url> returned a marker for an invalid page title! "
134 if ( !isset( $page[
'title'] ) ) {
135 wfDebugLog(
"MediaWikiSite",
"call to <$url> did not return a page title! " .
$ret );
139 return $page[
'title'];
154 if ( isset( $externalData[
'query'][
'pages'] ) ) {
155 $pages = array_values( $externalData[
'query'][
'pages'] );
156 if ( count( $pages ) === 1 ) {
163 if ( !is_array( $externalData ) || !isset( $externalData[
'query'] ) ) {
168 'normalized' =>
'from',
169 'converted' =>
'from',
170 'redirects' =>
'from',
173 foreach ( $structs
as $listId => $fieldId ) {
175 if ( !isset( $externalData[
'query'][$listId] ) ) {
179 $collectedHits = array_filter(
180 array_values( $externalData[
'query'][$listId] ),
181 function ( $a )
use ( $fieldId, $pageTitle ) {
182 return $a[$fieldId] === $pageTitle;
187 if ( $fieldId ===
'from' && is_array( $collectedHits ) ) {
188 switch ( count( $collectedHits ) ) {
192 $pageTitle = $collectedHits[0][
'to'];
197 } elseif ( $fieldId ===
'title' && is_array( $collectedHits ) ) {
200 switch ( count( $collectedHits ) ) {
204 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
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