Merge "Default is not necessary for toggle fields"
[lhc/web/wiklou.git] / includes / Title.php
index 072bf44..734e009 100644 (file)
@@ -1441,7 +1441,7 @@ class Title {
                                $url = str_replace( '$1', $dbkey, $wgArticlePath );
                                wfRunHooks( 'GetLocalURL::Article', array( &$this, &$url ) );
                        } else {
-                               global $wgVariantArticlePath, $wgActionPaths;
+                               global $wgVariantArticlePath, $wgActionPaths, $wgContLang;
                                $url = false;
                                $matches = array();
 
@@ -1463,6 +1463,7 @@ class Title {
 
                                if ( $url === false &&
                                        $wgVariantArticlePath &&
+                                       $wgContLang->getCode() === $this->getPageLanguage()->getCode() &&
                                        $this->getPageLanguage()->hasVariants() &&
                                        preg_match( '/^variant=([^&]*)$/', $query, $matches ) )
                                {
@@ -2099,34 +2100,10 @@ class Title {
         * @return Array list of errors
         */
        private function checkReadPermissions( $action, $user, $errors, $doExpensiveQueries, $short ) {
-               global $wgWhitelistRead, $wgWhitelistReadRegexp, $wgRevokePermissions;
-               static $useShortcut = null;
-
-               # Initialize the $useShortcut boolean, to determine if we can skip quite a bit of code below
-               if ( is_null( $useShortcut ) ) {
-                       $useShortcut = true;
-                       if ( !User::groupHasPermission( '*', 'read' ) ) {
-                               # Not a public wiki, so no shortcut
-                               $useShortcut = false;
-                       } elseif ( !empty( $wgRevokePermissions ) ) {
-                               /**
-                                * Iterate through each group with permissions being revoked (key not included since we don't care
-                                * what the group name is), then check if the read permission is being revoked. If it is, then
-                                * we don't use the shortcut below since the user might not be able to read, even though anon
-                                * reading is allowed.
-                                */
-                               foreach ( $wgRevokePermissions as $perms ) {
-                                       if ( !empty( $perms['read'] ) ) {
-                                               # We might be removing the read right from the user, so no shortcut
-                                               $useShortcut = false;
-                                               break;
-                                       }
-                               }
-                       }
-               }
+               global $wgWhitelistRead, $wgWhitelistReadRegexp;
 
                $whitelisted = false;
-               if ( $useShortcut ) {
+               if ( User::isEveryoneAllowed( 'read' ) ) {
                        # Shortcut for public wikis, allows skipping quite a bit of code
                        $whitelisted = true;
                } elseif ( $user->isAllowed( 'read' ) ) {
@@ -4775,9 +4752,10 @@ class Title {
         * they will already be wrapped in paragraphs.
         *
         * @since 1.21
+        * @param int oldid Revision ID that's being edited
         * @return Array
         */
-       public function getEditNotices() {
+       public function getEditNotices( $oldid = 0 ) {
                $notices = array();
 
                # Optional notices on a per-namespace and per-page basis
@@ -4804,6 +4782,8 @@ class Title {
                                $notices[$editnoticeText] = $editnoticeMsg->parseAsBlock();
                        }
                }
+
+               wfRunHooks( 'TitleGetEditNotices', array( $this, $oldid, &$notices ) );
                return $notices;
        }
 }