php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #21758 PCRE functions were screwed up
Submitted: 2003-01-19 17:16 UTC Modified: 2003-01-20 11:09 UTC
From: daniel dot gorski at develnet dot org Assigned:
Status: Closed Package: PCRE related
PHP Version: 5CVS-2003-01-19 (dev) OS: Linux, Win32
Private report: No CVE-ID: None
 [2003-01-19 17:16 UTC] daniel dot gorski at develnet dot org
Probably this patch screwed up preg_replace_* functions:
http://lists.php.net/article.php?group=php.cvs&article=18024

I need the functionality to pass a callback _method_ to preg_replace_callback().

It worked usually like this (in a class):

 $s = preg_replace_callback(<pattern>, array(&$this, 'callbackmethod'), $s);

Now "array" is forbidden. Is this your intention? How to access callback methods then?

regards dtg

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-01-20 00:29 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php4-STABLE-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-STABLE-latest.zip


To see if it's ZE2 issue or not..and also,
provide a complete, short and self-contained example script
so that we can easily reproduce the problem ourselves.

 [2003-01-20 05:23 UTC] daniel dot gorski at develnet dot org
Hi, have already pointed you to the patch that causes this. This has been working before the patch.

I've no possibility to test it on Win32 (I've been told by Sebastian Bergmann that it does not work there too).

As it has obviously nothing to do with ZE2, both (lastest PHP4-STABLE, and CVS "php5" module) perish on this. Please fix this as soon as possible.

"php4-STABLE-200301201030"

root@warpcore:/src/php4-STABLE-200301201030/sapi/cli> ./php -v
PHP 4.3.1-dev (cli) (built: Jan 20 2003 12:13:11)
Copyright (c) 1997-2003 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2003 Zend Technologies
root@warpcore:/src/php4-STABLE-200301201030/sapi/cli> ./php -i | head -13
phpinfo()
PHP Version => 4.3.1-dev

System => Linux warpcore 2.2.20 #10 Sun Nov 17 22:46:16 CET 2002 i686
Build Date => Jan 20 2003 12:09:35
Configure Command =>  './configure' '--enable-force-cgi-redirect' '--with-mysql=/usr/local/mysql' '--with-config-file-path=../conf' '--enable-trans-sid'
Server API => Command Line Interface
Virtual Directory Support => disabled
Configuration File (php.ini) Path => ../conf
PHP API => 20020918
PHP Extension => 20020429
Zend Extension => 20021010
Debug Build => no

root@warpcore:/src/php4-STABLE-200301201030/sapi/cli> cat | ./php 
<?php
  class Foo {
    function foo() {
      
      $s = 'preg_replace() is broken';
      
      echo preg_replace_callback(
              '/broken/',
              array(&$this, 'bar'),
              $s
           );
    }
    
    function bar() {
      return 'working';
    }
    
  } // of Foo

  $o = new Foo;
?>

Warning: preg_replace_callback() [...]: Parameter mismatch,
pattern is a string while replacement in an array. in - on line 11

----------------------------------------------------------------------

"php5" CVS module:

goosh@warpcore:/src/php5/sapi/cli> ./php -v
PHP 5.0.0-dev (cli) (built: Jan 20 2003 11:49:51)
Copyright (c) 1997-2003 The PHP Group
Zend Engine v2.0.0-dev, Copyright (c) 1998-2003 Zend Technologies

goosh@warpcore:/src/php5/sapi/cli> ./php -i | head -13
phpinfo()
PHP Version => 5.0.0-dev

System => Linux warpcore 2.2.20 #10 Sun Nov 17 22:46:16 CET 2002 i686
Build Date => Jan 20 2003 11:46:03
Configure Command =>  './configure' '--enable-force-cgi-redirect' '--with-mysql=/usr/local/mysql' '--with-config-file-path=../conf' '--enable-trans-sid'
Server API => Command Line Interface
Virtual Directory Support => disabled
Configuration File (php.ini) Path => ../conf
PHP API => 20020918
PHP Extension => 20020429
Zend Extension => 90021012
Debug Build => no

goosh@warpcore:/src/php5/sapi/cli> cat | ./php   
<?php
  class Foo {
    function foo() {
      
      $s = 'preg_replace() is broken';
      
      echo preg_replace_callback(
              '/broken/',
              array(&$this, 'bar'),
              $s
           );
    }
    
    function bar() {
      return 'working';
    }
    
  } // of Foo

  $o = new Foo;
?>

Warning: preg_replace_callback() [...]: Parameter mismatch,
pattern is a string while replacement in an array. in - on line 7

regards dtg
 [2003-01-20 10:46 UTC] moriyoshi@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.


 [2003-01-20 11:09 UTC] daniel dot gorski at develnet dot org
Thank you for the fast fix.

regards dtg
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sun Nov 17 00:01:34 2019 UTC