| 1 |
<?php |
| 2 |
|
| 3 |
" |
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
namespace MediaWiki\Api; |
| 24 |
|
| 25 |
use MediaWiki\Cache\LinkBatchFactory; |
| 26 |
use MediaWiki\EditPage\IntroMessageBuilder; |
| 27 |
use MediaWiki\EditPage\PreloadedContentBuilder; |
| 28 |
use MediaWiki\Language\ILanguageConverter; |
| 29 |
use MediaWiki\Language\Language; |
| 30 |
use MediaWiki\Languages\LanguageConverterFactory; |
| 31 |
use MediaWiki\Linker\LinksMigration; |
| 32 |
use MediaWiki\Linker\LinkTarget; |
| 33 |
use MediaWiki\MainConfigNames; |
| 34 |
use MediaWiki\Page\PageIdentity; |
| 35 |
use MediaWiki\Page\PageReference; |
| 36 |
use MediaWiki\ParamValidator\TypeDef\TitleDef; |
| 37 |
use MediaWiki\Permissions\PermissionStatus; |
| 38 |
use MediaWiki\Permissions\RestrictionStore; |
| 39 |
use MediaWiki\Revision\RevisionLookup; |
| 40 |
use MediaWiki\Title\NamespaceInfo; |
| 41 |
use MediaWiki\Title\Title; |
| 42 |
use MediaWiki\Title\TitleFactory; |
| 43 |
use MediaWiki\Title\TitleFormatter; |
| 44 |
use MediaWiki\Title\TitleValue; |
| 45 |
use MediaWiki\User\TempUser\TempUserCreator; |
| 46 |
use MediaWiki\User\UserFactory; |
| 47 |
use MediaWiki\Utils\UrlUtils; |
| 48 |
use MediaWiki\Watchlist\WatchedItem; |
| 49 |
use MediaWiki\Watchlist\WatchedItemStore; |
| 50 |
use MessageLocalizer; |
| 51 |
use Wikimedia\ParamValidator\ParamValidator; |
| 52 |
use Wikimedia\ParamValidator\TypeDef\EnumDef; |
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
class ApiQueryInfo extends ApiQueryBase { |
| 60 |
|
| 61 |
private ILanguageConverter $languageConverter; |
| 62 |
private LinkBatchFactory $linkBatchFactory; |
| 63 |
private NamespaceInfo $namespaceInfo; |
| 64 |
private TitleFactory $titleFactory; |
| 65 |
private TitleFormatter $titleFormatter; |
| 66 |
private WatchedItemStore $watchedItemStore; |
| 67 |
private RestrictionStore $restrictionStore; |
| 68 |
private LinksMigration $linksMigration; |
| 69 |
private TempUserCreator $tempUserCreator; |
| 70 |
private UserFactory $userFactory; |
| 71 |
private IntroMessageBuilder $introMessageBuilder; |
| 72 |
private PreloadedContentBuilder $preloadedContentBuilder; |
| 73 |
private RevisionLookup $revisionLookup; |
| 74 |
private UrlUtils $urlUtils; |
| 75 |
|
| 76 |
private bool $fld_protection = false; |
| 77 |
private bool $fld_talkid = false; |
| 78 |
private bool $fld_subjectid = false; |
| 79 |
private bool $fld_url = false; |
| 80 |
private bool $fld_readable = false; |
| 81 |
private bool $fld_watched = false; |
| 82 |
private bool $fld_watchers = false; |
| 83 |
private bool $fld_visitingwatchers = false; |
| 84 |
private bool $fld_notificationtimestamp = false; |
| 85 |
private bool $fld_preload = false; |
| 86 |
private bool $fld_preloadcontent = false; |
| 87 |
private bool $fld_editintro = false; |
| 88 |
private bool $fld_displaytitle = false; |
| 89 |
private bool $fld_varianttitles = false; |
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
private $fld_linkclasses = false; |
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
private $fld_associatedpage = false; |
| 101 |
|
| 102 |
|
| 103 |
private $params; |
| 104 |
|
| 105 |
|
| 106 |
private $titles; |
| 107 |
|
| 108 |
private $missing; |
| 109 |
|
| 110 |
private $everything; |
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
private $pageIsRedir; |
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
private $pageIsNew; |
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
private $pageTouched; |
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
private $pageLatest; |
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
private $pageLength; |
| 137 |
|
| 138 |
|
| 139 |
private $protections; |
| 140 |
|
| 141 |
private $restrictionTypes; |
| 142 |
|
| 143 |
private $watched; |
| 144 |
|
| 145 |
private $watchers; |
| 146 |
|
| 147 |
private $visitingwatchers; |
| 148 |
|
| 149 |
private $notificationtimestamps; |
| 150 |
|
| 151 |
private $talkids; |
| 152 |
|
| 153 |
private $subjectids; |
| 154 |
|
| 155 |
private $displaytitles; |
| 156 |
|
| 157 |
private $variantTitles; |
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
private $watchlistExpiries; |
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
private $linkClasses; |
| 170 |
|
| 171 |
|
| 172 |
private $showZeroWatchers = false; |
| 173 |
|
| 174 |
|
| 175 |
private $countTestedActions = 0; |
| 176 |
|
| 177 |
public function __construct( |
| 178 |
ApiQuery $queryModule, |
| 179 |
string $moduleName, |
| 180 |
Language $contentLanguage, |
| 181 |
LinkBatchFactory $linkBatchFactory, |
| 182 |
NamespaceInfo $namespaceInfo, |
| 183 |
TitleFactory $titleFactory, |
| 184 |
TitleFormatter $titleFormatter, |
| 185 |
WatchedItemStore $watchedItemStore, |
| 186 |
LanguageConverterFactory $languageConverterFactory, |
| 187 |
RestrictionStore $restrictionStore, |
| 188 |
LinksMigration $linksMigration, |
| 189 |
TempUserCreator $tempUserCreator, |
| 190 |
UserFactory $userFactory, |
| 191 |
IntroMessageBuilder $introMessageBuilder, |
| 192 |
PreloadedContentBuilder $preloadedContentBuilder, |
| 193 |
RevisionLookup $revisionLookup, |
| 194 |
UrlUtils $urlUtils |
| 195 |
) { |
| 196 |
parent::__construct( $queryModule, $moduleName, 'in' ); |
| 197 |
$this->languageConverter = $languageConverterFactory->getLanguageConverter( $contentLanguage ); |
| 198 |
$this->linkBatchFactory = $linkBatchFactory; |
| 199 |
$this->namespaceInfo = $namespaceInfo; |
| 200 |
$this->titleFactory = $titleFactory; |
| 201 |
$this->titleFormatter = $titleFormatter; |
| 202 |
$this->watchedItemStore = $watchedItemStore; |
| 203 |
$this->restrictionStore = $restrictionStore; |
| 204 |
$this->linksMigration = $linksMigration; |
| 205 |
$this->tempUserCreator = $tempUserCreator; |
| 206 |
$this->userFactory = $userFactory; |
| 207 |
$this->introMessageBuilder = $introMessageBuilder; |
| 208 |
$this->preloadedContentBuilder = $preloadedContentBuilder; |
| 209 |
$this->revisionLookup = $revisionLookup; |
| 210 |
$this->urlUtils = $urlUtils; |
| 211 |
} |
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
public function requestExtraData( $pageSet ) { |
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
$pageSet->requestField( 'page_is_redirect' ); |
| 222 |
$pageSet->requestField( 'page_is_new' ); |
| 223 |
$config = $this->getConfig(); |
| 224 |
$pageSet->requestField( 'page_touched' ); |
| 225 |
$pageSet->requestField( 'page_latest' ); |
| 226 |
$pageSet->requestField( 'page_len' ); |
| 227 |
$pageSet->requestField( 'page_content_model' ); |
| 228 |
if ( $config->get( MainConfigNames::PageLanguageUseDB ) ) { |
| 229 |
$pageSet->requestField( 'page_lang' ); |
| 230 |
} |
| 231 |
} |
| 232 |
|
| 233 |
public function execute() { |
| 234 |
$this->params = $this->extractRequestParams(); |
| 235 |
if ( $this->params['prop'] !== null ) { |
| 236 |
$prop = array_fill_keys( $this->params['prop'], true ); |
| 237 |
$this->fld_protection = isset( $prop['protection'] ); |
| 238 |
$this->fld_watched = isset( $prop['watched'] ); |
| 239 |
$this->fld_watchers = isset( $prop['watchers'] ); |
| 240 |
$this->fld_visitingwatchers = isset( $prop['visitingwatchers'] ); |
| 241 |
$this->fld_notificationtimestamp = isset( $prop['notificationtimestamp'] ); |
| 242 |
$this->fld_talkid = isset( $prop['talkid'] ); |
| 243 |
$this->fld_subjectid = isset( $prop['subjectid'] ); |
| 244 |
$this->fld_url = isset( $prop['url'] ); |
| 245 |
$this->fld_readable = isset( $prop['readable'] ); |
| 246 |
$this->fld_preload = isset( $prop['preload'] ); |
| 247 |
$this->fld_preloadcontent = isset( $prop['preloadcontent'] ); |
| 248 |
$this->fld_editintro = isset( $prop['editintro'] ); |
| 249 |
$this->fld_displaytitle = isset( $prop['displaytitle'] ); |
| 250 |
$this->fld_varianttitles = isset( $prop['varianttitles'] ); |
| 251 |
$this->fld_linkclasses = isset( $prop['linkclasses'] ); |
| 252 |
$this->fld_associatedpage = isset( $prop['associatedpage'] ); |
| 253 |
} |
| 254 |
|
| 255 |
$pageSet = $this->getPageSet(); |
| 256 |
$this->titles = $pageSet->getGoodPages(); |
| 257 |
$this->missing = $pageSet->getMissingPages(); |
| 258 |
$this->everything = $this->titles + $this->missing; |
| 259 |
$result = $this->getResult(); |
| 260 |
|
| 261 |
if ( |
| 262 |
( $this->fld_preloadcontent || $this->fld_editintro ) && |
| 263 |
( count( $this->everything ) > 1 || count( $this->getPageSet()->getRevisionIDs() ) > 1 ) |
| 264 |
) { |
| 265 |
|
| 266 |
|
| 267 |
$this->dieWithError( |
| 268 |
[ 'apierror-info-singlepagerevision', $this->getModulePrefix() ], 'invalidparammix' |
| 269 |
); |
| 270 |
} |
| 271 |
|
| 272 |
uasort( $this->everything, [ Title::class, 'compare' ] ); |
| 273 |
if ( $this->params['continue'] !== null ) { |
| 274 |
|
| 275 |
|
| 276 |
$cont = $this->parseContinueParamOrDie( $this->params['continue'], [ 'int', 'string' ] ); |
| 277 |
$conttitle = $this->titleFactory->makeTitleSafe( $cont[0], $cont[1] ); |
| 278 |
$this->dieContinueUsageIf( !$conttitle ); |
| 279 |
foreach ( $this->everything as $pageid => $page ) { |
| 280 |
if ( Title::compare( $page, $conttitle ) >= 0 ) { |
| 281 |
break; |
| 282 |
} |
| 283 |
unset( $this->titles[$pageid] ); |
| 284 |
unset( $this->missing[$pageid] ); |
| 285 |
unset( $this->everything[$pageid] ); |
| 286 |
} |
| 287 |
} |
| 288 |
|
| 289 |
|
| 290 |
$this->pageIsRedir = !$pageSet->isResolvingRedirects() |
| 291 |
? $pageSet->getCustomField( 'page_is_redirect' ) |
| 292 |
: []; |
| 293 |
$this->pageIsNew = $pageSet->getCustomField( 'page_is_new' ); |
| 294 |
|
| 295 |
$this->pageTouched = $pageSet->getCustomField( 'page_touched' ); |
| 296 |
$this->pageLatest = $pageSet->getCustomField( 'page_latest' ); |
| 297 |
$this->pageLength = $pageSet->getCustomField( 'page_len' ); |
| 298 |
|
| 299 |
|
| 300 |
if ( $this->fld_protection ) { |
| 301 |
$this->getProtectionInfo(); |
| 302 |
} |
| 303 |
|
| 304 |
if ( $this->fld_watched || $this->fld_notificationtimestamp ) { |
| 305 |
$this->getWatchedInfo(); |
| 306 |
} |
| 307 |
|
| 308 |
if ( $this->fld_watchers ) { |
| 309 |
$this->getWatcherInfo(); |
| 310 |
} |
| 311 |
|
| 312 |
if ( $this->fld_visitingwatchers ) { |
| 313 |
$this->getVisitingWatcherInfo(); |
| 314 |
} |
| 315 |
|
| 316 |
|
| 317 |
if ( $this->fld_talkid || $this->fld_subjectid ) { |
| 318 |
$this->getTSIDs(); |
| 319 |
} |
| 320 |
|
| 321 |
if ( $this->fld_displaytitle ) { |
| 322 |
$this->getDisplayTitle(); |
| 323 |
} |
| 324 |
|
| 325 |
if ( $this->fld_varianttitles ) { |
| 326 |
$this->getVariantTitles(); |
| 327 |
} |
| 328 |
|
| 329 |
if ( $this->fld_linkclasses ) { |
| 330 |
$this->getLinkClasses( $this->params['linkcontext'] ); |
| 331 |
} |
| 332 |
|
| 333 |
|
| 334 |
foreach ( $this->everything as $pageid => $page ) { |
| 335 |
$pageInfo = $this->extractPageInfo( $pageid, $page ); |
| 336 |
$fit = $pageInfo !== null && $result->addValue( [ |
| 337 |
'query', |
| 338 |
'pages' |
| 339 |
], $pageid, $pageInfo ); |
| 340 |
if ( !$fit ) { |
| 341 |
$this->setContinueEnumParameter( 'continue', |
| 342 |
$page->getNamespace() . '|' . |
| 343 |
$this->titleFormatter->getText( $page ) ); |
| 344 |
break; |
| 345 |
} |
| 346 |
} |
| 347 |
} |
| 348 |
|
| 349 |
|
| 350 |
|
| 351 |
|
| 352 |
|
| 353 |
|
| 354 |
|
| 355 |
private function extractPageInfo( $pageid, $page ) { |
| 356 |
$title = $this->titleFactory->newFromPageIdentity( $page ); |
| 357 |
$pageInfo = []; |
| 358 |
|
| 359 |
$pageExists = $pageid > 0; |
| 360 |
$ns = $page->getNamespace(); |
| 361 |
$dbkey = $page->getDBkey(); |
| 362 |
|
| 363 |
$pageInfo['contentmodel'] = $title->getContentModel(); |
| 364 |
|
| 365 |
$pageLanguage = $title->getPageLanguage(); |
| 366 |
$pageInfo['pagelanguage'] = $pageLanguage->getCode(); |
| 367 |
$pageInfo['pagelanguagehtmlcode'] = $pageLanguage->getHtmlCode(); |
| 368 |
$pageInfo['pagelanguagedir'] = $pageLanguage->getDir(); |
| 369 |
|
| 370 |
if ( $pageExists ) { |
| 371 |
$pageInfo['touched'] = wfTimestamp( TS_ISO_8601, $this->pageTouched[$pageid] ); |
| 372 |
$pageInfo['lastrevid'] = (int)$this->pageLatest[$pageid]; |
| 373 |
$pageInfo['length'] = (int)$this->pageLength[$pageid]; |
| 374 |
|
| 375 |
if ( isset( $this->pageIsRedir[$pageid] ) && $this->pageIsRedir[$pageid] ) { |
| 376 |
$pageInfo['redirect'] = true; |
| 377 |
} |
| 378 |
if ( $this->pageIsNew[$pageid] ) { |
| 379 |
$pageInfo['new'] = true; |
| 380 |
} |
| 381 |
} |
| 382 |
|
| 383 |
if ( $this->fld_protection ) { |
| 384 |
$pageInfo['protection'] = []; |
| 385 |
if ( isset( $this->protections[$ns][$dbkey] ) ) { |
| 386 |
$pageInfo['protection'] = |
| 387 |
$this->protections[$ns][$dbkey]; |
| 388 |
} |
| 389 |
ApiResult::setIndexedTagName( $pageInfo['protection'], 'pr' ); |
| 390 |
|
| 391 |
$pageInfo['restrictiontypes'] = []; |
| 392 |
if ( isset( $this->restrictionTypes[$ns][$dbkey] ) ) { |
| 393 |
$pageInfo['restrictiontypes'] = |
| 394 |
$this->restrictionTypes[$ns][$dbkey]; |
| 395 |
} |
| 396 |
ApiResult::setIndexedTagName( $pageInfo['restrictiontypes'], 'rt' ); |
| 397 |
} |
| 398 |
|
| 399 |
if ( $this->fld_watched ) { |
| 400 |
$pageInfo['watched'] = false; |
| 401 |
|
| 402 |
if ( isset( $this->watched[$ns][$dbkey] ) ) { |
| 403 |
$pageInfo['watched'] = $this->watched[$ns][$dbkey]; |
| 404 |
} |
| 405 |
|
| 406 |
if ( isset( $this->watchlistExpiries[$ns][$dbkey] ) ) { |
| 407 |
$pageInfo['watchlistexpiry'] = $this->watchlistExpiries[$ns][$dbkey]; |
| 408 |
} |
| 409 |
} |
| 410 |
|
| 411 |
if ( $this->fld_watchers ) { |
| 412 |
if ( $this->watchers !== null && $this->watchers[$ns][$dbkey] !== 0 ) { |
| 413 |
$pageInfo['watchers'] = $this->watchers[$ns][$dbkey]; |
| 414 |
} elseif ( $this->showZeroWatchers ) { |
| 415 |
$pageInfo['watchers'] = 0; |
| 416 |
} |
| 417 |
} |
| 418 |
|
| 419 |
if ( $this->fld_visitingwatchers ) { |
| 420 |
if ( $this->visitingwatchers !== null && $this->visitingwatchers[$ns][$dbkey] !== 0 ) { |
| 421 |
$pageInfo['visitingwatchers'] = $this->visitingwatchers[$ns][$dbkey]; |
| 422 |
} elseif ( $this->showZeroWatchers ) { |
| 423 |
$pageInfo['visitingwatchers'] = 0; |
| 424 |
} |
| 425 |
} |
| 426 |
|
| 427 |
if ( $this->fld_notificationtimestamp ) { |
| 428 |
$pageInfo['notificationtimestamp'] = ''; |
| 429 |
if ( isset( $this->notificationtimestamps[$ns][$dbkey] ) ) { |
| 430 |
$pageInfo['notificationtimestamp'] = |
| 431 |
wfTimestamp( TS_ISO_8601, $this->notificationtimestamps[$ns][$dbkey] ); |
| 432 |
} |
| 433 |
} |
| 434 |
|
| 435 |
if ( $this->fld_talkid && isset( $this->talkids[$ns][$dbkey] ) ) { |
| 436 |
$pageInfo['talkid'] = $this->talkids[$ns][$dbkey]; |
| 437 |
} |
| 438 |
|
| 439 |
if ( $this->fld_subjectid && isset( $this->subjectids[$ns][$dbkey] ) ) { |
| 440 |
$pageInfo['subjectid'] = $this->subjectids[$ns][$dbkey]; |
| 441 |
} |
| 442 |
|
| 443 |
if ( $this->fld_associatedpage && $ns >= NS_MAIN ) { |
| 444 |
$pageInfo['associatedpage'] = $this->titleFormatter->getPrefixedText( |
| 445 |
$this->namespaceInfo->getAssociatedPage( TitleValue::newFromPage( $page ) ) |
| 446 |
); |
| 447 |
} |
| 448 |
|
| 449 |
if ( $this->fld_url ) { |
| 450 |
$pageInfo['fullurl'] = (string)$this->urlUtils->expand( |
| 451 |
$title->getFullURL(), PROTO_CURRENT |
| 452 |
); |
| 453 |
$pageInfo['editurl'] = (string)$this->urlUtils->expand( |
| 454 |
$title->getFullURL( 'action=edit' ), PROTO_CURRENT |
| 455 |
); |
| 456 |
$pageInfo['canonicalurl'] = (string)$this->urlUtils->expand( |
| 457 |
$title->getFullURL(), PROTO_CANONICAL |
| 458 |
); |
| 459 |
} |
| 460 |
if ( $this->fld_readable ) { |
| 461 |
$pageInfo['readable'] = $this->getAuthority()->definitelyCan( 'read', $page ); |
| 462 |
} |
| 463 |
|
| 464 |
if ( $this->fld_preload ) { |
| 465 |
if ( $pageExists ) { |
| 466 |
$pageInfo['preload'] = ''; |
| 467 |
} else { |
| 468 |
$text = ''; |
| 469 |
$this->getHookRunner()->onEditFormPreloadText( $text, $title ); |
| 470 |
|
| 471 |
$pageInfo['preload'] = $text; |
| 472 |
} |
| 473 |
} |
| 474 |
|
| 475 |
if ( $this->fld_preloadcontent ) { |
| 476 |
$newSection = $this->params['preloadnewsection']; |
| 477 |
|
| 478 |
|
| 479 |
if ( !$pageExists || $newSection ) { |
| 480 |
$content = $this->preloadedContentBuilder->getPreloadedContent( |
| 481 |
$title->toPageIdentity(), |
| 482 |
$this->getAuthority(), |
| 483 |
$this->params['preloadcustom'], |
| 484 |
$this->params['preloadparams'] ?? [], |
| 485 |
$newSection ? 'new' : null |
| 486 |
); |
| 487 |
$defaultContent = $newSection ? null : |
| 488 |
$this->preloadedContentBuilder->getDefaultContent( $title->toPageIdentity() ); |
| 489 |
$contentIsDefault = $defaultContent ? $content->equals( $defaultContent ) : $content->isEmpty(); |
| 490 |
|
| 491 |
|
| 492 |
$pageInfo['preloadcontent']['contentmodel'] = $content->getModel(); |
| 493 |
$pageInfo['preloadcontent']['contentformat'] = $content->getDefaultFormat(); |
| 494 |
ApiResult::setContentValue( $pageInfo['preloadcontent'], 'content', $content->serialize() ); |
| 495 |
|
| 496 |
|
| 497 |
|
| 498 |
$pageInfo['preloadisdefault'] = $contentIsDefault; |
| 499 |
} |
| 500 |
} |
| 501 |
|
| 502 |
if ( $this->fld_editintro ) { |
| 503 |
|
| 504 |
$localizerWithPage = new class( $this, $page ) implements MessageLocalizer { |
| 505 |
private MessageLocalizer $base; |
| 506 |
private PageReference $page; |
| 507 |
|
| 508 |
public function __construct( MessageLocalizer $base, PageReference $page ) { |
| 509 |
$this->base = $base; |
| 510 |
$this->page = $page; |
| 511 |
} |
| 512 |
|
| 513 |
|
| 514 |
|
| 515 |
|
| 516 |
public function msg( $key, ...$params ) { |
| 517 |
return $this->base->msg( $key, ...$params )->page( $this->page ); |
| 518 |
} |
| 519 |
}; |
| 520 |
|
| 521 |
$styleParamMap = [ |
| 522 |
'lessframes' => IntroMessageBuilder::LESS_FRAMES, |
| 523 |
'moreframes' => IntroMessageBuilder::MORE_FRAMES, |
| 524 |
]; |
| 525 |
|
| 526 |
$revId = array_key_first( $this->getPageSet()->getLiveRevisionIDs() ); |
| 527 |
$revRecord = $revId ? $this->revisionLookup->getRevisionById( $revId ) : null; |
| 528 |
|
| 529 |
$messages = $this->introMessageBuilder->getIntroMessages( |
| 530 |
$styleParamMap[ $this->params['editintrostyle'] ], |
| 531 |
$this->params['editintroskip'] ?? [], |
| 532 |
$localizerWithPage, |
| 533 |
$title->toPageIdentity(), |
| 534 |
$revRecord, |
| 535 |
$this->getAuthority(), |
| 536 |
$this->params['editintrocustom'], |
| 537 |
|
| 538 |
null, |
| 539 |
false |
| 540 |
); |
| 541 |
ApiResult::setIndexedTagName( $messages, 'ei' ); |
| 542 |
ApiResult::setArrayType( $messages, 'kvp', 'key' ); |
| 543 |
|
| 544 |
$pageInfo['editintro'] = $messages; |
| 545 |
} |
| 546 |
|
| 547 |
if ( $this->fld_displaytitle ) { |
| 548 |
$pageInfo['displaytitle'] = $this->displaytitles[$pageid] ?? |
| 549 |
htmlspecialchars( $this->titleFormatter->getPrefixedText( $page ), ENT_NOQUOTES ); |
| 550 |
} |
| 551 |
|
| 552 |
if ( $this->fld_varianttitles && isset( $this->variantTitles[$pageid] ) ) { |
| 553 |
$pageInfo['varianttitles'] = $this->variantTitles[$pageid]; |
| 554 |
} |
| 555 |
|
| 556 |
if ( $this->fld_linkclasses && isset( $this->linkClasses[$pageid] ) ) { |
| 557 |
$pageInfo['linkclasses'] = $this->linkClasses[$pageid]; |
| 558 |
} |
| 559 |
|
| 560 |
if ( $this->params['testactions'] ) { |
| 561 |
$limit = $this->getMain()->canApiHighLimits() ? self::LIMIT_SML2 : self::LIMIT_SML1; |
| 562 |
if ( $this->countTestedActions >= $limit ) { |
| 563 |
return null; |
| 564 |
} |
| 565 |
|
| 566 |
$detailLevel = $this->params['testactionsdetail']; |
| 567 |
$errorFormatter = $this->getErrorFormatter(); |
| 568 |
if ( $errorFormatter->getFormat() === 'bc' ) { |
| 569 |
|
| 570 |
$errorFormatter = $errorFormatter->newWithFormat( 'plaintext' ); |
| 571 |
} |
| 572 |
|
| 573 |
$pageInfo['actions'] = []; |
| 574 |
if ( $this->params['testactionsautocreate'] ) { |
| 575 |
$pageInfo['wouldautocreate'] = []; |
| 576 |
} |
| 577 |
|
| 578 |
foreach ( $this->params['testactions'] as $action ) { |
| 579 |
$this->countTestedActions++; |
| 580 |
|
| 581 |
$shouldAutoCreate = $this->tempUserCreator->shouldAutoCreate( $this->getUser(), $action ); |
| 582 |
|
| 583 |
if ( $shouldAutoCreate ) { |
| 584 |
$authority = $this->userFactory->newTempPlaceholder(); |
| 585 |
} else { |
| 586 |
$authority = $this->getAuthority(); |
| 587 |
} |
| 588 |
|
| 589 |
if ( $detailLevel === 'boolean' ) { |
| 590 |
$pageInfo['actions'][$action] = $authority->authorizeRead( $action, $page ); |
| 591 |
} else { |
| 592 |
$status = new PermissionStatus(); |
| 593 |
if ( $detailLevel === 'quick' ) { |
| 594 |
$authority->probablyCan( $action, $page, $status ); |
| 595 |
} else { |
| 596 |
$authority->definitelyCan( $action, $page, $status ); |
| 597 |
} |
| 598 |
$this->addBlockInfoToStatus( $status ); |
| 599 |
$pageInfo['actions'][$action] = $errorFormatter->arrayFromStatus( $status ); |
| 600 |
} |
| 601 |
|
| 602 |
if ( $this->params['testactionsautocreate'] ) { |
| 603 |
$pageInfo['wouldautocreate'][$action] = $shouldAutoCreate; |
| 604 |
} |
| 605 |
} |
| 606 |
} |
| 607 |
|
| 608 |
return $pageInfo; |
| 609 |
} |
| 610 |
|
| 611 |
|
| 612 |
|
| 613 |
|
| 614 |
private function getProtectionInfo() { |
| 615 |
$this->protections = []; |
| 616 |
$db = $this->getDB(); |
| 617 |
|
| 618 |
|
| 619 |
if ( count( $this->titles ) ) { |
| 620 |
$this->resetQueryParams(); |
| 621 |
$this->addTables( 'page_restrictions' ); |
| 622 |
$this->addFields( [ 'pr_page', 'pr_type', 'pr_level', |
| 623 |
'pr_expiry', 'pr_cascade' ] ); |
| 624 |
$this->addWhereFld( 'pr_page', array_keys( $this->titles ) ); |
| 625 |
|
| 626 |
$res = $this->select( __METHOD__ ); |
| 627 |
foreach ( $res as $row ) { |
| 628 |
|
| 629 |
$page = $this->titles[$row->pr_page]; |
| 630 |
$a = [ |
| 631 |
'type' => $row->pr_type, |
| 632 |
'level' => $row->pr_level, |
| 633 |
'expiry' => ApiResult::formatExpiry( $row->pr_expiry ) |
| 634 |
]; |
| 635 |
if ( $row->pr_cascade ) { |
| 636 |
$a['cascade'] = true; |
| 637 |
} |
| 638 |
$this->protections[$page->getNamespace()][$page->getDBkey()][] = $a; |
| 639 |
} |
| 640 |
} |
| 641 |
|
| 642 |
|
| 643 |
if ( count( $this->missing ) ) { |
| 644 |
$this->resetQueryParams(); |
| 645 |
$lb = $this->linkBatchFactory->newLinkBatch( $this->missing ); |
| 646 |
$this->addTables( 'protected_titles' ); |
| 647 |
$this->addFields( [ 'pt_title', 'pt_namespace', 'pt_create_perm', 'pt_expiry' ] ); |
| 648 |
$this->addWhere( $lb->constructSet( 'pt', $db ) ); |
| 649 |
$res = $this->select( __METHOD__ ); |
| 650 |
foreach ( $res as $row ) { |
| 651 |
$this->protections[$row->pt_namespace][$row->pt_title][] = [ |
| 652 |
'type' => 'create', |
| 653 |
'level' => $row->pt_create_perm, |
| 654 |
'expiry' => ApiResult::formatExpiry( $row->pt_expiry ) |
| 655 |
]; |
| 656 |
} |
| 657 |
} |
| 658 |
|
| 659 |
|
| 660 |
|
| 661 |
$images = $others = []; |
| 662 |
foreach ( $this->everything as $page ) { |
| 663 |
if ( $page->getNamespace() === NS_FILE ) { |
| 664 |
$images[] = $page->getDBkey(); |
| 665 |
} else { |
| 666 |
$others[] = $page; |
| 667 |
} |
| 668 |
|
| 669 |
$this->restrictionTypes[$page->getNamespace()][$page->getDBkey()] = |
| 670 |
array_values( $this->restrictionStore->listApplicableRestrictionTypes( $page ) ); |
| 671 |
} |
| 672 |
|
| 673 |
[ $blNamespace, $blTitle ] = $this->linksMigration->getTitleFields( 'templatelinks' ); |
| 674 |
$queryInfo = $this->linksMigration->getQueryInfo( 'templatelinks' ); |
| 675 |
|
| 676 |
if ( count( $others ) ) { |
| 677 |
|
| 678 |
$lb = $this->linkBatchFactory->newLinkBatch( $others ); |
| 679 |
$this->resetQueryParams(); |
| 680 |
$this->addTables( array_merge( [ 'page_restrictions', 'page' ], $queryInfo['tables'] ) ); |
| 681 |
|
| 682 |
$this->addOption( 'USE INDEX', [ 'templatelinks' => 'PRIMARY' ] ); |
| 683 |
$this->addFields( [ 'pr_type', 'pr_level', 'pr_expiry', |
| 684 |
'page_title', 'page_namespace', |
| 685 |
$blNamespace, $blTitle ] ); |
| 686 |
$this->addWhere( $lb->constructSet( 'tl', $db ) ); |
| 687 |
$this->addWhere( 'pr_page = page_id' ); |
| 688 |
$this->addWhere( 'pr_page = tl_from' ); |
| 689 |
$this->addWhereFld( 'pr_cascade', 1 ); |
| 690 |
$this->addJoinConds( $queryInfo['joins'] ); |
| 691 |
|
| 692 |
$res = $this->select( __METHOD__ ); |
| 693 |
foreach ( $res as $row ) { |
| 694 |
$this->protections[$row->$blNamespace][$row->$blTitle][] = [ |
| 695 |
'type' => $row->pr_type, |
| 696 |
'level' => $row->pr_level, |
| 697 |
'expiry' => ApiResult::formatExpiry( $row->pr_expiry ), |
| 698 |
'source' => $this->titleFormatter->formatTitle( $row->page_namespace, $row->page_title ), |
| 699 |
]; |
| 700 |
} |
| 701 |
} |
| 702 |
|
| 703 |
if ( count( $images ) ) { |
| 704 |
|
| 705 |
$this->resetQueryParams(); |
| 706 |
$this->addTables( [ 'page_restrictions', 'page', 'imagelinks' ] ); |
| 707 |
$this->addFields( [ 'pr_type', 'pr_level', 'pr_expiry', |
| 708 |
'page_title', 'page_namespace', 'il_to' ] ); |
| 709 |
$this->addWhere( 'pr_page = page_id' ); |
| 710 |
$this->addWhere( 'pr_page = il_from' ); |
| 711 |
$this->addWhereFld( 'pr_cascade', 1 ); |
| 712 |
$this->addWhereFld( 'il_to', $images ); |
| 713 |
|
| 714 |
$res = $this->select( __METHOD__ ); |
| 715 |
foreach ( $res as $row ) { |
| 716 |
$this->protections[NS_FILE][$row->il_to][] = [ |
| 717 |
'type' => $row->pr_type, |
| 718 |
'level' => $row->pr_level, |
| 719 |
'expiry' => ApiResult::formatExpiry( $row->pr_expiry ), |
| 720 |
'source' => $this->titleFormatter->formatTitle( $row->page_namespace, $row->page_title ), |
| 721 |
]; |
| 722 |
} |
| 723 |
} |
| 724 |
} |
| 725 |
|
| 726 |
|
| 727 |
|
| 728 |
|
| 729 |
|
| 730 |
private function getTSIDs() { |
| 731 |
$getTitles = $this->talkids = $this->subjectids = []; |
| 732 |
$nsInfo = $this->namespaceInfo; |
| 733 |
|
| 734 |
|
| 735 |
foreach ( $this->everything as $page ) { |
| 736 |
if ( $nsInfo->isTalk( $page->getNamespace() ) ) { |
| 737 |
if ( $this->fld_subjectid ) { |
| 738 |
$getTitles[] = $nsInfo->getSubjectPage( TitleValue::newFromPage( $page ) ); |
| 739 |
} |
| 740 |
} elseif ( $this->fld_talkid ) { |
| 741 |
$getTitles[] = $nsInfo->getTalkPage( TitleValue::newFromPage( $page ) ); |
| 742 |
} |
| 743 |
} |
| 744 |
if ( $getTitles === [] ) { |
| 745 |
return; |
| 746 |
} |
| 747 |
|
| 748 |
$db = $this->getDB(); |
| 749 |
|
| 750 |
|
| 751 |
|
| 752 |
$lb = $this->linkBatchFactory->newLinkBatch( $getTitles ); |
| 753 |
$this->resetQueryParams(); |
| 754 |
$this->addTables( 'page' ); |
| 755 |
$this->addFields( [ 'page_title', 'page_namespace', 'page_id' ] ); |
| 756 |
$this->addWhere( $lb->constructSet( 'page', $db ) ); |
| 757 |
$res = $this->select( __METHOD__ ); |
| 758 |
foreach ( $res as $row ) { |
| 759 |
if ( $nsInfo->isTalk( $row->page_namespace ) ) { |
| 760 |
$this->talkids[$nsInfo->getSubject( $row->page_namespace )][$row->page_title] = |
| 761 |
(int)( $row->page_id ); |
| 762 |
} else { |
| 763 |
$this->subjectids[$nsInfo->getTalk( $row->page_namespace )][$row->page_title] = |
| 764 |
(int)( $row->page_id ); |
| 765 |
} |
| 766 |
} |
| 767 |
} |
| 768 |
|
| 769 |
private function getDisplayTitle() { |
| 770 |
$this->displaytitles = []; |
| 771 |
|
| 772 |
$pageIds = array_keys( $this->titles ); |
| 773 |
|
| 774 |
if ( $pageIds === [] ) { |
| 775 |
return; |
| 776 |
} |
| 777 |
|
| 778 |
$this->resetQueryParams(); |
| 779 |
$this->addTables( 'page_props' ); |
| 780 |
$this->addFields( [ 'pp_page', 'pp_value' ] ); |
| 781 |
$this->addWhereFld( 'pp_page', $pageIds ); |
| 782 |
$this->addWhereFld( 'pp_propname', 'displaytitle' ); |
| 783 |
$res = $this->select( __METHOD__ ); |
| 784 |
|
| 785 |
foreach ( $res as $row ) { |
| 786 |
$this->displaytitles[$row->pp_page] = $row->pp_value; |
| 787 |
} |
| 788 |
} |
| 789 |
|
| 790 |
|
| 791 |
|
| 792 |
|
| 793 |
|
| 794 |
|
| 795 |
|
| 796 |
|
| 797 |
private function getLinkClasses( ?LinkTarget $context_title = null ) { |
| 798 |
if ( $this->titles === [] ) { |
| 799 |
return; |
| 800 |
} |
| 801 |
|
| 802 |
|
| 803 |
|
| 804 |
|
| 805 |
|
| 806 |
|
| 807 |
$classes = []; |
| 808 |
$pagemap = []; |
| 809 |
foreach ( $this->titles as $pageId => $page ) { |
| 810 |
$pdbk = $this->titleFormatter->getPrefixedDBkey( $page ); |
| 811 |
$pagemap[$pageId] = $pdbk; |
| 812 |
$classes[$pdbk] = isset( $this->pageIsRedir[$pageId] ) && $this->pageIsRedir[$pageId] ? 'mw-redirect' : ''; |
| 813 |
} |
| 814 |
|
| 815 |
$context_title = $this->titleFactory->newFromLinkTarget( |
| 816 |
$context_title ?? $this->titleFactory->newMainPage() |
| 817 |
); |
| 818 |
$this->getHookRunner()->onGetLinkColours( |
| 819 |
$pagemap, $classes, $context_title |
| 820 |
); |
| 821 |
|
| 822 |
|
| 823 |
|
| 824 |
|
| 825 |
|
| 826 |
$this->linkClasses = []; |
| 827 |
foreach ( $this->titles as $pageId => $page ) { |
| 828 |
$pdbk = $this->titleFormatter->getPrefixedDBkey( $page ); |
| 829 |
$this->linkClasses[$pageId] = preg_split( |
| 830 |
'/\s+/', $classes[$pdbk] ?? '', -1, PREG_SPLIT_NO_EMPTY |
| 831 |
); |
| 832 |
} |
| 833 |
} |
| 834 |
|
| 835 |
private function getVariantTitles() { |
| 836 |
if ( $this->titles === [] ) { |
| 837 |
return; |
| 838 |
} |
| 839 |
$this->variantTitles = []; |
| 840 |
foreach ( $this->titles as $pageId => $page ) { |
| 841 |
$this->variantTitles[$pageId] = isset( $this->displaytitles[$pageId] ) |
| 842 |
? $this->getAllVariants( $this->displaytitles[$pageId] ) |
| 843 |
: $this->getAllVariants( $this->titleFormatter->getText( $page ), $page->getNamespace() ); |
| 844 |
} |
| 845 |
} |
| 846 |
|
| 847 |
private function getAllVariants( $text, $ns = NS_MAIN ) { |
| 848 |
$result = []; |
| 849 |
foreach ( $this->languageConverter->getVariants() as $variant ) { |
| 850 |
$convertTitle = $this->languageConverter->autoConvert( $text, $variant ); |
| 851 |
if ( $ns !== NS_MAIN ) { |
| 852 |
$convertNs = $this->languageConverter->convertNamespace( $ns, $variant ); |
| 853 |
$convertTitle = $convertNs . ':' . $convertTitle; |
| 854 |
} |
| 855 |
$result[$variant] = $convertTitle; |
| 856 |
} |
| 857 |
return $result; |
| 858 |
} |
| 859 |
|
| 860 |
|
| 861 |
|
| 862 |
|
| 863 |
|
| 864 |
private function getWatchedInfo() { |
| 865 |
$user = $this->getUser(); |
| 866 |
|
| 867 |
if ( !$user->isRegistered() || count( $this->everything ) == 0 |
| 868 |
|| !$this->getAuthority()->isAllowed( 'viewmywatchlist' ) |
| 869 |
) { |
| 870 |
return; |
| 871 |
} |
| 872 |
|
| 873 |
$this->watched = []; |
| 874 |
$this->watchlistExpiries = []; |
| 875 |
$this->notificationtimestamps = []; |
| 876 |
|
| 877 |
|
| 878 |
$items = $this->watchedItemStore->loadWatchedItemsBatch( $user, $this->everything ); |
| 879 |
|
| 880 |
foreach ( $items as $item ) { |
| 881 |
$nsId = $item->getTarget()->getNamespace(); |
| 882 |
$dbKey = $item->getTarget()->getDBkey(); |
| 883 |
|
| 884 |
if ( $this->fld_watched ) { |
| 885 |
$this->watched[$nsId][$dbKey] = true; |
| 886 |
|
| 887 |
$expiry = $item->getExpiry( TS_ISO_8601 ); |
| 888 |
if ( $expiry ) { |
| 889 |
$this->watchlistExpiries[$nsId][$dbKey] = $expiry; |
| 890 |
} |
| 891 |
} |
| 892 |
|
| 893 |
if ( $this->fld_notificationtimestamp ) { |
| 894 |
$this->notificationtimestamps[$nsId][$dbKey] = $item->getNotificationTimestamp(); |
| 895 |
} |
| 896 |
} |
| 897 |
} |
| 898 |
|
| 899 |
|
| 900 |
|
| 901 |
|
| 902 |
private function getWatcherInfo() { |
| 903 |
if ( count( $this->everything ) == 0 ) { |
| 904 |
return; |
| 905 |
} |
| 906 |
|
| 907 |
$canUnwatchedpages = $this->getAuthority()->isAllowed( 'unwatchedpages' ); |
| 908 |
$unwatchedPageThreshold = |
| 909 |
$this->getConfig()->get( MainConfigNames::UnwatchedPageThreshold ); |
| 910 |
if ( !$canUnwatchedpages && !is_int( $unwatchedPageThreshold ) ) { |
| 911 |
return; |
| 912 |
} |
| 913 |
|
| 914 |
$this->showZeroWatchers = $canUnwatchedpages; |
| 915 |
|
| 916 |
$countOptions = []; |
| 917 |
if ( !$canUnwatchedpages ) { |
| 918 |
$countOptions['minimumWatchers'] = $unwatchedPageThreshold; |
| 919 |
} |
| 920 |
|
| 921 |
$this->watchers = $this->watchedItemStore->countWatchersMultiple( |
| 922 |
$this->everything, |
| 923 |
$countOptions |
| 924 |
); |
| 925 |
} |
| 926 |
|
| 927 |
|
| 928 |
|
| 929 |
|
| 930 |
|
| 931 |
|
| 932 |
|
| 933 |
private function getVisitingWatcherInfo() { |
| 934 |
$config = $this->getConfig(); |
| 935 |
$db = $this->getDB(); |
| 936 |
|
| 937 |
$canUnwatchedpages = $this->getAuthority()->isAllowed( 'unwatchedpages' ); |
| 938 |
$unwatchedPageThreshold = $config->get( MainConfigNames::UnwatchedPageThreshold ); |
| 939 |
if ( !$canUnwatchedpages && !is_int( $unwatchedPageThreshold ) ) { |
| 940 |
return; |
| 941 |
} |
| 942 |
|
| 943 |
$this->showZeroWatchers = $canUnwatchedpages; |
| 944 |
|
| 945 |
$titlesWithThresholds = []; |
| 946 |
if ( $this->titles ) { |
| 947 |
$lb = $this->linkBatchFactory->newLinkBatch( $this->titles ); |
| 948 |
|
| 949 |
|
| 950 |
$this->resetQueryParams(); |
| 951 |
$this->addTables( [ 'page', 'revision' ] ); |
| 952 |
$this->addFields( [ 'page_namespace', 'page_title', 'rev_timestamp' ] ); |
| 953 |
$this->addWhere( [ |
| 954 |
'page_latest = rev_id', |
| 955 |
$lb->constructSet( 'page', $db ), |
| 956 |
] ); |
| 957 |
$this->addOption( 'GROUP BY', [ 'page_namespace', 'page_title' ] ); |
| 958 |
$timestampRes = $this->select( __METHOD__ ); |
| 959 |
|
| 960 |
$age = $config->get( MainConfigNames::WatchersMaxAge ); |
| 961 |
$timestamps = []; |
| 962 |
foreach ( $timestampRes as $row ) { |
| 963 |
$revTimestamp = wfTimestamp( TS_UNIX, (int)$row->rev_timestamp ); |
| 964 |
$timestamps[$row->page_namespace][$row->page_title] = (int)$revTimestamp - $age; |
| 965 |
} |
| 966 |
$titlesWithThresholds = array_map( |
| 967 |
static function ( PageReference $target ) use ( $timestamps ) { |
| 968 |
return [ |
| 969 |
$target, $timestamps[$target->getNamespace()][$target->getDBkey()] |
| 970 |
]; |
| 971 |
}, |
| 972 |
$this->titles |
| 973 |
); |
| 974 |
} |
| 975 |
|
| 976 |
if ( $this->missing ) { |
| 977 |
$titlesWithThresholds = array_merge( |
| 978 |
$titlesWithThresholds, |
| 979 |
array_map( |
| 980 |
static function ( PageReference $target ) { |
| 981 |
return [ $target, null ]; |
| 982 |
}, |
| 983 |
$this->missing |
| 984 |
) |
| 985 |
); |
| 986 |
} |
| 987 |
$this->visitingwatchers = $this->watchedItemStore->countVisitingWatchersMultiple( |
| 988 |
$titlesWithThresholds, |
| 989 |
!$canUnwatchedpages ? $unwatchedPageThreshold : null |
| 990 |
); |
| 991 |
} |
| 992 |
|
| 993 |
public function getCacheMode( $params ) { |
| 994 |
|
| 995 |
$publicProps = [ |
| 996 |
'protection', |
| 997 |
'talkid', |
| 998 |
'subjectid', |
| 999 |
'associatedpage', |
| 1000 |
'url', |
| 1001 |
'preload', |
| 1002 |
'displaytitle', |
| 1003 |
'varianttitles', |
| 1004 |
]; |
| 1005 |
if ( array_diff( (array)$params['prop'], $publicProps ) ) { |
| 1006 |
return 'private'; |
| 1007 |
} |
| 1008 |
|
| 1009 |
|
| 1010 |
if ( $params['testactions'] ) { |
| 1011 |
return 'private'; |
| 1012 |
} |
| 1013 |
|
| 1014 |
return 'public'; |
| 1015 |
} |
| 1016 |
|
| 1017 |
public function getAllowedParams() { |
| 1018 |
return [ |
| 1019 |
'prop' => [ |
| 1020 |
ParamValidator::PARAM_ISMULTI => true, |
| 1021 |
ParamValidator::PARAM_TYPE => [ |
| 1022 |
'protection', |
| 1023 |
'talkid', |
| 1024 |
'watched', |
| 1025 |
'watchers', |
| 1026 |
'visitingwatchers', |
| 1027 |
'notificationtimestamp', |
| 1028 |
'subjectid', |
| 1029 |
'associatedpage', |
| 1030 |
'url', |
| 1031 |
'readable', |
| 1032 |
'preload', |
| 1033 |
'preloadcontent', |
| 1034 |
'editintro', |
| 1035 |
'displaytitle', |
| 1036 |
'varianttitles', |
| 1037 |
'linkclasses', |
| 1038 |
|
| 1039 |
|
| 1040 |
], |
| 1041 |
ApiBase::PARAM_HELP_MSG_PER_VALUE => [], |
| 1042 |
EnumDef::PARAM_DEPRECATED_VALUES => [ |
| 1043 |
'readable' => true, |
| 1044 |
'preload' => true, |
| 1045 |
], |
| 1046 |
], |
| 1047 |
'linkcontext' => [ |
| 1048 |
ParamValidator::PARAM_TYPE => 'title', |
| 1049 |
ParamValidator::PARAM_DEFAULT => $this->titleFactory->newMainPage()->getPrefixedText(), |
| 1050 |
TitleDef::PARAM_RETURN_OBJECT => true, |
| 1051 |
], |
| 1052 |
'testactions' => [ |
| 1053 |
ParamValidator::PARAM_TYPE => 'string', |
| 1054 |
ParamValidator::PARAM_ISMULTI => true, |
| 1055 |
], |
| 1056 |
'testactionsdetail' => [ |
| 1057 |
ParamValidator::PARAM_TYPE => [ 'boolean', 'full', 'quick' ], |
| 1058 |
ParamValidator::PARAM_DEFAULT => 'boolean', |
| 1059 |
ApiBase::PARAM_HELP_MSG_PER_VALUE => [], |
| 1060 |
], |
| 1061 |
'testactionsautocreate' => false, |
| 1062 |
'preloadcustom' => [ |
| 1063 |
|
| 1064 |
|
| 1065 |
ParamValidator::PARAM_TYPE => 'string', |
| 1066 |
ApiBase::PARAM_HELP_MSG_INFO => [ [ 'preloadcontentonly' ] ], |
| 1067 |
], |
| 1068 |
'preloadparams' => [ |
| 1069 |
ParamValidator::PARAM_ISMULTI => true, |
| 1070 |
ApiBase::PARAM_HELP_MSG_INFO => [ [ 'preloadcontentonly' ] ], |
| 1071 |
], |
| 1072 |
'preloadnewsection' => [ |
| 1073 |
ParamValidator::PARAM_TYPE => 'boolean', |
| 1074 |
ParamValidator::PARAM_DEFAULT => false, |
| 1075 |
ApiBase::PARAM_HELP_MSG_INFO => [ [ 'preloadcontentonly' ] ], |
| 1076 |
], |
| 1077 |
'editintrostyle' => [ |
| 1078 |
ParamValidator::PARAM_TYPE => [ 'lessframes', 'moreframes' ], |
| 1079 |
ParamValidator::PARAM_DEFAULT => 'moreframes', |
| 1080 |
ApiBase::PARAM_HELP_MSG_INFO => [ [ 'editintroonly' ] ], |
| 1081 |
], |
| 1082 |
'editintroskip' => [ |
| 1083 |
ParamValidator::PARAM_TYPE => 'string', |
| 1084 |
ParamValidator::PARAM_ISMULTI => true, |
| 1085 |
ApiBase::PARAM_HELP_MSG_INFO => [ [ 'editintroonly' ] ], |
| 1086 |
], |
| 1087 |
'editintrocustom' => [ |
| 1088 |
|
| 1089 |
|
| 1090 |
ParamValidator::PARAM_TYPE => 'string', |
| 1091 |
ApiBase::PARAM_HELP_MSG_INFO => [ [ 'editintroonly' ] ], |
| 1092 |
], |
| 1093 |
'continue' => [ |
| 1094 |
ApiBase::PARAM_HELP_MSG => 'api-help-param-continue', |
| 1095 |
], |
| 1096 |
]; |
| 1097 |
} |
| 1098 |
|
| 1099 |
protected function getExamplesMessages() { |
| 1100 |
$title = Title::newMainPage()->getPrefixedText(); |
| 1101 |
$mp = rawurlencode( $title ); |
| 1102 |
|
| 1103 |
return [ |
| 1104 |
"action=query&prop=info&titles={$mp}" |
| 1105 |
=> 'apihelp-query+info-example-simple', |
| 1106 |
"action=query&prop=info&inprop=protection&titles={$mp}" |
| 1107 |
=> 'apihelp-query+info-example-protection', |
| 1108 |
]; |
| 1109 |
} |
| 1110 |
|
| 1111 |
public function getHelpUrls() { |
| 1112 |
return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Info'; |
| 1113 |
} |
| 1114 |
} |
| 1115 |
|
| 1116 |
|
| 1117 |
class_alias( ApiQueryInfo::class, 'ApiQueryInfo' ); |