JUser: :_load: Unable to load user with ID: 1

softforge

Member
I am using the Joomla User form plugin to create a user and log them in when someone completes a form. This works great unless they do not pass the validation in which case I get this error after the page reloads:

JUser: :_load: Unable to load user with ID: 1
In juser.php at around line 210, for some reason this returns 1:

Code:
$userid = (int) JArrayHelper::getValue($formModel->_data, $this->useridfield . '_raw');

My user element is hidden and I can see that the value is 0 when being submitted so I don't know why this returns 1. I have done a quick fix by changing the following line to this:

Code:
if ($userid > 1)

But this feels like a workaround. I updated from GitHub yesterday, any ideas?...
 
is the validation part of the form plugin's validation routines or an additonal element validation you added?
 
All the validations are element based. The only form plugin that has been setup is juser.

I have setup another form to create a different types of user which gives me this double error with an invalid submission:

Code:
JUser: :_load: User Array does not exist
JUser: :_load: User Array does not exist

Thanks for your help.
 
OK, I see what's happening. Looking for how to fix it atm.

For some reason the _raw value is an array after validation failure, which we cast to an int, in that line of code from juser.php you quoted in your first post.

-- hugh
 
I've raised a github issue on this:

https://github.com/Fabrik/fabrik/issues/728

... as I'm having problems working out just exactly why the user data remains as an array after a validation failure. I tried a bandaid in the juser code, to test to see if the user data is an array and if it is, extract that userid from that ... which fixes that error ... but just moves the problem further down the line, where it blows up in some other code.

-- hugh
 
Thanks Hugh. I've been experimenting as well and the array issue is strange. I have now added a php plugin to process the data after juser has run and that also gets an array from JRequest. To make matters worse, the array contains the logged in user's id not the id of the user that was just created (although the correct id gets stored in the database). I could do a DB query to get the correct id but it looks like the same issue so hopefully if you can fix it at the source, the correct id will be returned (as an int) by JRequest as well.
 
I think this is related, I've found in some cases a database join returns an Array with one item and sometimes an int in PHP form plugin scripts. I cant workout what causes one or the other (maybe filters?) but it feels like this may be a more fundamental problem with database-like elements sometime returning an Array when it should be an int.

I have done a workaround in my code for now but I hope this inconsistency can be tracked down...
 
It's in the issues list ... it'll get worked on as soon as we have time. I've done some more work on it, and it's not a trivial thing to fix. And yes, it is related to the join element code, as the user element extends the join element class.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top