From: Aryeh Gregor Date: Wed, 2 Jan 2008 01:39:05 +0000 (+0000) Subject: Chalk another bug up to PHP's lunacy. When a user creating a page is not allowed... X-Git-Tag: 1.31.0-rc.0~50188 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/journal.php?a=commitdiff_plain;h=23041421b09304bd66c2d16dd61898059efffc03;p=lhc%2Fweb%2Fwiklou.git 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. --- 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();