API: Fixed documentation for hasmg parameter
[lhc/web/wiklou.git] / includes / api / ApiQueryInfo.php
index db28df7..c45e0ef 100644 (file)
@@ -395,10 +395,10 @@ class ApiQueryInfo extends ApiQueryBase {
                        $pageInfo['length'] = intval( $this->pageLength[$pageid] );
 
                        if ( isset( $this->pageIsRedir[$pageid] ) && $this->pageIsRedir[$pageid] ) {
-                               $pageInfo['redirect'] = '';
+                               $pageInfo['redirect'] = true;
                        }
                        if ( $this->pageIsNew[$pageid] ) {
-                               $pageInfo['new'] = '';
+                               $pageInfo['new'] = true;
                        }
                }
 
@@ -431,8 +431,8 @@ class ApiQueryInfo extends ApiQueryBase {
                        ApiResult::setIndexedTagName( $pageInfo['restrictiontypes'], 'rt' );
                }
 
-               if ( $this->fld_watched && isset( $this->watched[$ns][$dbkey] ) ) {
-                       $pageInfo['watched'] = '';
+               if ( $this->fld_watched ) {
+                       $pageInfo['watched'] = isset( $this->watched[$ns][$dbkey] );
                }
 
                if ( $this->fld_watchers ) {
@@ -464,8 +464,8 @@ class ApiQueryInfo extends ApiQueryBase {
                        $pageInfo['editurl'] = wfExpandUrl( $title->getFullURL( 'action=edit' ), PROTO_CURRENT );
                        $pageInfo['canonicalurl'] = wfExpandUrl( $title->getFullURL(), PROTO_CANONICAL );
                }
-               if ( $this->fld_readable && $title->userCan( 'read', $this->getUser() ) ) {
-                       $pageInfo['readable'] = '';
+               if ( $this->fld_readable ) {
+                       $pageInfo['readable'] = $title->userCan( 'read', $this->getUser() );
                }
 
                if ( $this->fld_preload ) {
@@ -497,9 +497,7 @@ class ApiQueryInfo extends ApiQueryBase {
                        $pageInfo['actions'] = array();
                        foreach ( $this->params['testactions'] as $action ) {
                                $this->countTestedActions++;
-                               if ( $title->userCan( $action, $user ) ) {
-                                       $pageInfo['actions'][$action] = '';
-                               }
+                               $pageInfo['actions'][$action] = $title->userCan( $action, $user );
                        }
                }
 
@@ -532,7 +530,7 @@ class ApiQueryInfo extends ApiQueryBase {
                                        'expiry' => $wgContLang->formatExpiry( $row->pr_expiry, TS_ISO_8601 )
                                );
                                if ( $row->pr_cascade ) {
-                                       $a['cascade'] = '';
+                                       $a['cascade'] = true;
                                }
                                $this->protections[$title->getNamespace()][$title->getDBkey()][] = $a;
                        }
@@ -801,6 +799,7 @@ class ApiQueryInfo extends ApiQueryBase {
        }
 
        public function getCacheMode( $params ) {
+               // Other props depend on something about the current user
                $publicProps = array(
                        'protection',
                        'talkid',
@@ -809,13 +808,15 @@ class ApiQueryInfo extends ApiQueryBase {
                        'preload',
                        'displaytitle',
                );
-               if ( !is_null( $params['prop'] ) ) {
-                       foreach ( $params['prop'] as $prop ) {
-                               if ( !in_array( $prop, $publicProps ) ) {
-                                       return 'private';
-                               }
-                       }
+               if ( array_diff( (array)$params['prop'], $publicProps ) ) {
+                       return 'private';
                }
+
+               // testactions also depends on the current user
+               if ( $params['testactions'] ) {
+                       return 'private';
+               }
+
                if ( !is_null( $params['token'] ) ) {
                        return 'private';
                }
@@ -870,6 +871,6 @@ class ApiQueryInfo extends ApiQueryBase {
        }
 
        public function getHelpUrls() {
-               return 'https://www.mediawiki.org/wiki/API:Properties#info_.2F_in';
+               return 'https://www.mediawiki.org/wiki/API:Info';
        }
 }