News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

JUser::_load: error bug when updating order status in backend [WITH HOW TO FIX]

Started by marcodelpercio, March 10, 2012, 19:34:01 PM

Previous topic - Next topic

marcodelpercio

Hi

The problem is very similar to the one signaled here: 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

Milbo

Can you please verify this with the latest version? 2.0.3b, I think we fixed it already.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

marcodelpercio

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!!


Milbo

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
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

nordmograph

Well the error is indeed on my 2.0.6

Here is a screenshot

[attachment cleanup by admin]

Milbo

Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/


JulianWolf

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!

emel

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?

Milbo

You usually change your id first and then you install all other components. check the tables for the number 42
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

emel

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.

emel

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

Milbo

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
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

emel

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 :)