Page MenuHomePhabricator

NetworkAuth: $u is undefined
Closed, ResolvedPublic

Description

Author: olaf

Description:
Patch to fix the bug.

When error reporting is turned on and I use the NetworkAuth extension, I get the following warning:

Notice: Undefined variable: u in (...)/extensions/NetworkAuth/NetworkAuth.php on line 123

As noted on the extensions talk page by user 朝彦 (Asahiko):

http://www.mediawiki.org/wiki/Extension_talk:NetworkAuth

this is caused by the usage of the function is_null($u) to check whether the variable $u contains something useful. However, when $u is not defined, this causes the warning. The solution is to replace is_null($u) by !isset($u).

I have attached a patch for NetworkAuth.php to solve the problem.


Version: unspecified
Severity: minor
URL: http://www.mediawiki.org/wiki/Extension_talk:NetworkAuth

attachment isset.patch ignored as obsolete

Details

Reference
bz32808

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 12:01 AM
bzimport set Reference to bz32808.
bzimport added a subscriber: Unknown Object (MLST).

Fixed with numerous other issues in r105184

olaf wrote:

Sorry, I have to reopen the bug. The fixes in r105184 have actually really messed up the code, as it changed the logics. I attach a patch that fixes the fix.

olaf wrote:

Patch that fixes the broken fix.

attachment fixfix.patch ignored as obsolete

(In reply to comment #2)

Sorry, I have to reopen the bug. The fixes in r105184 have actually really
messed up the code, as it changed the logics. I attach a patch that fixes the
fix.

It was done purposely as it was horrendously written, having empty cases and such, so I inverted the logic to tidy it up somewhat

After the followup in r105185 it's fine

olaf wrote:

Patch that fixes the (still) broken fix.

Sorry, but no, it's not fine.
The '!' in front of the User::isUsableName( $u->getName() ) is too much.
My patch furthermore puts all clause into one expression, which makes the whole thing more readble.

Attached: