From 23041421b09304bd66c2d16dd61898059efffc03 Mon Sep 17 00:00:00 2001 From: Aryeh Gregor Date: Wed, 2 Jan 2008 01:39:05 +0000 Subject: [PATCH] Chalk another bug up to PHP's lunacy. When a user creating a page is not allowed to either create the page nor edit it, all applicable reasons are now shown, not just the reasons it couldn't be edited. --- RELEASE-NOTES | 2 ++ includes/EditPage.php | 13 +++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index fd25ef2699..9ab08d1dfe 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 == diff --git a/includes/EditPage.php b/includes/EditPage.php index 1bd627fd8a..ab4b86a362 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -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(); -- 2.20.1