Skip to content

max_execution_time / set_time_limit is inconsistent across OSs and unhelpful on non-windows OSs #8567

Closed as not planned
@SpencerMalone

Description

@SpencerMalone

Description

The following code:

<?php

sleep(6000);
echo("hi");

Resulted in this output:

hi

But I expected this output instead:

Maximum execution time of <x> exceeded

While this is a documented limitation, I would like to argue that this should be reimplemented to match the windows implementation where it tracks the real time of the script.

  1. Max execution time being based on PHP's CPU time is unintuitive. When you set max execution time, nobody expects it to be PHP CPU time, making this an easy to trap where you think you've set yourself up to be safe against long running requests, and instead are still exposed to this failure mode.
  2. This behavior should be OS consistent. Having it inconsistent adds to operational confusion when working with PHP.
  3. If the expectation is that the SAPI be the one to handle "real" max execution time, then one of the oldest simplest SAPIs (apache's mod_php) does not have a way to handle this, and PHP CLI applications will be left in the dust, as they have no comparable way to manage max execution time.
  4. Max execution time being based on CPU time is not useful. If a request is running for 5+ minutes, I don't care if it's sleeping, stuck in a bad recursive loop, waiting on a bad mysql query, or stuck on a curl that won't resolve, I just need it to end and free up resources. Without this, I've seen requests that have lifespans of days or weeks because they've gotten stuck in novel places without a timeout.

PHP Version

7.4

Operating System

Not-windows

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions