VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: marcodelpercio on March 10, 2012, 19:34:01 PM

Title: JUser::_load: error bug when updating order status in backend [WITH HOW TO FIX]
Post by: marcodelpercio on March 10, 2012, 19:34:01 PM
Hi

The problem is very similar to the one signaled here: http://forum.virtuemart.net/index.php?topic=95636.0 (http://forum.virtuemart.net/index.php?topic=95636.0) however I am still experiencing it on Joomla 2.5.2 and VM 2.0.2 stable.
What is happening:
Whenever you try to update an order status from VM backend orders view you get an error JUser::_load: unable to load user with id: x but x is erroneously treated as a user id when actually it is the virtuemart order id!! So for example if you try to update order status of an order with id = 62 you'll get JUser::_load: unable to load user with id: 62 etc...

Root cause:
The root cause is the same of the other post, I'll explain more in details: in VM backend orders view the cid array attribute value passed via HTTP during the updatestatus task is actually the virtuemart_order_id. The order status is successfully updated however in the call stack this cid is erroneously interpreted as the user id and so the JUser class raises the error.
More in particular:
In VirtuemartControllerOrders::updatestatus()
    which invokes  VirtueMartModelOrders::updateOrderStatus()
        which invokes  updateStatusForOneOrder() 
           which invokes  notifyCustomer()
              which invokes shopFunctionsF::renderMail()
                 which invokes  sendVmMail()
                    which invokes  VirtuemartViewInvoice::renderMailLayout()
                       which invokes  display()

well in such display() function there's a piece of code like the following lines where VM is trying to get vendor details by user id


$userId = $vendorModel->getUserIdByVendorId($virtuemart_vendor_id);
$usermodel = VmModel::getModel('user');
$virtuemart_userinfo_id = $usermodel->getBTuserinfo_id($userId);

The problem is right there because even if you actually have the correct user id into the $userId variable, when you get user model instance with VmModel::getModel('user'); the default VmModel costructor sets the model id with the cid received in the request that in this case is NOT a user id, it's the ORDER ID. So 2 lines after on $usermodel->getUserInfoInUserFields the system is raising the described error since that usermodel has been instantiated with the wrong Id (the cid).

How to fix that:
Since the correct userId is in the $userId variable you just have to reset the correct id for the user model before invoking $usermodel->getUserInfoInUserFields
Like this for example:

$userId = $vendorModel->getUserIdByVendorId($virtuemart_vendor_id);
$usermodel = VmModel::getModel('user');
/* MY   FIX   STARTS   HERE */
if(Permissions::getInstance()->check("admin")) {
$usermodel->setId($userId);
}
/* MY   FIX   ENDS   HERE */
$virtuemart_userinfo_id = $usermodel->getBTuserinfo_id($userId);
$vendorFieldsArray = $usermodel->getUserInfoInUserFields($layout, 'BT', $virtuemart_userinfo_id, false);


Please try to fix that in the next release.
Regards
Marco Del Percio
Title: Re: JUser::_load: error bug when updating order status in backend [WITH HOW TO FIX]
Post by: Milbo on March 11, 2012, 16:08:06 PM
Can you please verify this with the latest version? 2.0.3b, I think we fixed it already.
Title: Re: JUser::_load: error bug when updating order status in backend [WITH HOW TO FIX]
Post by: marcodelpercio on April 17, 2012, 22:23:11 PM
I can't believe it's still there... I suggested FIX more than a month ago, since then 2 stable releases have been published and a lot of other users are complaining such error and it is still there!

Please fix it!!
Title: Re: JUser::_load: error bug when updating order status in backend [WITH HOW TO FIX]
Post by: nordmograph on May 18, 2012, 17:10:14 PM
Error still here in VM2.0.6
Title: Re: JUser::_load: error bug when updating order status in backend [WITH HOW TO FIX]
Post by: Milbo on May 18, 2012, 17:29:05 PM
Quote from: marcodelpercio on April 17, 2012, 22:23:11 PM
I can't believe it's still there...

Come on guy, you wrote at the 10. march, I answered at the 11. march,. ... no answer from you for more than a month and then a rant. lol.

and the user model is not anylonger using the cid, it is now taking the virtuemart_user_id, so,... I am wondering. and I dont get that error since months. hmm
Title: Re: JUser::_load: error bug when updating order status in backend [WITH HOW TO FIX]
Post by: nordmograph on May 18, 2012, 17:45:18 PM
Well the error is indeed on my 2.0.6

Here is a screenshot

[attachment cleanup by admin]
Title: Re: JUser::_load: error bug when updating order status in backend [WITH HOW TO FIX]
Post by: Milbo on May 18, 2012, 19:36:18 PM
and in 2.0.7c?
Title: Re: JUser::_load: error bug when updating order status in backend [WITH HOW TO FIX]
Post by: nordmograph on May 19, 2012, 11:44:21 AM
Good, seems to be fixed in 2.0.7c
Thanks
Title: Re: JUser::_load: error bug when updating order status in backend [WITH HOW TO FIX]
Post by: JulianWolf on August 06, 2012, 09:50:43 AM
Hi everybody,

bad luck: I´m on 2.0.8e and the error is still present for me. Even when a customer places an order, the error-message shows up on the front end.

Is there any solution comming?

All the best, Julian!
Title: Re: JUser::_load: error bug when updating order status in backend [WITH HOW TO FIX]
Post by: emel on September 09, 2012, 19:04:44 PM
i have this issue, and i am using 2.0.10

this is possibly caused by the fact that i have deleted the admin with id 42 since this method is widely known and explained over and over (safety reasons joomla)

what can i do now?
Title: Re: JUser::_load: error bug when updating order status in backend [WITH HOW TO FIX]
Post by: Milbo on September 09, 2012, 19:27:05 PM
You usually change your id first and then you install all other components. check the tables for the number 42
Title: Re: JUser::_load: error bug when updating order status in backend [WITH HOW TO FIX]
Post by: emel on September 10, 2012, 14:11:07 PM
so with php my admin i should do

"check the tables for the number 42 "

please a little bit more info, can you tell me exactly what to do here.... ?

thanx a million.
Title: Re: JUser::_load: error bug when updating order status in backend [WITH HOW TO FIX]
Post by: emel on September 10, 2012, 16:25:03 PM
update: i was advised by another forum to label the new admin as vendor, which i did. but still this error remains. would like a clear dummy explanation how to..... :/

THANX
Title: Re: JUser::_load: error bug when updating order status in backend [WITH HOW TO FIX]
Post by: Milbo on September 10, 2012, 20:11:18 PM
Search for the number 42 and change it to your new id.

Pay attention to vmusers table, your mainvendor should have is_vendor =1 and vendorid=1
Title: Re: JUser::_load: error bug when updating order status in backend [WITH HOW TO FIX]
Post by: emel on September 10, 2012, 22:21:38 PM
well, what i did... changed my new user id, back to ID42 :) and the error was/is gone :)

if this is really not done, or could lead to difficulties, please let me know :)
Title: Re: JUser::_load: error bug when updating order status in backend [WITH HOW TO FIX]
Post by: Milbo on September 10, 2012, 23:40:57 PM
You could try to use the tools to set the shopowner to another id
Title: Re: JUser::_load: error bug when updating order status in backend [WITH HOW TO FIX]
Post by: status101 on May 09, 2013, 12:11:06 PM
I know this is an old post, but I ran into this issue today and came across this post.  I have resloved it by resetting my super admin to ID 42, BUT this is generally not a good idea ( well Akeeba Admin tools does not think so! ) .. anyway,  Milbo said:

"You could try to use the tools to set the shopowner to another id"

I would love to do this, but what 'tools' do you use to set the shop owner to a different ID?  I have looked around and really cant find anything....