Umherirrender has uploaded a new change for review. https://gerrit.wikimedia.org/r/74963
Change subject: Api: Add editnotices to prop=info ...................................................................... Api: Add editnotices to prop=info Added only the message keys, this avoids problems, which occurs on parsing and caching, like language and other user settings. Bug: 43683 Change-Id: I555a2ed6fb3078ae8d5124794f23bc4d44de2c9c --- M includes/Title.php M includes/api/ApiQueryInfo.php 2 files changed, 21 insertions(+), 5 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/63/74963/1 diff --git a/includes/Title.php b/includes/Title.php index 0c223af..0b6c2fa 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -4751,16 +4751,18 @@ * they will already be wrapped in paragraphs. * * @since 1.21 + * @param bool $keys Return only the keys of the messages * @return Array */ - public function getEditNotices() { + public function getEditNotices( $keys = false ) { $notices = array(); # Optional notices on a per-namespace and per-page basis $editnotice_ns = 'editnotice-' . $this->getNamespace(); $editnotice_ns_message = wfMessage( $editnotice_ns ); if ( $editnotice_ns_message->exists() ) { - $notices[$editnotice_ns] = $editnotice_ns_message->parseAsBlock(); + $notices[$editnotice_ns] = + !$keys ? $editnotice_ns_message->parseAsBlock() : ''; } if ( MWNamespace::hasSubpages( $this->getNamespace() ) ) { $parts = explode( '/', $this->getDBkey() ); @@ -4769,7 +4771,7 @@ $editnotice_base .= '-' . array_shift( $parts ); $editnotice_base_msg = wfMessage( $editnotice_base ); if ( $editnotice_base_msg->exists() ) { - $notices[$editnotice_base] = $editnotice_base_msg->parseAsBlock(); + $notices[$editnotice_base] = !$keys ? $editnotice_base_msg->parseAsBlock() : ''; } } } else { @@ -4777,7 +4779,7 @@ $editnoticeText = $editnotice_ns . '-' . str_replace( '/', '-', $this->getDBkey() ); $editnoticeMsg = wfMessage( $editnoticeText ); if ( $editnoticeMsg->exists() ) { - $notices[$editnoticeText] = $editnoticeMsg->parseAsBlock(); + $notices[$editnoticeText] = !$keys ? $editnoticeMsg->parseAsBlock() : ''; } } return $notices; diff --git a/includes/api/ApiQueryInfo.php b/includes/api/ApiQueryInfo.php index 017684e..317c1b4 100644 --- a/includes/api/ApiQueryInfo.php +++ b/includes/api/ApiQueryInfo.php @@ -35,7 +35,7 @@ $fld_subjectid = false, $fld_url = false, $fld_readable = false, $fld_watched = false, $fld_watchers = false, $fld_notificationtimestamp = false, - $fld_preload = false, $fld_displaytitle = false; + $fld_preload = false, $fld_editnotices = false, $fld_displaytitle = false; private $params, $titles, $missing, $everything, $pageCounter; @@ -260,6 +260,7 @@ $this->fld_url = isset( $prop['url'] ); $this->fld_readable = isset( $prop['readable'] ); $this->fld_preload = isset( $prop['preload'] ); + $this->fld_editnotices = isset( $prop['editnotices'] ); $this->fld_displaytitle = isset( $prop['displaytitle'] ); } @@ -439,6 +440,16 @@ $pageInfo['preload'] = $text; } + } + + if ( $this->fld_editnotices ) { + $editNotices = $title->getEditNotices( 'keys' ); + $data = array(); + foreach ( $editNotices as $msgKey => $unused ) { + $data[] = array( 'message' => $msgKey ); + } + $this->getResult()->setIndexedTagName( $data, 'editnotice' ); + $pageInfo['editnotices'] = $data; } if ( $this->fld_displaytitle ) { @@ -749,6 +760,7 @@ 'subjectid', 'url', 'preload', + 'editnotices', 'displaytitle', ); if ( !is_null( $params['prop'] ) ) { @@ -779,6 +791,7 @@ 'url', 'readable', # private 'preload', + 'editnotices', 'displaytitle', // If you add more properties here, please consider whether they // need to be added to getCacheMode() @@ -805,6 +818,7 @@ ' url - Gives a full URL to the page, and also an edit URL', ' readable - Whether the user can read this page', ' preload - Gives the text returned by EditFormPreloadText', + ' editnotices - Gives the message keys for edit notices for each page', ' displaytitle - Gives the way the page title is actually displayed', ), 'token' => 'Request a token to perform a data-modifying action on a page', -- To view, visit https://gerrit.wikimedia.org/r/74963 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I555a2ed6fb3078ae8d5124794f23bc4d44de2c9c Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Umherirrender <umherirrender_de...@web.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits