php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #81566 ob_get_status return value contains non-existing constants
Submitted: 2021-10-29 17:25 UTC Modified: 2021-11-02 11:25 UTC
From: pegasus at vaultwiki dot org Assigned:
Status: Closed Package: Output Control
PHP Version: master-Git-2021-10-29 (Git) OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: pegasus at vaultwiki dot org
New email:
PHP Version: OS:

 

 [2021-10-29 17:25 UTC] pegasus at vaultwiki dot org
Description:
------------
The PHP documentation for ob_get_status says that the returned "type" key may be one of PHP_OUTPUT_HANDLER_INTERNAL or PHP_OUTPUT_HANDLER_USER:
https://www.php.net/manual/en/function.ob-get-status.php

However, these constants have historically not been defined and are still undefined:
https://github.com/php/php-src/blob/29e5e4719c253e28f521f9fbee6b1bf2ea5f7e22/main/output.c#L206

Since PHP 8, undefined constants are now fatal errors. This means the following code, which the documentation suggests should work, will now throw a fatal error.

So this is either a PHP bug (two missing output-control constants), or a PHP documentation bug (docs mentioning constants that do not exist).

Test script:
---------------
ob_start();

$status = ob_get_status();

if ($status['type'] == PHP_OUTPUT_HANDLER_INTERNAL) // fatal error
// do something

Expected result:
----------------
The condition should be evaluated without notice, warning, or fatal error; or the documentation should be updated so that it no longer suggests that these constants exist and are return values of ob_get_status.

Actual result:
--------------
Before 7.2: E_NOTICE
7.2-7.4: E_WARNING
8+: fatal

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-11-02 11:25 UTC] cmb@php.net
-Status: Open +Status: Verified -Type: Bug +Type: Documentation Problem
 [2021-11-02 11:25 UTC] cmb@php.net
This is a documentation issue.  "type" is either 0 (internal
handler) or 1 (userland handler).
 [2021-11-02 12:46 UTC] git@php.net
Automatic comment on behalf of cmb69
Revision: https://github.com/php/doc-en/commit/55f70d19870c396f3bf86b6c45826da3cb7e525f
Log: Fix #81566: ob_get_status return value contains non-existing constants
 [2021-11-02 12:46 UTC] git@php.net
-Status: Verified +Status: Closed
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sat Nov 26 19:05:53 2022 UTC