$this->params = $this->extractRequestParams();
if ( $this->params['continue'] ) {
$continueValue = intval( $this->params['continue'] );
- $filteredPages = array();
+ $this->dieContinueUsageIf( strval( $continueValue ) !== $this->params['continue'] );
+ $filteredPages = [];
foreach ( $pages as $id => $page ) {
if ( $id >= $continueValue ) {
$filteredPages[$id] = $page;
}
$pageProps = PageProps::getInstance();
- $props = array();
$result = $this->getResult();
if ( $this->params['prop'] ) {
$propnames = $this->params['prop'];
- $properties = array();
- foreach ( $propnames as $propname ) {
- $values = $pageProps->getProperty( $pages, $propname );
- foreach ( $values as $page => $value ) {
- if ( !isset( $properties[$page] ) ) {
- $properties[$page] = array();
- }
- $properties[$page][$propname] = $value;
- }
- }
+ $properties = $pageProps->getProperties( $pages, $propnames );
} else {
- $properties = $pageProps->getProperties( $pages );
+ $properties = $pageProps->getAllProperties( $pages );
}
+
+ ksort( $properties );
+
foreach ( $properties as $page => $props ) {
- $this->addPageProps( $result, $page, $props );
+ if ( !$this->addPageProps( $result, $page, $props ) ) {
+ break;
+ }
}
}
*/
private function addPageProps( $result, $page, $props ) {
ApiResult::setArrayType( $props, 'assoc' );
- $fit = $result->addValue( array( 'query', 'pages', $page ), 'pageprops', $props );
+ $fit = $result->addValue( [ 'query', 'pages', $page ], 'pageprops', $props );
if ( !$fit ) {
$this->setContinueEnumParameter( 'continue', $page );
}
public function getAllowedParams() {
- return array(
- 'continue' => array(
+ return [
+ 'continue' => [
ApiBase::PARAM_HELP_MSG => 'api-help-param-continue',
- ),
- 'prop' => array(
+ ],
+ 'prop' => [
ApiBase::PARAM_ISMULTI => true,
- ),
- );
+ ],
+ ];
}
protected function getExamplesMessages() {
- return array(
+ return [
'action=query&prop=pageprops&titles=Main%20Page|MediaWiki'
=> 'apihelp-query+pageprops-example-simple',
- );
+ ];
}
public function getHelpUrls() {