Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
After installing Permissions Grid, attempting to display the permissions form (/admin/people/permissions) results in this error:
PDOException: SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for integer: "" LINE 4: WHERE (rid = '') ^: SELECT r.* FROM {role} r WHERE (rid = :db_condition_placeholder_0) ; Array ( [:db_condition_placeholder_0] => ) in user_role_load() (line 2912 of /home/profilees/public_html/modules/user/user.module).
It appears that user_role_load is being called with a $rid of an empty string. PostgreSQL won't do an integer = string comparison. I'm not yet sure where this is coming from.
Comment | File | Size | Author |
---|---|---|---|
#7 | permission_grid-error_in_postgrsql-2069397-7.patch | 450 bytes | adriancid |
Comments
Comment #1
Ben Coleman CreditAttribution: Ben Coleman commentedI've been trying to dig into this. I put a ddebug_backtrace into user_role_load. The results of the backtrace:
Looks like the problem is in permissions_grid.admin.inc, but I haven't been able to figure out what yet.
Comment #2
joachim CreditAttribution: joachim commentedI don't see how code in permissions_grid.admin.inc could be breaking the core permissions form. This module doesn't alter that form.
Comment #3
Ben Coleman CreditAttribution: Ben Coleman commentedFrom the backtrace, it doesn't look like it's happening in the form, but in menu code. From what I read of the backtrace, the last 'public' function called is menu_local_tasks (numbered 15 in the backtrace). The internal function _menu_load_object (numbered 17 in the backtrace) is being called with the $item argument an array decidedly pointing to permission_grid (include_file contains 'sites/all/modules/permission_grid/permissions_grid.admin.inc', path contains 'admin/people/permissions/grid/%', you can see plenty more in the traceback above).
For testing purposes, I created a new Drupal site, using PostgreSQL, and added only the Permissions Grid module, everything else just the standard Drupal install. Once that was done, just clicking on the People button in the task bar produced the error in the Issue Summary.
MySQL doesn't produce an error on this, because if you pass compare a string to a numeric field, MySQL will silently convert the string to a number. PostgreSQL and other databases are more picky. If you don't have access to PostgreSQL and want to reproduce the backtrace I have above, add these lines (temporarily, for testing purposes):
to the beginning of the user_role_load function in module/user/user.module, and then select the People link in the task bar. You'll get the same backtrace I put in comment #1 (except it will probably be easier to read), you just won't get the error I get on PostgreSQL). I did build a test MySQL-based Drupal site here, with Permissions Menu installed, and I get the backtrace. Note that $rid should be a number (being a Role Id number), so it being equal to an empty string is an error.
Comment #4
Ben Coleman CreditAttribution: Ben Coleman commentedA bit more digging. This appears to have something to do with the autoloader wildcard %user_role in the second menu entry in permission_grid_menu. Evidently, this gets processed somehow before the form is even called (actually, it gets processed for admin/people/permissions or any submenu, apparently as part of menu handling), even if there is no part of the url corresponding to the wildcard. In the latter case, an empty string is passed as the role id, and PostgreSQL complains. You haven't seen this because MySQL doesn't complain about being handed an empty string for a number.
Comment #5
joachim CreditAttribution: joachim commentedThis is because 'admin/people/permissions/grid/%user_role' is correctly having its tab_root set as 'admin/people/permissions'. And when you're there, menu_local_tasks() loads all tabs beneath the current menu item.
This is either:
- a bug in core, because _menu_translate() tries to load menu items it has no map items for
- a bug in core, because user_role_load() should allow for an empty $rid
- a bug in this module because I've misused tabs here (which I have to say is likely!)
While I have a think about this, you can fix the problem by removing the "'type' => MENU_LOCAL_TASK," from the 'admin/people/permissions/grid/%user_role' menu item.
Comment #6
adriancidAs @joachim says, it works changing your implementation of hook_menu in permission_grid.module to:
Comment #7
adriancidHere is the patch
Comment #8
adriancid