I attempted to change the properties of a container that was imported by legacy_import. Whether I make no change to the container's properties or make changes, I get this error:

Fatal error: Maximum execution time of 30 seconds exceeded in /home/jacobson/public_html/webdev/modules/category/category.inc on line 904

Sometimes, the error is reported at line 905 instead of 904.

I do not get this error on any other part of my site.

Comments

Fajan’s picture

Title: PHP Timeout Changing Container Properties » PHP Timeout When Accessing Category Pages

I have a similar problem while accessing category pages within a container. I am able to access the container pages without a problem, however, accessing the individual category pages within the container returns a php timeout error. Same error everytime.

[quote]Fatal error: Maximum execution time of 30 seconds exceeded in
/home/blah blah/modules/category/category.inc on line 905[/quote]

Played around with the settings and I have isolated the problem to the "Show prev, next, and up links" settings in container properties. I have no problems accessing the individual categories when I have this setting disabled. I get the timeout otherwise when it is enabled for either linkage within the container or without.

Jaza’s picture

Hmm.. this sounds like a serious problem, but I've never encountered it myself. If two of you are having virtually identical experiences, though, it is clear that this bug is real.

What version of PHP are you guys running? I've only tested the category module with PHP4, and it's quite possible that this bug only occurs on PHP5.

And can you tell me exactly which modules in the category package you have enabled, and exactly what settings you've specified for the containers and the categories that you're having problems with. The more info you can give me about the conditions needed to reproduce the problem, the better.

The function on line 905 is one that category_display heavily depends upon for generating its 'prev' and 'next' links. So it makes sense that enabling the 'show prev, next, and up links' setting would make the bug appear.

Fajan’s picture

I'm running PHP 4.4.1 over here and am using the 5th Feb cvs version of category on top of a similarly dated cvs version of drupal (post 4.7beta4) in order to ensure compatability of your changes to the menu api. The module previously ran alright before the menu api change. When I am free, I will check out the module before the api change and run it on a virgin 4.7beta4 drupal core and see whether the problem still exists then.

jacobson’s picture

Ditto for me on the PHP and Category versions. I have disabled all the Category modules right now because I think that my attempt to import my taxonomy terms was causing some problems too. I think a fresh Drupal install followed by a manual recreation of my categories is going to be necessary.

Jaza’s picture

Status: Active » Needs review

This problem may be related to this one, which has possibly been fixed. Please check out latest version of the category package, and let us know if the problem is still around.

Jaza’s picture

Priority: Normal » Critical
Status: Needs review » Active

This problem clearly still exists: see http://drupal.org/node/54998

I am really frustrated by this problem - I am completely unable to reproduce it!!! If you can all please give me as much information as you can, it would be much appreciated.

We already know these things about the problem:
- it occurs on PHP4 and PHP5
- it is caused by the 'show prev, next, and up links' setting in category_display being enabled
- it happens because of an infinite loop in the _category_list_set_current() function

All that I need to know now is WHY THE HELL that loop is repeating infinitely. Believe me, I have looked at it - A LOT. And I see no reason why it should go on forever. I urge you to tell me everything you know:
- every setting you've applied to your categories and containers
- list all installed modules on your site
- if at all possible, please set up a test site on the web that I can look at, to investigate the problem myself

Jaza’s picture

Finally, I worked it out! This problem only occurs when you have a large number of categories / containers on your site. I just tried using the devel module to generate 100 containers, and 2,000 categories. I then turned on the 'show prev, next, and up links' for all the containers. I instantly saw the 'maximum execution time exceeded' error.

Looks like the logic behind the 'prev, next, and up links' as it is now simply does not scale. I'll have to look into redesigning the logic behind this, so that it is able to cope with a larger set of data.

Jaza’s picture

Status: Active » Fixed

Fix committed to HEAD.

Copy of CVS commit log, FYI:

This problem was occurring if multiple containers (say, 5+), all with a large amount of categories (say, 500+), were present on a site. The tree-parsing logic in the category system has been refactored: the category_get_trees() function has been removed; and category_get_tree() is now capable of generating a tree for the entire site's category structure, with only one SQL query. Category_get_trees_flat() is now calling category_get_tree() directly (as are several other functions), and nav links are being generated much more efficiently (tested with 5,000+ categories on a dev box).

It is still possible for a timeout to occur with nav links enabled, but it is much less likely. An extremely large number of categories and containers would now be needed for this to happen.

Anonymous’s picture

Status: Fixed » Closed (fixed)
Jaza’s picture

Version: » master

New fix committed to HEAD and 4.7.

This issue was not actually fixed before, but it is now! Turns out that the cause behind so many people getting the mysterious PHP timeout, was an issue with PHP's handling of internal array pointer changes when arrays get passed to a function by reference. See the comment that I've added to http://www.php.net/manual/en/function.current.php for more details.