I recently noticed over 300,000 entries in my watchdog table with a record of:
`location`: "http://*/user/register"
`message`: "array_shift() [function.array-shift]: The argument should be an array in /*/includes/form.inc on line 487."
Each time I tried to register a new user in Firefox, my watchdog table added just over 5000 of these errors. If I used Internet Explorer, it would add just over 10,000 of these errors. This caused me great trouble just trying to click the "administer" menu item and often wouldn't even come up due to the large number of messages to show.
This huge quantity of duplicate records was followed by:
`location`: "http://*/user/register"
`message`: "500.shtml not found"
After deleting the array_shift messages in mysql, I also found that each chunk of array_shift messages was preceded by:
`location`: "http://*/user/register"
`message`: "Invalid argument supplied for foreach() in /*/includes/form.inc on line 350."
The actual symptoms users see of the problem are that they cannot create a new account; it returns "Page not found" to anyone attempting that. When I click "my account" as admin, I get my the expected information along with all the profile data, but there is also a red warning message at the top of the page that states, "warning: Invalid argument supplied for foreach() in /*/modules/user.module on line 1490." This step of viewing my account details does not introduce anything new in the watchdog tables. Trying to edit my account, though, returns the "Page not found" node and the 5,000 array_shift messages as described above. This happened the same way for admin and also for another user I used for troubleshooting.
I went in to add comments to some other pages and was able to do that successfully. Creating pages and stories works flawlessly as well. Those forms are using the same engine and many of the same elements without a problem.
Some additional information: I have been hacking around with a custom module for my own use that provides custom reporting. It pulls information from the `profile_values` table and combines it with information from several other custom tables. While this reporting is all read-only and isolated in its own module and its own menus, I have edited some values in the database directly while playing with this code. It's possible that I've created some data in terms of NULL values or special characters or something that's choking drupal's code.
I saw numerous mentions of this problem, or similar problems on the boards, but they all had small pieces of information and no solutions. I intend to research what I can and assemble that information here, then guide those other posts in this direction for information. Hopefully future sufferers of this problem will more easily find the information and solution.
I looked at the code referenced in the previous messages, not with the intent to change it since it's all core code that worked last week, but with the intent to see if I could temporarily add some debug information to display, or just to see what it may be choking on.
form.inc: 350
foreach ($form['#parents'] as $parent) { ... }
form.inc: 487
$parent = array_shift($parents);
and the warning in "my account" that may lead us somewhere
user.module: 1490 (1488 - 1490 displayed)
foreach (module_list() as $module) {
if ($data = module_invoke($module, 'user', 'view', '', $account)) {
foreach ($data as $category => $items) {
This is the problem in as much detail as I think I can muster. I will post troubleshooting steps, and I will hopefully post a solution later today. My web site can add no users until I figure this out!!
Comments
Turning off my custom module fixed the problem
I turned off my custom module, even though I couldn't imagine it impacting anything in the new user stuff. (I had no hooks that I believed would be called there.) Everything seems to work well at this point. I will dig into my module and post the offending code/data as soon as I find it.
-Mike
Did you ever figure out what
Did you ever figure out what was causing your array_shift() error? I'm having the same problem, but I turned off the custom modules that I thought would be causing the problem and no cigar.
Ah nevermind. I found my
Ah nevermind. I found my problem. It was a hook_user invokation in one of my modules that I had modified that was causing the problem. The reason why the error was happening was because that hook_user invokation is called on any page that follows the URL path of /drupal/user/x/, which includes /drupal/user/x/edit and other variants. There was some code that would only work when viewing the user profile, but not when editing.