Chalk another bug up to PHP's lunacy. When a user creating a page is not allowed...
authorAryeh Gregor <simetrical@users.mediawiki.org>
Wed, 2 Jan 2008 01:39:05 +0000 (01:39 +0000)
committerAryeh Gregor <simetrical@users.mediawiki.org>
Wed, 2 Jan 2008 01:39:05 +0000 (01:39 +0000)
RELEASE-NOTES
includes/EditPage.php

index fd25ef2..9ab08d1 100644 (file)
@@ -274,6 +274,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   are now forbidden. A run of cleanupTitles.php will fix up existing pages.
 * (bug 12446) Permissions check fix for undelete link
 * (bug 12451) AJAX title normalization tweaks
+* When a user creating a page is not allowed to either create the page nor edit
+  it, all applicable reasons are now shown.
 
 
 == Parser changes in 1.12 ==
index 1bd627f..ab4b86a 100644 (file)
@@ -355,8 +355,17 @@ class EditPage {
                }
 
                $permErrors = $this->mTitle->getUserPermissionsErrors('edit', $wgUser);
-               if( !$this->mTitle->exists() )
-                       $permErrors += array_diff( $this->mTitle->getUserPermissionsErrors('create', $wgUser), $permErrors );
+               if( !$this->mTitle->exists() ) {
+                       # We can't use array_diff here, because that considers ANY TWO
+                       # ARRAYS TO BE EQUAL.  Thanks, PHP.
+                       $createErrors = $this->mTitle->getUserPermissionsErrors('create', $wgUser);
+                       foreach( $createErrors as $error ) {
+                               # in_array() actually *does* work as expected.
+                               if( !in_array( $error, $permErrors ) ) {
+                                       $permErrors[] = $error;
+                               }
+                       }
+               }
 
                # Ignore some permissions errors.
                $remove = array();