VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: RuBAN on March 22, 2012, 08:21:05 AM

Title: JUser::_load: Unable to load user with id:
Post by: RuBAN on March 22, 2012, 08:21:05 AM
Hello! If you try to change the status of orders I give out messages JUser :: _load: Unable to load user with id: N, where N is different each time. The site of two users with id 42 and 44 ..
How can I fix it?
Thanks in advance!
Title: Re: JUser::_load: Unable to load user with id:
Post by: RuBAN on March 22, 2012, 09:08:45 AM
http://forum.virtuemart.net/index.php?topic=99383.msg328217 (http://forum.virtuemart.net/index.php?topic=99383.msg328217) - It works
Title: Re: JUser::_load: Unable to load user with id:
Post by: marcodelpercio on April 17, 2012, 22:26:43 PM
Yes RuBAN it's an old annoying bug however regardless its age and proposed fix they've not fixed it yet :-(
Title: Re: JUser::_load: Unable to load user with id:
Post by: Milbo on April 17, 2012, 23:21:29 PM
? Imho this is fixed, maybe I missed a file, where it is missing? and why do you push up a thread already a month old?
Title: Re: JUser::_load: Unable to load user with id:
Post by: marcodelpercio on April 17, 2012, 23:27:31 PM
It is not fixed, I've just updated to VM stable 2.0.6 and it is still there, please look at the link above.
Title: Re: JUser::_load: Unable to load user with id:
Post by: marcodelpercio on April 17, 2012, 23:33:18 PM
This is a screenshot as proof...regardless of the language the error is clear enough, the same of a month ago.

[attachment cleanup by admin]
Title: Re: JUser::_load: Unable to load user with id:
Post by: Milbo on April 17, 2012, 23:33:21 PM
which file?
Title: Re: JUser::_load: Unable to load user with id:
Post by: marcodelpercio on April 17, 2012, 23:37:34 PM
It's components/com_virtuemart/views/invoice/view.html.php  Line 213 

Full explanation is here: http://forum.virtuemart.net/index.php?topic=99383.msg336282 (http://forum.virtuemart.net/index.php?topic=99383.msg336282)
Title: Re: JUser::_load: Unable to load user with id:
Post by: Milbo on April 17, 2012, 23:46:54 PM
I just had never this bug I changed the order status in the last days very often. I know the issue itself. But in invoices it is used with parameter and so the model id is not used.
Title: Re: JUser::_load: Unable to load user with id:
Post by: marcodelpercio on April 17, 2012, 23:52:25 PM
IMHO I trust you however from what I see VM is still confusing order id with user id, that's why I'm still getting the error. As you can see by the screenshot attached before I've fresh update of 2.0.6 stable on Joomla 2.5.4.

I just tried re-applying my workaround and it solves the problem however I'd like to remove hacks from component files.
Title: Re: JUser::_load: Unable to load user with id:
Post by: Milbo on April 18, 2012, 00:31:20 AM

$virtuemart_userinfo_id = $usermodel->getBTuserinfo_id($userId);


is only using the _id of the $usermodel when no id is given.


function getBTuserinfo_id($id = 0){
if(empty($this->_db)) $this->_db = JFactory::getDBO();

if($id == 0){
$id = $this->_id;
vmdebug('getBTuserinfo_id is '.$this->_id);
}

$q = 'SELECT `virtuemart_userinfo_id` FROM `#__virtuemart_userinfos` WHERE `virtuemart_user_id` = "' .(int)$id .'" AND `address_type`="BT" ';
$this->_db->setQuery($q);
return $this->_db->loadResult();
}
[code]

So I do not understand the reason
Title: Re: JUser::_load: Unable to load user with id:
Post by: marcodelpercio on April 18, 2012, 10:37:16 AM
Maybe I wasn't  clear enough or you didn't read what I wrote in http://forum.virtuemart.net/index.php?topic=99383.msg336282 (http://forum.virtuemart.net/index.php?topic=99383.msg336282)
The problem is not caused by getBTuserinfo_id rather the JUser::_load error is caused by $usermodel->getUserInfoInUserFields(... under it.
As I have already explained getUserInfoInUserFields is working on a usermodel instance whose id is wrongly set as the order id.

Try the following:
Open Orders view in backend and pick any order to change its state. Pay attention to the order id you're changing and save its changed status. VM will raise an error telling you JUser::_load: Unable to load user with id:X where X is exactly the order id of the order you're changing.

You may also try the following debug code to understand what is happening in VirtueMartModelUser constructor class


class VirtueMartModelUser extends VmModel {

/**
* Constructor for the user model.
*
* The user ID is read and detmimined if it is an array of ids or just one single id.
*/
function __construct(){
           /* DEBUG CODE HERE   START */
           $myFile = "VirtueMartModelUser.log";
           $fh = fopen($myFile, 'w') or die("can't open file");

           $stringData = "VirtueMartModelUser before parent_construct ID IS: " . $this->_id . "\n";
           fwrite($fh, $stringData);
           /* DEBUG CODE HERE   END */

parent::__construct();

           /* DEBUG CODE HERE   START */
           $stringData = "VirtueMartModelUser after parent_construct ID IS: " . $this->_id . "\n";
           fwrite($fh, $stringData);
           fclose($fh);
           /* DEBUG CODE HERE   END */

$this->setMainTable('vmusers');
$this->setToggleName('user_is_vendor');
$this->addvalidOrderingFieldName(array('ju.username','ju.name','sg.virtuemart_shoppergroup_id','shopper_group_name','shopper_group_desc') );
array_unshift($this->_validOrderingFieldName,'ju.id');
// $user = JFactory::getUser();
// $this->_id = $user->id;
}


As I have emphasized in previous post in components/com_virtuemart/views/invoice/view.html.php when $usermodel = VmModel::getModel('user'); gets invoked (in display method) this forces invocation of VirtueMartModelUser costructor which will actually construct the usermodel instance with wrong id. If you check the debug log file VirtueMartModelUser.log you'll notice that the returned VirtueMartModelUser instance will have user id = order id which is wrong and causes the described error.
Title: Re: JUser::_load: Unable to load user with id:
Post by: PRO on April 18, 2012, 11:12:46 AM
I got this when changing my superadmin id.

WHAT i had to do is change the table

   jos_user_usergroup_map

to reflect the new id.

Title: Re: JUser::_load: Unable to load user with id:
Post by: marcodelpercio on April 18, 2012, 11:24:11 AM
I'm not sure what does it matter superadmin id... anyway I proposed a fix looooong time ago http://forum.virtuemart.net/index.php?topic=99383.msg328217 (http://forum.virtuemart.net/index.php?topic=99383.msg328217) you actually already have the correct user id in the $userId variable exactly one row above...you simply have to set it using setId($userId); on the usermodel instance so that the usermodel instance has the correct id of the user.

I don't know if my suggested fix is the recommended way of doing it however it works, I'd just like to get rid of this error which is "surviving" after 2 stable releases and it is quite a common operation to change an order status. I'd like a hackless VM
Title: Re: JUser::_load: Unable to load user with id:
Post by: PRO on April 18, 2012, 11:37:48 AM
marcodelpercio,

does this happen on a  migrated site that vmart was migrated first, and then Joomla was migrated to 2.5/1.7 ?

Title: Re: JUser::_load: Unable to load user with id:
Post by: marcodelpercio on April 18, 2012, 12:00:00 PM
No, a plain Joomla 2.5 installation, now 2.5.4, I used to have VM 2.0.2 and I had such bug... then updated to 2.0.4, yesterday updated to 2.0.6 stable...bug is still there.
Title: Re: JUser::_load: Unable to load user with id:
Post by: PRO on April 18, 2012, 12:41:22 PM
did you user id's change at all?

do you allow joomla registration?

Title: Re: JUser::_load: Unable to load user with id:
Post by: marcodelpercio on April 18, 2012, 13:36:03 PM
I never change user id, try to avoid such kind of database hack it can be dangerous potentially for other extensions.
Yes Joomla registration is allowed.

I also tried bypassing completely frontend registration. If I create a new Registered user directly from Joomla backend and configure him as a Virtuemart regular shopper. It happens the same issue on any order confirmed by such user.
Title: Re: JUser::_load: Unable to load user with id:
Post by: zebrafilm on April 24, 2012, 20:56:28 PM
I can confirm the bug. J 2.54 with VM 2.00->2.02->2.04->2.06 upgrades.

It clearly shows up on all my VM2 installs when I change an order setting for example from pending to confirmed in the backend.

Bastiaan
Title: Re: JUser::_load: Unable to load user with id:
Post by: Milbo on April 24, 2012, 23:43:22 PM
The solution with setId is wrong. I changed something, is some days ago no. But changing the id of the user model to the vendor would show an hacking attempt.
Title: Re: JUser::_load: Unable to load user with id:
Post by: zebrafilm on April 25, 2012, 09:32:57 AM
Found a difference:

When I open my orders list and change the drop down, lets say from pending to completed and click straight away on the Update status button, all goes well.
But when I click the checkbox in front of the order (normal joomla behavior I would say) then the error pops up.

Guess thats why Milbo does not see it?

Bastiaan
Title: Re: JUser::_load: Unable to load user with id:
Post by: PRO on April 25, 2012, 15:42:57 PM
Quote from: zebrafilm on April 25, 2012, 09:32:57 AM
Found a difference:

When I open my orders list and change the drop down, lets say from pending to completed and click straight away on the Update status button, all goes well.
But when I click the checkbox in front of the order (normal joomla behavior I would say) then the error pops up.

Guess thats why Milbo does not see it?

Bastiaan

I just tested this, and do not get this
Title: Re: JUser::_load: Unable to load user with id:
Post by: just.timonych on April 27, 2012, 20:07:17 PM
Also, this problem has come to me...

As marcodelpercio has already said, when You try to change the order Status, You will see the error with User ID, but ID takes from the Order and not from user, that's why this error has been found.
User ID 48 and VM trying to find the user with ID 55(which the order ID)

Ok. But the problem may be appeared with the Orders of Buyes which has no account. Already tested.

Joomla 2.5.4 and Virtuemart 2.0.6

Begin from:
Joomla 2.5.3 and VM 2.0.2
-> Joomla 2.5.4 + VM 2.0.4, after Joomla 2.5.4 and VM 2.0.6

On first releases(2.0.2 and 20.4) I can't call to mind that this error has happened.
Title: Re: JUser::_load: Unable to load user with id:
Post by: PRO on April 27, 2012, 20:12:57 PM
Quote from: just.timonych on April 27, 2012, 20:07:17 PM

Ok. But the problem may be appeared with the Orders of Buyes which has no account. Already tested.



I think I asked this before, and got no response in the thread. I thought maybe that was it
Title: Re: JUser::_load: Unable to load user with id:
Post by: Tdoc on September 06, 2012, 14:44:34 PM
Good day

I would like to notify that this bug is still existing in version 10.0.10

(http://www.cathieriyne.net/error1) in back end as well as (http://www.cathieriyne.net/error2) in front end which is MUCH more annoying

I can not test the solution proposed earlier as I do not know which file with path to modify

Could a happy soul help me with that ??

in advance thanks

Tdoc
Title: Re: JUser::_load: Unable to load user with id:
Post by: Milbo on September 08, 2012, 17:21:44 PM
sorry, I cant replicate, did it now also with an anonymous user. How do you make it exactly?

I edited one order and changed it there. works.
I also used the checkboxes in the list for an order with registered and non registered user,.. works.
Title: Confirming this bug on 1.1.9 maintenance release.
Post by: Brunus on October 25, 2012, 09:18:04 AM
I had this bug 2 times, with the 1.1.9 maintenance release. It did not occur with previous releases in my case.
Then I confirm this bug as it replicates two times on my production website.
Would you think there will be a fix for 1.1.x branch ?
Thanks for any answers, even : "No" :)

Sincerely.