[JobQueue] Made the maximum number of job attempts configurable.
[lhc/web/wiklou.git] / includes / Title.php
index 6aa4cd2..c1782e5 100644 (file)
@@ -149,7 +149,7 @@ class Title {
                $t->mDbkeyform = str_replace( ' ', '_', $filteredText );
                $t->mDefaultNamespace = $defaultNamespace;
 
-               static $cachedcount = 0 ;
+               static $cachedcount = 0;
                if ( $t->secureAndSplit() ) {
                        if ( $defaultNamespace == NS_MAIN ) {
                                if ( $cachedcount >= self::CACHE_MAX ) {
@@ -1728,8 +1728,10 @@ class Title {
         */
        private function checkQuickPermissions( $action, $user, $errors, $doExpensiveQueries, $short ) {
                if ( $action == 'create' ) {
-                       if ( ( $this->isTalkPage() && !$user->isAllowed( 'createtalk' ) ) ||
-                                ( !$this->isTalkPage() && !$user->isAllowed( 'createpage' ) ) ) {
+                       if (
+                               ( $this->isTalkPage() && !$user->isAllowed( 'createtalk' ) ) ||
+                               ( !$this->isTalkPage() && !$user->isAllowed( 'createpage' ) )
+                       ) {
                                $errors[] = $user->isAnon() ? array( 'nocreatetext' ) : array( 'nocreate-loggedin' );
                        }
                } elseif ( $action == 'move' ) {
@@ -1818,8 +1820,11 @@ class Title {
                        $errors = $this->resultToError( $errors, $result );
                }
                // Check getUserPermissionsErrorsExpensive hook
-               if ( $doExpensiveQueries && !( $short && count( $errors ) > 0 ) &&
-                        !wfRunHooks( 'getUserPermissionsErrorsExpensive', array( &$this, &$user, $action, &$result ) ) ) {
+               if (
+                       $doExpensiveQueries
+                       && !( $short && count( $errors ) > 0 )
+                       && !wfRunHooks( 'getUserPermissionsErrorsExpensive', array( &$this, &$user, $action, &$result ) )
+               ) {
                        $errors = $this->resultToError( $errors, $result );
                }
 
@@ -2146,7 +2151,7 @@ class Title {
                                # If it's a special page, ditch the subpage bit and check again
                                $name = $this->getDBkey();
                                list( $name, /* $subpage */ ) = SpecialPageFactory::resolveAlias( $name );
-                               if ( $name !== false ) {
+                               if ( $name ) {
                                        $pure = SpecialPage::getTitleFor( $name )->getPrefixedText();
                                        if ( in_array( $pure, $wgWhitelistRead, true ) ) {
                                                $whitelisted = true;
@@ -2274,8 +2279,10 @@ class Title {
        public function userCanEditJsSubpage() {
                global $wgUser;
                wfDeprecated( __METHOD__, '1.19' );
-               return ( ( $wgUser->isAllowedAll( 'editusercssjs', 'edituserjs' ) )
-                          || preg_match( '/^' . preg_quote( $wgUser->getName(), '/' ) . '\//', $this->mTextform ) );
+               return (
+                       ( $wgUser->isAllowedAll( 'editusercssjs', 'edituserjs' ) )
+                       || preg_match( '/^' . preg_quote( $wgUser->getName(), '/' ) . '\//', $this->mTextform )
+               );
        }
 
        /**
@@ -2343,9 +2350,12 @@ class Title {
 
                if ( !isset( $this->mTitleProtection ) ) {
                        $dbr = wfGetDB( DB_SLAVE );
-                       $res = $dbr->select( 'protected_titles', '*',
+                       $res = $dbr->select(
+                               'protected_titles',
+                               array( 'pt_user', 'pt_reason', 'pt_expiry', 'pt_create_perm' ),
                                array( 'pt_namespace' => $this->getNamespace(), 'pt_title' => $this->getDBkey() ),
-                               __METHOD__ );
+                               __METHOD__
+                       );
 
                        // fetchRow returns false if there are no rows.
                        $this->mTitleProtection = $dbr->fetchRow( $res );
@@ -2522,7 +2532,7 @@ class Title {
 
                if ( $getPages ) {
                        $cols = array( 'pr_page', 'page_namespace', 'page_title',
-                                                  'pr_expiry', 'pr_type', 'pr_level' );
+                               'pr_expiry', 'pr_type', 'pr_level' );
                        $where_clauses[] = 'page_id=pr_page';
                        $tables[] = 'page';
                } else {
@@ -2550,8 +2560,10 @@ class Title {
                                                $pagerestrictions[$row->pr_type] = array();
                                        }
 
-                                       if ( isset( $pagerestrictions[$row->pr_type] ) &&
-                                                !in_array( $row->pr_level, $pagerestrictions[$row->pr_type] ) ) {
+                                       if (
+                                               isset( $pagerestrictions[$row->pr_type] )
+                                               && !in_array( $row->pr_level, $pagerestrictions[$row->pr_type] )
+                                       ) {
                                                $pagerestrictions[$row->pr_type][] = $row->pr_level;
                                        }
                                } else {
@@ -2735,7 +2747,7 @@ class Title {
 
                                $res = $dbr->select(
                                        'page_restrictions',
-                                       '*',
+                                       array( 'pr_type', 'pr_expiry', 'pr_level', 'pr_cascade' ),
                                        array( 'pr_page' => $this->getArticleID() ),
                                        __METHOD__
                                );
@@ -2777,6 +2789,10 @@ class Title {
         * Purge expired restrictions from the page_restrictions table
         */
        static function purgeExpiredRestrictions() {
+               if ( wfReadOnly() ) {
+                       return;
+               }
+
                $dbw = wfGetDB( DB_MASTER );
                $dbw->delete(
                        'page_restrictions',
@@ -3186,15 +3202,18 @@ class Title {
                # Pages with "/./" or "/../" appearing in the URLs will often be un-
                # reachable due to the way web browsers deal with 'relative' URLs.
                # Also, they conflict with subpage syntax.  Forbid them explicitly.
-               if ( strpos( $dbkey, '.' ) !== false &&
-                        ( $dbkey === '.' || $dbkey === '..' ||
-                          strpos( $dbkey, './' ) === 0  ||
-                          strpos( $dbkey, '../' ) === 0 ||
-                          strpos( $dbkey, '/./' ) !== false ||
-                          strpos( $dbkey, '/../' ) !== false  ||
-                          substr( $dbkey, -2 ) == '/.' ||
-                          substr( $dbkey, -3 ) == '/..' ) )
-               {
+               if (
+                       strpos( $dbkey, '.' ) !== false &&
+                       (
+                               $dbkey === '.' || $dbkey === '..' ||
+                               strpos( $dbkey, './' ) === 0  ||
+                               strpos( $dbkey, '../' ) === 0 ||
+                               strpos( $dbkey, '/./' ) !== false ||
+                               strpos( $dbkey, '/../' ) !== false  ||
+                               substr( $dbkey, -2 ) == '/.' ||
+                               substr( $dbkey, -3 ) == '/..'
+                       )
+               ) {
                        return false;
                }
 
@@ -3207,9 +3226,10 @@ class Title {
                # underlying database field. We make an exception for special pages, which
                # don't need to be stored in the database, and may edge over 255 bytes due
                # to subpage syntax for long titles, e.g. [[Special:Block/Long name]]
-               if ( ( $this->mNamespace != NS_SPECIAL && strlen( $dbkey ) > 255 ) ||
-                 strlen( $dbkey ) > 512 )
-               {
+               if (
+                       ( $this->mNamespace != NS_SPECIAL && strlen( $dbkey ) > 255 )
+                       || strlen( $dbkey ) > 512
+               ) {
                        return false;
                }
 
@@ -3504,9 +3524,11 @@ class Title {
                if ( strlen( $nt->getDBkey() ) < 1 ) {
                        $errors[] = array( 'articleexists' );
                }
-               if ( ( $this->getDBkey() == '' ) ||
-                        ( !$oldid ) ||
-                        ( $nt->getDBkey() == '' ) ) {
+               if (
+                       ( $this->getDBkey() == '' ) ||
+                       ( !$oldid ) ||
+                       ( $nt->getDBkey() == '' )
+               ) {
                        $errors[] = array( 'badarticleerror' );
                }
 
@@ -4035,12 +4057,11 @@ class Title {
 
                $dbr = wfGetDB( DB_SLAVE );
 
-               $res = $dbr->select( 'categorylinks', '*',
-                       array(
-                               'cl_from' => $titleKey,
-                       ),
-                       __METHOD__,
-                       array()
+               $res = $dbr->select(
+                       'categorylinks',
+                       'cl_to',
+                       array( 'cl_from' => $titleKey ),
+                       __METHOD__
                );
 
                if ( $res->numRows() > 0 ) {
@@ -4280,7 +4301,7 @@ class Title {
                }
                $old_cmp = '>';
                $new_cmp = '<';
-               $options = (array) $options;
+               $options = (array)$options;
                if ( in_array( 'include_old', $options ) ) {
                        $old_cmp = '>=';
                }