3

I'm trying to reindex my catalog_url_rewrite table (Magento website) through the command line using the command "php indexer.php --reindex catalog_url" in /shell. I get the following error:

PHP Fatal error:  Maximum execution time of 60 seconds exceeded in /var/www/domain.com/lib/Zend/Db/Statement.php on line 141

The file and line on the error varies.

I've double checked to confirm that php in the command line is indeed using the php-cli version (by using "php -i") and that there are no limits in its config that should yield such an error.

I've also looked around to see if any magento file is setting the "set_time_limit" manually, but couldn't find anything that points that way. I can't find the 60 seconds max_execution_time anywhere.

Any idea on what's going on?

Edit:

So far I've tried:

  • Running "php -d max_execution_time=0 indexer.php --reindex catalog_url"
  • Setting "set_time_limit(9000);" on indexer.php directly.
  • Running "php -i" to see "Configuration File (php.ini) Path => /etc/php5/cli" & "Loaded Configuration File => /etc/php5/cli/php.ini"
  • Setting max_execution_time on fpm's php.ini to 61 just to see if it was using it by accident.
  • Made sure "set_time_limit(60)" is not hardcoded anywhere in the magento framework.
8

I've run into this. The issue is that shell scripts extending Mage_Shell_Abstract inherit behaviour that applies PHP ini settings parsed from Magento's .htaccess file.

Take a look at the method protected function _applyPhpVariables() in shell/abstract.php.

Easiest fix, is to just edit .htaccess and comment out the php_value directives for execution_time and or memory_limit. Alternatively you can extend the indexer by overriding the applyPhpVariables() method and stop it processing the .htaccess.

I made sizeable donations to my swear jar when I first discovered this 'feature'.

  • 2
    "Catalog URL Rewrites index was rebuilt successfully" Holy sh** man, what a savior! Such a strange behavior, never would have thought of that. I just commented out the whole function and it worked like a charm. If I'm ever in London I'm making sure to buy you a beer. – Pedro Peixoto Oct 30 '13 at 17:24
  • 1
    This is good to know and nice work super sleuthing! Now I'm curious why I've never run into this since I've had index jobs that easily run up to 4 hrs after a full-import of 5-million products. Guess I've got some digging to do to satisfy my curiosity. :D – davidalger Oct 30 '13 at 17:34
5

Try running this from the root of Magento installation:

php -d max_execution_time=0 ./shell/indexer.php --reindex catalog_url

If this command fails with that same error, then something crazy is going on. :)

  • 1
    This is nicely done. reindexall is another valid option to be passed. – philwinkle Oct 29 '13 at 13:54
  • Yea someone suggested the same over at stackoverflow, but I still get the same error. There is indeed something crazy going on and I can't figure out what. – Pedro Peixoto Oct 29 '13 at 14:38
  • Out of curiosity, what version of PHP do you have? Could you post the output of php --version – davidalger Oct 30 '13 at 2:34
  • 1
    Also is this a shared host or a dedicated environment you have full control over? – davidalger Oct 30 '13 at 2:35
  • 1
    Yea I was stumped too, but check the accepted answer below to see the solution. – Pedro Peixoto Oct 30 '13 at 17:25
1

One thing to point out is that Magento shell commands parse the htaccess file and will apply settings (such as time limit) that it finds. I would check your htaccess file.

See this post I wrote a while ago: http://edmondscommerce.github.io/magento/magento-shell-scripts-and-memory-limit-woes-solution.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.