1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.4 Maximum execution time exceeded when rebuilding thumbnails

Discussion in 'Troubleshooting and Problems' started by Optic, Dec 6, 2014.

  1. Optic

    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:
    ErrorExceptionFatal ErrorMaximum execution time of 120 seconds exceeded library/XenForo/Image/ImageMagick/Pecl.php:310
    Generated By
    Optic6 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:
    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: Dec 6, 2014
  2. Tracy Perry

    Tracy Perry Well-Known Member

    Increase the execution time in your php.ini?
    What are the specs on the VPS or server you are on?
  3. Optic

    Optic Well-Known Member

    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: Dec 6, 2014
  4. Optic

    Optic Well-Known Member

    Found a workaround.

    Added this to the top of the Pecl.php file and it's going smoothly now:
  5. Chris D

    Chris D XenForo Developer Staff Member

    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:


    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.
    audiokid likes this.
  6. Tracy Perry

    Tracy Perry Well-Known Member

    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.
    karll likes this.
  7. Optic

    Optic Well-Known Member

    Thank you so much @Tracy Perry and @Chris D for your valuable insights.

    I've reverted that line and will experiment with tweaking the number of items per page setting the next time I rebuild thumbnails.
  8. audiokid

    audiokid Active Member

    I've tried lowering my value to 60 and it still times out at 120 secs.
  9. audiokid

    audiokid Active Member

    I set a new time limit:
    > set_time_limit(480);
    in Pecl.php.

    Now fixed.
    karll and XboxAR like this.
  10. karll

    karll Well-Known Member

    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.

Share This Page