Skip to content

Module install/remove: "Undefined array key" warnings from getUsersWithRole() and "Failed to remove module permission object" #548

Open

Description

@caseysoftware

Installing or removing any module logs these on 5.0.0-rc3 (master 8727ad5c, with full error reporting):

PHP Warning:  Undefined array key 1 in classes/w2p/Database/Query.class.php on line 1289
PHP Warning:  Undefined array key "" in classes/w2p/Database/Query.class.php on line 1289
classes/w2p/Extensions/Permissions.class.php(221): Failed to remove module permission object   (remove only)

Causes

  1. w2p_Extensions_Permissions::getUsersWithRole() calls loadHashList() on a one-column query (DISTINCT(g.aro_id)). With one column, loadHashList() reads $keys[1], which doesn't exist. It is called from recalcPermissions(), so every install, remove and full recalc logs the pair (about 10 times per request). The keys still come out right, so it is noise, not wrong data. Use loadColumn() and array_flip(), or select the column twice.
  2. A module's setup.php remove() ends with parent::remove(). w2p_System_Setup::remove() calls unregisterModule(), which deletes the gacl_axo row. Then domodsql calls w2p_System_Module::remove() → deleteModule(), which can't find the row any more and logs the failure. Only one of the two should remove it.

Recommended Fix

Have deleteModule() should remove the gacl_axo row.

Found while testing the Notebook add-on's install and remove.

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