Last modified: 2014-03-20 17:57:59 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T64029, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 62029 - Saving preferences with returning "false" from allowRealNameChange() in AuthPlugin.php causing "Undefined index: realname"
Saving preferences with returning "false" from allowRealNameChange() in AuthP...
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
User preferences (Other open bugs)
1.22.2
All All
: Normal normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2014-02-28 00:58 UTC by Kai
Modified: 2014-03-20 17:57 UTC (History)
4 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Kai 2014-02-28 00:58:48 UTC
If a sysop doesn't want a user can change his realname (because its set by extend authPlugin) and adds a allowRealNameChange(), which returns false, to the AuthPlugin.php, you get a php notice "Undefined index: realname in Preferences.php line 1439".

If allowPropChange() or allowRealNameChange() from AuthPlugin.php return false then there is a missing key 'realname' in $formData. 
This causes the mentioned warning and an empty realname string for the user. 
This should either be checked before saving or the index should include the old realname by default.

Workaround for me: Edit Preferences.php like this:

Preferences.php line 1436
// Fortunately, the realname field is MUCH simpler
// (not really "private", but still shouldn't be edited without permission)
  if ( !in_array( 'realname', $wgHiddenPrefs ) && $user->isAllowed( 'editmyprivateinfo' ) ) {
    if (!array_key_exists('realname', $formData)) {
      $formData['realname'] = $user->getRealname();
    }

    $realName = $formData['realname'];
    $user->setRealName( $realName );
  }


Message in error.log:
PHP Notice:  Undefined index: realname in /srv/web/wiki.xxxxxx.org/public/mediawiki-1.22.2/includes/Preferences.php on line 1439, referer: http://wiki.xxxxxx.org/wiki/Spezial:Einstellungen
Comment 1 Andre Klapper 2014-02-28 12:47:01 UTC
fx-eckart: Thanks for taking the time to report this!
Would you be willing to turn the code snippet into a patch?
You are welcome to use Developer access
  https://www.mediawiki.org/wiki/Developer_access
to submit this as a Git branch directly into Gerrit:
  https://www.mediawiki.org/wiki/Git/Tutorial
Comment 2 Kai 2014-03-01 17:57:00 UTC
let me figure out first how the creepy git/gerrit works on wikimedia ;)
Comment 3 Gerrit Notification Bot 2014-03-02 16:30:11 UTC
Change 116282 had a related patch set uploaded by GBT248:
Preferences.php: avoid "Undefined index" if key 'realname' don't exist in $formdata Added additional check for missing key "realname" in $formData which can cause an undefined index: realname (see bug 62029 fo details)

https://gerrit.wikimedia.org/r/116282
Comment 4 Gerrit Notification Bot 2014-03-02 16:33:21 UTC
Change 116282 had a related patch set uploaded by Alex Monk:
Preferences.php: avoid "Undefined index" if key 'realname' don't exist in $formdata

https://gerrit.wikimedia.org/r/116282
Comment 5 Kai 2014-03-03 10:30:57 UTC
New patch set uploaded 12h ago (
don't know why it hasn't announced here by gerrit):

https://gerrit.wikimedia.org/r/116282
Comment 6 Andre Klapper 2014-03-03 11:21:55 UTC
(In reply to Kai from comment #5)
> don't know why it hasn't announced here by gerrit):

because it shouldn't.
Comment 7 Gerrit Notification Bot 2014-03-19 22:53:34 UTC
Change 116282 merged by jenkins-bot:
Preferences.php: avoid "Undefined index" if key 'realname' don't exist in $formdata

https://gerrit.wikimedia.org/r/116282
Comment 8 Umherirrender 2014-03-20 17:57:59 UTC
was successfully merged

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links