XF 1.4 Maximum execution time exceeded when rebuilding thumbnails

Optic

Well-known member
I recently changed the image processor from GD to ImageMagick PECL. After doing this I can no longer gracefully rebuild attachment thumbnails, I get a 503 LiteSpeed error.

This server error appears:
PHP:
ErrorException: Fatal Error: Maximum execution time of 120 seconds exceeded - library/XenForo/Image/ImageMagick/Pecl.php:310
Generated By: Optic, 6 minutes ago
Stack Trace
#0 [internal function]: XenForo_Application::handleFatalError()
#1 {main}
Request State
array(3) {
  ["url"] => string(51) "http://animeforums.net/admin.php?tools/run-deferred"
  ["_GET"] => array(1) {
    ["tools/run-deferred"] => string(0) ""
  }
  ["_POST"] => array(3) {
    ["redirect"] => string(56) "http://animeforums.net/admin.php?tools/rebuild&success=1"
    ["execute"] => string(1) "1"
    ["_xfToken"] => string(8) "********"
  }
}

If I return to the Admin CP the following message appears:
There are manual rebuild processes that have been stopped before completion. Click here to complete them.

Clicking that appears to resume the rebuild process, but shortly afterwards the 503 occurs again. If I repeat this cycle a few times eventually all the attachments finish rebuilding.

Does anyone have any ideas?

I'm using ImageMagick module versoin 6.5.4-7 2014-02-10 Q16 if that helps..
 
Last edited:
Increase the execution time in your php.ini?
What are the specs on the VPS or server you are on?
Thanks for your response Tracy.

I'm on the SSD2000 managed VPS plan on WiredTree.

It's peculiar because I set the max_execution_time awhile ago to 600, which should be 10 minutes right? Yet the error reports the maximum execution time to be 2 minutes... I set this particular value in WHM -> Tweak Settings -> PHP. Is it possible this value is maybe getting overridden elsewhere?
 
Last edited:
Changing the time limit and execution time is probably not the best way to handle it, there's definitely times where you won't want PHP to run tasks infinitely; so at least consider reverting that back when the task is done.

This is why there's a configuration step before rebuilding thumbs:

upload_2014-12-6_16-2-23.webp

Reduce it from 200 to something more manageable; even if it's as low as 10, that will drastically reduce the amount of time it takes on each page, and probably won't go near your max execution time.
 
Found a workaround.

Added this to the top of the Pecl.php file and it's going smoothly now:
PHP:
set_time_limit(0);
As Chris said.. you don't want it unlimited..
And yes, there is (especially if you are using cPanel and Apache) something probably over riding the actual php.ini. Even though I have a VPS set up with cPanel right now - I'm growing to hate it more and more.
With it being a VPS, they could be having problems with that server, or a container on that server utilizing more resources than necessary that causes a negative impact on your container.
If this is a managed plan, I'd suggest contacting them to have them take a look at it.
 
I just had the same issue (XF 1.5), and in the end I had to resort to editing the Pecl.php file as suggested above. I had previously tried rebuilding the attachment thumbnails with only 10 items per page, but even that failed. Editing Pecl.php and setting the time limit there solved the issue.
 
Top Bottom