php / php/php-src

Issue with ob handler context and execution in PHP

Offen
#13,965 5 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bug Category: Output
Vorherrschende Sprache
C
Sterne
40.4k
Forks
8.2k
Ø Merge
2 T. 13 Std.
Gemergte PRs (30 T.)
96

Beschreibung

Description

I am encountering an issue while working with the "ob_start" function in PHP and the callback parameter.

Description:
When utilizing ob_start("system") to initiate output buffering with the "system" callback in the provided code snippet, I've observed that the zend_get_executed_filename function fails to return the correct file name when the "system" zend function is executed.

This discrepancy occurs particularly when a flush operation happens during php_request_shutdown.

<?php
ob_start("system");
?>

Observations:
Upon debugging, I've noticed the following:

  • Omission of the ob_flush() function call results in the flushing of output handlers during php_request_shutdown.
  • Prior to the invocation of php_output_end_all, the EG(current_execute_data) variable is set to NULL.
  • Consequently, when the "system" function is executed, it operates without the context of the current executed file name, leading to unexpected behavior.

Expected Behavior:
I expect the zend_get_executed_filename function to accurately retrieve the file name, even in scenarios involving flush operations during php_request_shutdown. Is this feasible?

PHP Version

PHP 8.3.3

Operating System

No response

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne damit, php_request_shutdown über php_output_end_all zu verfolgen, wenn ob_start("system") verwendet wird, und untersuche, wie EG(current_execute_data) behandelt wird, bevor system zend_get_executed_filename aufruft. Reproduziere das Beispiel für PHP 8.3.3 mit und ohne ob_flush(); done bedeutet, dass der ausgeführte Dateiname während des Flushens beim Shutdown korrekt bleibt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
c, php
Bereich
backend
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.