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!
http://forum.virtuemart.net/index.php?topic=99383.msg328217 (http://forum.virtuemart.net/index.php?topic=99383.msg328217) - It works
Yes RuBAN it's an old annoying bug however regardless its age and proposed fix they've not fixed it yet :-(
? 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?
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.
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]
which file?
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)
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.
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.
$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
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.
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.
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
marcodelpercio,
does this happen on a migrated site that vmart was migrated first, and then Joomla was migrated to 2.5/1.7 ?
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.
did you user id's change at all?
do you allow joomla registration?
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.
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
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.
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
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
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.
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
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
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.
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.