php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #56909 rename_function should not be be case-sensitive
Submitted: 2006-03-23 17:48 UTC Modified: 2015-02-26 07:34 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: mattsch at gmail dot com Assigned:
Status: Suspended Package: apd (PECL)
PHP Version: 5_1 CVS-2006-03-23 OS: Gentoo
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2006-03-23 17:48 UTC] mattsch at gmail dot com
Description:
------------
rename_function should be not case-sensitive as that seems to conflict with php which specifically states that its functions aren't case sensitive.

Reproduce code:
---------------
function testFunc(){
 echo 'test';
}
rename_function('testFunc','testFuncOther');

Outputs this:

PHP Warning:  rename_function(testFunc, testFuncOther) failed: testFunc does not exist!

Workaround:

function testFunc(){
 echo 'test';
}
rename_function('testfunc','testFuncOther');

Expected result:
----------------
Rename the function.

Actual result:
--------------
Only renames if the original function name is specified in lower case.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-03-23 17:54 UTC] mattsch at gmail dot com
changing summary
 [2008-06-16 21:25 UTC] geoff at spacevs dot com
Here is a patch to fix this.

--- orig.c	2008-06-17 10:27:26.000000000 +1000
+++ php_apd.c	2008-06-17 11:24:41.000000000 +1000
@@ -663,6 +663,7 @@
 PHP_FUNCTION(rename_function)
 {
 	zval **z_orig_fname, **z_new_fname;
+	char *orig_fname;
 	zend_function *func, *dummy_func;
 
 	if( ZEND_NUM_ARGS() != 2 ||
@@ -671,6 +672,13 @@
 			ZEND_WRONG_PARAM_COUNT();
 		}
 
+	orig_fname = Z_STRVAL_PP(z_orig_fname);
+	/* Convert to to lower case */
+	for(i = 0; i < Z_STRLEN_PP(z_orig_fname); i++)
+		if ((orig_fname[i] > 64) && (orig_fname[i] < 91))
+			orig_fname[i] += 32;
+	Z_STRVAL_PP(z_orig_fname) = orig_fname;
+
 	convert_to_string_ex(z_orig_fname);
 	convert_to_string_ex(z_new_fname);
 [2008-06-16 21:27 UTC] geoff at spacevs dot com
Whoops, missed a variable, this patch fixes this...

--- orig.c	2008-06-17 10:27:26.000000000 +1000
+++ php_apd.c	2008-06-17 11:26:55.000000000 +1000
@@ -663,6 +663,8 @@
 PHP_FUNCTION(rename_function)
 {
 	zval **z_orig_fname, **z_new_fname;
+	char *orig_fname;
+	int i;
 	zend_function *func, *dummy_func;
 
 	if( ZEND_NUM_ARGS() != 2 ||
@@ -671,6 +673,13 @@
 			ZEND_WRONG_PARAM_COUNT();
 		}
 
+	orig_fname = Z_STRVAL_PP(z_orig_fname);
+	/* Convert to to lower case */
+	for(i = 0; i < Z_STRLEN_PP(z_orig_fname); i++)
+		if ((orig_fname[i] > 64) && (orig_fname[i] < 91))
+			orig_fname[i] += 32;
+	Z_STRVAL_PP(z_orig_fname) = orig_fname;
+
 	convert_to_string_ex(z_orig_fname);
 	convert_to_string_ex(z_new_fname);
 [2015-02-26 07:34 UTC] krakjoe@php.net
-Status: Open +Status: Suspended
 [2015-02-26 07:34 UTC] krakjoe@php.net
APD hasn't had a release in 10 years, this means it's source code is way out of sync with modern PHP.

I'm going to mark this bug as suspended, the report can still be found if a maintainer for APD comes forward.

Sorry about the wait.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Thu Dec 02 19:03:38 2021 UTC