Skip to content

updateLogin(): get_object_data() result destructured wrongly, "Undefined array key" warnings on every user save #538

Open

Description

@caseysoftware

Summary

w2p_Extensions_Permissions::updateLogin() (classes/w2p/Extensions/Permissions.class.php, line 142 on master and dev-5.0.0) unpacks the result of get_object_data() as if it were a single row:

list($notUsed, $notUsed2, $notUsed3, $oname, $notUsed4) = $this->get_object_data($id, 'aro');
if ($oname != $username) {
    $res = $this->edit_object($id, 'user', $username, $login, 1, 0, 'aro');
    ...
}
return $res;

get_object_data() returns a list of rows (other callers use $aro_info[0][0], $mod_info[0][1]), so list() reads keys 0-4 of the outer array. Only key 0 exists.

Effects

  • PHP logs Undefined array key 1 … 4 every time a user is stored (CUser::store() calls updateLogin()).
  • $oname is always null, so the ARO is rewritten on every save, even when the username hasn't changed.
  • If the comparison ever matched, $res would be undefined at return $res;.

Seen in the PHP log while testing GHSA-qqx6-f7cc-3wf2 on a fresh install (PHP 8.3.6, MariaDB).

Suggested fix

$data = $this->get_object_data($id, 'aro');
$oname = $data[0][3] ?? null;
$res = true;
if ($oname != $username) {
    $res = $this->edit_object($id, 'user', $username, $login, 1, 0, 'aro');
    ...
}
return $res;

Low severity, small fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions