I've got a view that generates a CSV report on user information. However, due to the size of the dataset it's causing the server to timeout. Is there some way that I can set the max_execution_time() or set_time_limit() just for this path?


If you're looking for a custom-code centric path. Both D7 & D8 provide a hook_views_pre_execute() hook. It will trigger prior to any view query execution.

You can hook into this function, inspect $view object for the particular view you're wanting to extend your PHP execution, then call the PHP function of your choice.

  • Ah interesting, never thought to use that hook for abitrary code execution, only for code relating the view itself. So I should be able to just run set_time_limit(0) within the hook? – Mrweiner Mar 21 at 22:02
  • Yup, if you look at the docs example, you can see it hinting at the same idea (noting an admin of heavy query). You should be able to execute any PHP code you need. As long as set_time_limit() is allowed on your host machine, you should be able to run it. – Shawn Conn Mar 21 at 22:30
  • 1
    Seems like the right way to do this in general, but hitting a timeout on cloudflare now. May just need to set something up through Batch API. Thanks for the suggestion, though! – Mrweiner Mar 21 at 23:16

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.