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

Error on deleting orders from history

Started by shopper999, December 23, 2013, 18:01:52 PM

Previous topic - Next topic

shopper999

Hi everbody,

i am using Virtuemart  2.0.26a on Joomla  2.5.17 with PHP 5.4.4-14+deb7u7 on an Apache Webserver.
If I try to delete an order under "Orders & Shoppers -> Orders",
I get an PHP error (I already give the process 512 MB RAM).


mod_fcgid: stderr: PHP Fatal error:  Allowed memory size of 536870912 bytes exhausted (tried to allocate 64 bytes) in /srv/www/webxxx/html/foo.bar/cms/libraries/joomla/language/language.php on line 347, referer: https://www.foo.bar/administrator/index.php?option=com_virtuemart&view=orders


This only happens to some orders, not all orders on deleting.

What's wrong here?

Thanks in advance

Jumbo!

Probably the order that you are trying to delete has too many products and too many order history. That is why it requires greater RAM capacity to execute the function. You will probably need to allocate more RAM or just manually drop those rows from the database.

shopper999

The order has only one article, and I already increased to 800 MB RAM.
The whole database has only 3 MB.

I don't think it's a RAM problem. It looks more like a bug.

Sometimes the error is thrown by the loader.php only on deleting an order.

mod_fcgid: stderr: PHP Fatal error:  Allowed memory size of 536870912 bytes exhausted (tried to allocate 130968 bytes) in /srv/www/webXXX/html/foo.bar/cms/libraries/loader.php on line 366, referer: https://www.foo.bar/administrator/index.php


Deleting rows from db could be an option for a developer, but not for an end user.
The database contains items for an order in many tables, and it must be consistant.

Greetings

shopper999

This error seems to appear in the following case:

Someone registred to place an order.
The user was deleted from the joomla user database.
If I delete an order of this (deleted user), the error appears with this screen of death.

This is an processing error in virtuemart, because the system is not useable any more.

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/

Jythra

I have the same errors.
But I also get them in the frontend on registration through the cart and when I try to change the status of an order. Increasing the RAM will only increase the numers in the error.

Regards,

Rachel

Milbo

I am sorry, I was not able to reproduce it.  I took an existing order and changed the user_id to some not existing and I could delete the order without any problems and the database is also correctly updated.
Do you use some plugins?
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

shopper999

It's not so easy to really reproduce the problem.
OK, I think it doesn't really have anything to do with the deleted user, sorry. This was my first impression.
I tried to reproduce it for hours now.

This problem seems to be related to the problem discussed here:
http://forum.virtuemart.net/index.php?topic=121149.0
because in both cases, I get the same erros (on changing the order status, or on deleting an order).

The order has the status "confirmed by shopper". The order can be paid by paypal or standard.
So I don't think it a problem of a plugin, an for VM I only use the standard (and AIO).



   
If i change the status to "confirmed"!! (and only when "Notify Shopper" is ticked") and click "update order stats", i get the error
Quote
Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 118 bytes) in /srv/www/webXXX/html/foo.bar/cms/administrator/components/com_virtuemart/helpers/config.php on line 202

After reloading the page, I get
Quote
Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 130968 bytes) in /srv/www/webXXX/html/foo.bar/cms/libraries/joomla/client/helper.php on line 168


If I now look at the order list, i can see the status "confirmed".

Now, I try to delete the order:
Quote
Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 64 bytes) in /srv/www/webXXX/html/foo.bar/cms/libraries/joomla/language/language.php on line 347
After reloading the page, I get
Quote
Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 130968 bytes) in /srv/www/webXXX/html/foo.bar/cms/libraries/loader.php on line 366

During this time, the db seems to get corrupt, because the products are already deleted from the shopping list, but the order itself is still present.
In the end: The errors tell us to increase memory. But I also tried it this nearly 1 GB memory. The error is still present, so the problem must be elsewhere.


By testing all possible causes, I got a second error (independent from the one above, also tested on another VM installation):
If you delete the payment method from the shop e.g. paypal, and try to delete the orders, which were sold by paypal, then the order cannot be deleted,
and the db get corrupted (see order details).


Milbo

Please look here http://forum.virtuemart.net/index.php?topic=121213.0

I think it has something todo with your product. Do your products have multiple prices? related products? related categories and similar?
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

shopper999

Every product in allocated to just a single category. (I have many categories, but each product has only one category allocated).
Each product has only a single price.
I do not use any product variants.

I do use some user defined folders for my products.


OK, perhaps this may help a bit.
I am not a joomla or VM developer, but I think, there is a loop somewhere, which makes this memory problem.
Because in all problems posted, the loader.php seems to make strange things in line 366.

I changed the function in "libraries/loader.php" to give me some more information about what is being imported.

function jimport($path)
{
error_log($path);
        return JLoader::import($path);
}


When I delete my orders, which make the problem, the script seems to be in an endless loop of importing

joomla.filesystem.file
joomla.utilities.date
joomla.filesystem.folder


The last successfull imports before the loop starts (on delting an order) is

joomla.application.module.helper
joomla.utilities.utility
joomla.html.pagination
joomla.application.component.controller
joomla.application.component.controller
joomla.application.component.model
joomla.filesystem.path
joomla.utilities.arrayhelper
joomla.database.table
joomla.filesystem.path
joomla.user.user
joomla.filesystem.path
joomla.filesystem.file
joomla.utilities.date
joomla.filesystem.folder

joomla.filesystem.file
joomla.utilities.date
joomla.filesystem.folder

...


Perhaps this may help the developers as a first hint.

shopper999

I changed the loader.php once more, to get more information about the function, which is calling the jimport function:


function jimport($path)
{
$inhalt="";

$erg=debug_backtrace();

if (isset($erg)) {
$inhalt.= "import: $path \n";

$max_depth = 8;
   for ($i=0; ($i < sizeof($erg)) && ($i < $max_depth); $i++) {
      if (isset($erg[$i]["file"])) {
         $inhalt.= $erg[$i]["file"]." - function: ".$erg[$i]["function"]." - line: ".$erg[$i]["line"]."\n";
      }
   }
}
$inhalt.= "-----------------------------------------------------------------------------------------------------\n";

file_put_contents("../../logging.txt", $inhalt, FILE_APPEND | LOCK_EX);

        return JLoader::import($path);
}



The output on deleting an order, which causes memory problem in loader.php on line 366

import: joomla.filesystem.file
/srv/www/webXXX/html/foo.bar/administrator/components/com_virtuemart/helpers/config.php - function: jimport - line: 363
/srv/www/webXXX/html/foo.bar/administrator/components/com_virtuemart/helpers/config.php - function: logInfo - line: 207
/srv/www/webXXX/html/foo.bar/administrator/components/com_virtuemart/helpers/config.php - function: vmError - line: 395
/srv/www/webXXX/html/foo.bar/administrator/components/com_virtuemart/helpers/config.php - function: logInfo - line: 207
/srv/www/webXXX/html/foo.bar/administrator/components/com_virtuemart/helpers/config.php - function: vmError - line: 395
/srv/www/webXXX/html/foo.bar/administrator/components/com_virtuemart/helpers/config.php - function: logInfo - line: 207
/srv/www/webXXX/html/foo.bar/administrator/components/com_virtuemart/helpers/config.php - function: vmError - line: 395
/srv/www/webXXX/html/foo.bar/administrator/components/com_virtuemart/helpers/config.php - function: logInfo - line: 207
-----------------------------------------------------------------------------------------------------
import: joomla.utilities.date
/srv/www/webXXX/html/foo.bar/libraries/joomla/factory.php - function: jimport - line: 519
/srv/www/webXXX/html/foo.bar/administrator/components/com_virtuemart/helpers/config.php - function: getDate - line: 372
/srv/www/webXXX/html/foo.bar/administrator/components/com_virtuemart/helpers/config.php - function: logInfo - line: 207
/srv/www/webXXX/html/foo.bar/administrator/components/com_virtuemart/helpers/config.php - function: vmError - line: 395
/srv/www/webXXX/html/foo.bar/administrator/components/com_virtuemart/helpers/config.php - function: logInfo - line: 207
/srv/www/webXXX/html/foo.bar/administrator/components/com_virtuemart/helpers/config.php - function: vmError - line: 395
/srv/www/webXXX/html/foo.bar/administrator/components/com_virtuemart/helpers/config.php - function: logInfo - line: 207
/srv/www/webXXX/html/foo.bar/administrator/components/com_virtuemart/helpers/config.php - function: vmError - line: 395
-----------------------------------------------------------------------------------------------------
import: joomla.filesystem.folder
/srv/www/webXXX/html/foo.bar/administrator/components/com_virtuemart/helpers/config.php - function: jimport - line: 377
/srv/www/webXXX/html/foo.bar/administrator/components/com_virtuemart/helpers/config.php - function: logInfo - line: 207
/srv/www/webXXX/html/foo.bar/administrator/components/com_virtuemart/helpers/config.php - function: vmError - line: 395
/srv/www/webXXX/html/foo.bar/administrator/components/com_virtuemart/helpers/config.php - function: logInfo - line: 207
/srv/www/webXXX/html/foo.bar/administrator/components/com_virtuemart/helpers/config.php - function: vmError - line: 395
/srv/www/webXXX/html/foo.bar/administrator/components/com_virtuemart/helpers/config.php - function: logInfo - line: 207
/srv/www/webXXX/html/foo.bar/administrator/components/com_virtuemart/helpers/config.php - function: vmError - line: 395
/srv/www/webXXX/html/foo.bar/administrator/components/com_virtuemart/helpers/config.php - function: logInfo - line: 207
-----------------------------------------------------------------------------------------------------

shopper999

If I comment out the line 207

// logInfo($adminmsg,'error');

in the file "administrator/components/com_virtuemart/helpers/config.php", I get a good error message in VM, and no memory-leak or server-error.

        vmError: VirtueMartModelOrders::remove 1
        Orders could not be deleted.


After digging deeper, why this causes the error, I had a look at the function "logInfo".
The debug trace said it was on line "function: vmError - line: 395".

vmError('Could not use path '.$file.' to store log');


ok, so what is in "$file" ?

I inserted an

error_log($file);

on line 371, and see...


/srv/www/webXXX/html/foo.bar/logs/com_virtuemart.log.php


Is this correct?

OK, back to the beginning.

Solution:
If I create a blank file "/logs/com_virtuemart.log.php", I do not have memory-leaks any more...

Besides this, I still have the problem, that I cannot delete my order, but no endless loops.
Perhaps the cause of the "cannot delete" error can have another reason, e.g. "payment method" was deleted after order placed?!





Milbo

#12
We are sorry for this. Rename and use the attached file for "C:\Users\Milbo\Coden\_workspace\VM2014mp\administrator\components\com_virtuemart\helpers"

The reasons are the file permissions not allowing to create the vm log file. In this case, you must manually create a file "/logs/com_virtuemart.log.php", and add at begin of the file

if( !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );


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

shopper999

Thank you milbo, for the corrected file.
If there is no manually created file "/logs/com_virtuemart.log.php", it gets now created by your new code (so permissions are OK), but without the security mechanism.

if( !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );

Milbo

Thank you, please try this one

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