Skip to content

php 8 - exit() takes a very long time to send response #10620

Description

@fred-gregorio

Code

<?php
   $stid= [];
    $cnt= 0;
    set_time_limit(600);

    $epg= simplexml_load_file("epg.xml", "SimpleXMLElement", LIBXML_NOCDATA);
    if ($epg === FALSE) {
        exit ( "Malformed XML" );
    }

    foreach  ($epg->programme as $p) {
        /* just do something.... */
        $ev= json_decode(json_encode($p), true);
        $pieces= explode(" ", $ev['@attributes']['start']);
        $st= $pieces[0];
        $start= strtotime(substr($st, 0, 4)."-".substr($st, 4, 2)."-".substr($st, 6, 2)." ".substr($st, 8, 2).":".substr($st, 10, 2).":".substr($st, 12, 2));
        $cnt++;
    }
    exit ( "Done, $cnt programs loaded" );
?>

Description

For some reason the php opening line is correct, it breaks the report, so I inserted a space after <

This snipet of code takes around 15 seconds to execute and get to the exit() line. Existing, however, takes 10minutes, until the response is sent. The input file (epg.xml) has around 330,000 nodes. The actual code inside the foreach() loop doesn't realy matters much.

Tested with 8.1.14 and 8.2.3 - Same result on both.

Executing the same code with php 7.4.28 works fine, taking around 15 seconds to execute and spit out the response.

Relevant php configs : max_memory= 256M

Test environment: laptop HP, i7 8th Gen, 32GB RAM, 2TB nVme, Windows 11 PRO - 64 bits

The input file (epg.xml) is provided gz compressed.

epg.xml.gz

PHP Version

8.2.3

Operating System

Windos 11 64bits

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions