/** @var Content $pstContent */
private $pstContent = null;
+ private function checkReadPermissions( Title $title ) {
+ if ( !$title->userCan( 'read', $this->getUser() ) ) {
+ $this->dieUsage( "You don't have permission to view this page", 'permissiondenied' );
+ }
+ }
+
public function execute() {
// The data is hot but user-dependent, like page views, so we set vary cookies
$this->getMain()->setCacheMode( 'anon-public-user-private' );
if ( !$rev ) {
$this->dieUsage( "There is no revision ID $oldid", 'missingrev' );
}
+
+ $this->checkReadPermissions( $rev->getTitle() );
if ( !$rev->userCan( Revision::DELETED_TEXT, $this->getUser() ) ) {
$this->dieUsage( "You don't have permission to view deleted revisions", 'permissiondenied' );
}
if ( !$titleObj || !$titleObj->exists() ) {
$this->dieUsage( "The page you specified doesn't exist", 'missingtitle' );
}
+
+ $this->checkReadPermissions( $titleObj );
$wgTitle = $titleObj;
if ( isset( $prop['revid'] ) ) {
$titleObj->getPrefixedText();
}
- if ( isset( $prop['headitems'] ) || isset( $prop['headhtml'] ) ) {
+ if ( isset( $prop['headitems'] ) ) {
+ $result_array['headitems'] = $this->formatHeadItems( $p_result->getHeadItems() );
+ $this->logFeatureUsage( 'action=parse&prop=headitems' );
+ $this->setWarning( 'headitems is deprecated since MediaWiki 1.28. '
+ . 'Use prop=headhtml when creating new HTML documents, or '
+ . 'prop=modules|jsconfigvars when updating a document client-side.' );
+ }
+
+ if ( isset( $prop['headhtml'] ) ) {
$context = new DerivativeContext( $this->getContext() );
$context->setTitle( $titleObj );
$context->setWikiPage( $pageObj );
$output = new OutputPage( $context );
$output->addParserOutputMetadata( $p_result );
- if ( isset( $prop['headitems'] ) ) {
- $headItems = $this->formatHeadItems( $p_result->getHeadItems() );
-
- $css = $this->formatCss( $output->buildCssLinksArray() );
-
- $scripts = [ $output->getHeadScripts() ];
-
- $result_array['headitems'] = array_merge( $headItems, $css, $scripts );
- }
-
- if ( isset( $prop['headhtml'] ) ) {
- $result_array['headhtml'] = $output->headElement( $context->getSkin() );
- $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'headhtml';
- }
+ $result_array['headhtml'] = $output->headElement( $context->getSkin() );
+ $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'headhtml';
}
if ( isset( $prop['modules'] ) ) {
$hiddencats[$row->page_title] = isset( $row->pp_propname );
}
+ $linkCache = LinkCache::singleton();
+
foreach ( $links as $link => $sortkey ) {
$entry = [];
$entry['sortkey'] = $sortkey;
ApiResult::setContentValue( $entry, 'category', (string)$link );
if ( !isset( $hiddencats[$link] ) ) {
$entry['missing'] = true;
+
+ // We already know the link doesn't exist in the database, so
+ // tell LinkCache that before calling $title->isKnown().
+ $title = Title::makeTitle( NS_CATEGORY, $link );
+ $linkCache->addBadLinkObj( $title );
+ if ( $title->isKnown() ) {
+ $entry['known'] = true;
+ }
} elseif ( $hiddencats[$link] ) {
$entry['hidden'] = true;
}
return $result;
}
- private function formatCss( $css ) {
- $result = [];
- foreach ( $css as $file => $link ) {
- $entry = [];
- $entry['file'] = $file;
- ApiResult::setContentValue( $entry, 'link', $link );
- $result[] = $entry;
- }
-
- return $result;
- }
-
private function formatLimitReportData( $limitReportData ) {
$result = [];