Author Topic: JUser::_load: error bug when updating order status in backend [WITH HOW TO FIX]  (Read 7827 times)

marcodelpercio

  • Beginner
  • *
  • Posts: 35
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

Code: [Select]
$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:
Code: [Select]
$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

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9997
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Can you please verify this with the latest version? 2.0.3b, I think we fixed it already.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

marcodelpercio

  • Beginner
  • *
  • Posts: 35
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!!

nordmograph

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 169
  • VirtueMart Version: 3 on Joomla3
Error still here in VM2.0.6

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9997
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
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
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

nordmograph

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 169
  • VirtueMart Version: 3 on Joomla3
Well the error is indeed on my 2.0.6

Here is a screenshot

[attachment cleanup by admin]

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9997
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
and in 2.0.7c?
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

nordmograph

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 169
  • VirtueMart Version: 3 on Joomla3
Good, seems to be fixed in 2.0.7c
Thanks

JulianWolf

  • Beginner
  • *
  • Posts: 1
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

  • Jr. Member
  • **
  • Posts: 55
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

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9997
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
You usually change your id first and then you install all other components. check the tables for the number 42
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

emel

  • Jr. Member
  • **
  • Posts: 55
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

  • Jr. Member
  • **
  • Posts: 55
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

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9997
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
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
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

emel

  • Jr. Member
  • **
  • Posts: 55
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 :)