Clean up Title::isSemiProtected() and make it return false if the page doesn't exist
authorRob Church <robchurch@users.mediawiki.org>
Wed, 27 Dec 2006 07:47:10 +0000 (07:47 +0000)
committerRob Church <robchurch@users.mediawiki.org>
Wed, 27 Dec 2006 07:47:10 +0000 (07:47 +0000)
includes/Title.php

index a6145e8..96df51d 100644 (file)
@@ -989,14 +989,15 @@ class Title {
         * @return bool
         */
        function isSemiProtected( $action = 'edit' ) {
-               $restrictions = $this->getRestrictions( $action );
-               # We do a full compare because this could be an array
-               foreach( $restrictions as $restriction ) {
-                       if( strtolower( $restriction ) != 'autoconfirmed' ) {
-                               return( false );
+               if( $this->exists() ) {
+                       foreach( $this->getRestrictions( $action ) as $restriction ) {
+                               if( strtolower( $restriction ) != 'autoconfirmed' )
+                                       return false;
                        }
+               } else {
+                       # If it doesn't exist, it can't be protected
+                       return false;
                }
-               return( true );
        }
 
        /**