Hi guys,
After installing the CSNA module, latest version at 8866f85, without enabling any other API providers or CSNA sub-modules, with the admin user, I browsed to create a new user at admin/people/create (by clicking the Add user link on the People admin page) and got the following error message:
Notice: Undefined variable: items in theme_csna_providers() (line 256 of /sites/default/modules/csna/csna.module). Backtrace:
theme_csna_providers(Array) theme.inc:1142
theme('csna_providers', Array) csna.module:162
csna_form_alter(Array, Array, 'user_register_form') module.inc:1056
drupal_alter(Array, Array, Array, 'user_register_form') form.inc:1085
drupal_prepare_form('user_register_form', Array, Array) form.inc:340
drupal_build_form('user_register_form', Array) form.inc:131
drupal_get_form('user_register_form') user.admin.inc:14
user_admin('create')
call_user_func_array('user_admin', Array) menu.inc:517
menu_execute_active_handler() index.php:21
After taking a closer look at the code, as indicated in the error log message, it seems there is no proper handling in theme_csna_providers in case no providers are declared:
See csna.admin.inc, line 253:
<?php
function theme_csna_providers($providers) {
foreach ($providers as $provider_id => $provider) {
$items[] = l($provider['display_title'], 'csna/' . $provider_id, array('html' => TRUE));
}
return theme('item_list', array('items' => $items));
}
?>
If $providers is empty, then $items is undefined.
This would be fairly simple to solve for the time being by adding an initialization for $items:
$items = array();;
would pretty much do the trick to avoid the log error message.
However, this would maybe bring another feature request that should maybe be discussed in another ticket.
Would we really want to display the CSNA links on the Registration form (user_register_form), if it's the Create user form used by the administrator?
In short, would we need to display the CSNA links on the admin add user page as well? (It is also a user_register_form page).
I guess there would be several solutions for that, such as adding configuration settings to CSNA admin page to include or exclude certain form_ids, or simply choose to only display the links if user is anonymous, etc...
I would assume this could be further discussed in a different ticket, for the time being, we could try fixing the error log message with a simple and clean solution in code.
Please let me know if you would have any objections, questions, comments, recommendations, suggestions or issues on this bug report or on the feature request/idea, I would surely be glad to explain in more details.
Thanks very much for your feedback in advance.
Cheers!
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | Patch to fix notice error log message on Create user form page with admin user without any providers enabled. | 479 bytes | dydave |
Comments
Comment #1
dydave commentedQuick follow up on this ticket.
Please find attached to this comment a patch against the latest 7.x-1.x version at 8866f85 that should fix the error message/notice mentioned in this ticket summary: csna-notice-create-user-page-admin-no-providers-1908802-1.patch
This patch simply adds an initialization to the
$itemsvariable in thetheme_csna_providersfunction, in csna.module. With this initialization to empty array, if$itemsis passed totheme_listit should still be fine since theme_list wouldn't iterate on empty items (see theme_list code for more information).Patch has been tested and seems to work as expected: No more notice error log messages.
Please let me know if you would have any questions, objections, comments, suggestions, recommendations or concerns on the patch or the issue reported above, I would be glad to explain in more details or re-roll the patch if necessary.
I would greatly appreciate if you could take a look at the attached patch and potentially consider committing it to module's repository, it would certainly help improving overall module's usability and quality.
Lastly, I would be greatly interested in getting your opinion whether the CSNA links should be displayed on the admin Create user page or if you would have any other ideas about it.
Thanks in advance for your feedback, testing and answers.
Cheers!
Comment #2
alfababy commentedThanks DYdave,
I pushed your patch on e2a551a.
For this question, i opened the new ticket. Maybe we can discuss in it.
#1909288: Display the CSNA links on the Registration form (user_register_form) for administrator ?