php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #78163 preg_quote() documented as accepting null for $delimiter, which actually throws
Submitted: 2019-06-14 15:29 UTC Modified: 2019-06-17 11:32 UTC
From: sp at fp dot de Assigned: cmb (profile)
Status: Closed Package: PCRE related
PHP Version: 7.3.6 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: sp at fp dot de
New email:
PHP Version: OS:

 

 [2019-06-14 15:29 UTC] sp at fp dot de
Description:
------------
Referring to Nikitas post:
https://www.mail-archive.com/internals@lists.php.net/msg98043.html

> If you see something that is documented as =null, but does not behave the
> same when null is passed, please do report a bug.

preg_quote() seems to fall under that category:
https://www.php.net/manual/en/function.preg-quote.php

It is documented as:
preg_quote ( string $str [, string $delimiter = NULL ] ) : string

But actually passing NULL as second argument throws TypeError with strict_types=1:
"Fatal error: Uncaught TypeError: preg_quote() expects parameter 2 to be string, null given"

Test script:
---------------
https://3v4l.org/ufjFF


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-06-14 15:33 UTC] requinix@php.net
Per the source, the actual default value is "\0" (which is always quoted anyways).
 [2019-06-14 16:07 UTC] cmb@php.net
-Status: Open +Status: Verified -Assigned To: +Assigned To: cmb
 [2019-06-14 16:11 UTC] cmb@php.net
Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&revision=347600
Log: Fix #78163: preg_quote() documented as accepting null for $delimiter, which actually throws
 [2019-06-14 16:15 UTC] salathe@php.net
Automatic comment on behalf of cmb
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=8a69739e04cbd1ad962d32609bc961c153572590
Log: Fix #78163: preg_quote() documented as accepting null for $delimiter, which actually throws
 [2019-06-14 16:15 UTC] salathe@php.net
-Status: Verified +Status: Closed
 [2019-06-17 11:32 UTC] nikic@php.net
Fixed in php-src in https://github.com/php/php-src/commit/03db04c3aba03fd55c94c9d834a6c151e351cfc5.

I'd recommend reverting the docs change for clarity. "\0" is a convenient value for internal use, but not a good choice for a user-facing default.
 [2019-06-17 12:35 UTC] cmb@php.net
Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&revision=347611
Log: Merged revision(s) 347600 from phpdoc/en/trunk:
Fix #78163: preg_quote() documented as accepting null for $delimiter, which actually throws
........
Cf. <https://bugs.php.net/bug.php?id=78163#1560771170>.
 [2019-06-17 12:40 UTC] salathe@php.net
Automatic comment on behalf of cmb
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=6b9ffc2ffc7f740c8a92b57e8b78b69f937d1f8a
Log: Merged revision(s) 347600 from phpdoc/en/trunk: Fix #78163: preg_quote() documented as accepting null for $delimiter, which actually throws ........ Cf. <https://bugs.php.net/bug.php?id=78163#1560771170>.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sun Dec 08 13:01:23 2019 UTC