@@ -316,13 +316,12 @@ static char *zend_parse_arg_impl(zval **arg, va_list *va, char **spec TSRMLS_DC)
316
316
* pl = Z_STRLEN_PP (arg );
317
317
break ;
318
318
case IS_OBJECT : {
319
- if (Z_OBJ_HANDLER_PP (arg , cast_object )) {
319
+ if (Z_OBJ_HANDLER_PP (arg , cast_object )
320
+ && Z_OBJ_HANDLER_PP (arg , cast_object )(* arg , * arg , IS_STRING , 0 TSRMLS_CC ) == SUCCESS ) {
320
321
SEPARATE_ZVAL_IF_NOT_REF (arg );
321
- if (Z_OBJ_HANDLER_PP (arg , cast_object )(* arg , * arg , IS_STRING , 0 TSRMLS_CC ) == SUCCESS ) {
322
- * pl = Z_STRLEN_PP (arg );
323
- * p = Z_STRVAL_PP (arg );
324
- break ;
325
- }
322
+ * pl = Z_STRLEN_PP (arg );
323
+ * p = Z_STRVAL_PP (arg );
324
+ break ;
326
325
}
327
326
}
328
327
@@ -1218,29 +1217,6 @@ ZEND_API int zend_startup_module(zend_module_entry *module)
1218
1217
return zend_register_module_ex (module TSRMLS_CC );
1219
1218
}
1220
1219
1221
- ZEND_API void zend_check_magic_method_implementation (zend_class_entry * ce , zend_function * fptr , int error_type TSRMLS_DC )
1222
- {
1223
- char lcname [16 ];
1224
- int name_len ;
1225
-
1226
- /* we don't care if the function name is longer, in fact lowercasing only
1227
- * the beginning of the name speeds up the check process */
1228
- name_len = strlen (fptr -> common .function_name );
1229
- zend_str_tolower_copy (lcname , fptr -> common .function_name , MIN (name_len , sizeof (lcname )- 1 ));
1230
- lcname [sizeof (lcname )- 1 ] = '\0' ; /* zend_str_tolower_copy won't necessarily set the zero byte */
1231
-
1232
- if (name_len == sizeof (ZEND_DESTRUCTOR_FUNC_NAME ) - 1 && !memcmp (lcname , ZEND_DESTRUCTOR_FUNC_NAME , sizeof (ZEND_DESTRUCTOR_FUNC_NAME )) && fptr -> common .num_args != 0 ) {
1233
- zend_error (error_type , "Destuctor %s::%s() cannot take arguments" , ce -> name , ZEND_DESTRUCTOR_FUNC_NAME );
1234
- } else if (name_len == sizeof (ZEND_CLONE_FUNC_NAME ) - 1 && !memcmp (lcname , ZEND_CLONE_FUNC_NAME , sizeof (ZEND_CLONE_FUNC_NAME )) && fptr -> common .num_args != 0 ) {
1235
- zend_error (error_type , "Method %s::%s() cannot accept any arguments" , ce -> name , ZEND_CLONE_FUNC_NAME );
1236
- } else if (name_len == sizeof (ZEND_GET_FUNC_NAME ) - 1 && !memcmp (lcname , ZEND_GET_FUNC_NAME , sizeof (ZEND_GET_FUNC_NAME )) && fptr -> common .num_args != 1 ) {
1237
- zend_error (error_type , "Method %s::%s() must take exactly 1 argument" , ce -> name , ZEND_GET_FUNC_NAME );
1238
- } else if (name_len == sizeof (ZEND_SET_FUNC_NAME ) - 1 && !memcmp (lcname , ZEND_SET_FUNC_NAME , sizeof (ZEND_SET_FUNC_NAME )) && fptr -> common .num_args != 2 ) {
1239
- zend_error (error_type , "Method %s::%s() must take exactly 2 arguments" , ce -> name , ZEND_SET_FUNC_NAME );
1240
- } else if (name_len == sizeof (ZEND_CALL_FUNC_NAME ) - 1 && !memcmp (lcname , ZEND_CALL_FUNC_NAME , sizeof (ZEND_CALL_FUNC_NAME )) && fptr -> common .num_args != 2 ) {
1241
- zend_error (error_type , "Method %s::%s() must take exactly 2 arguments" , ce -> name , ZEND_CALL_FUNC_NAME );
1242
- }
1243
- }
1244
1220
1245
1221
/* registers all functions in *library_functions in the function hash */
1246
1222
ZEND_API int zend_register_functions (zend_class_entry * scope , zend_function_entry * functions , HashTable * function_table , int type TSRMLS_DC )
@@ -1251,11 +1227,9 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, zend_function_entr
1251
1227
int count = 0 , unload = 0 ;
1252
1228
HashTable * target_function_table = function_table ;
1253
1229
int error_type ;
1254
- zend_function * ctor = NULL , * dtor = NULL , * clone = NULL , * __get = NULL , * __set = NULL , * __call = NULL ;
1230
+ zend_function * ctor = NULL , * dtor = NULL , * clone = NULL ;
1255
1231
char * lowercase_name ;
1256
1232
int fname_len ;
1257
- char * lc_class_name ;
1258
- int class_name_len ;
1259
1233
1260
1234
if (type == MODULE_PERSISTENT ) {
1261
1235
error_type = E_CORE_WARNING ;
@@ -1267,11 +1241,6 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, zend_function_entr
1267
1241
target_function_table = CG (function_table );
1268
1242
}
1269
1243
internal_function -> type = ZEND_INTERNAL_FUNCTION ;
1270
-
1271
- if (scope ) {
1272
- class_name_len = strlen (scope -> name );
1273
- lc_class_name = zend_str_tolower_dup (scope -> name , class_name_len );
1274
- }
1275
1244
1276
1245
while (ptr -> fname ) {
1277
1246
internal_function -> handler = ptr -> handler ;
@@ -1341,38 +1310,25 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, zend_function_entr
1341
1310
* If it's an old-style constructor, store it only if we don't have
1342
1311
* a constructor already.
1343
1312
*/
1344
- if (( fname_len == class_name_len ) && ! memcmp ( lowercase_name , lc_class_name , class_name_len + 1 ) && !ctor ) {
1313
+ if (! strcmp ( ptr -> fname , scope -> name ) && !ctor ) {
1345
1314
ctor = reg_function ;
1346
- } else if (( fname_len == sizeof ( ZEND_CONSTRUCTOR_FUNC_NAME ) - 1 ) && ! memcmp ( lowercase_name , ZEND_CONSTRUCTOR_FUNC_NAME , sizeof ( ZEND_CONSTRUCTOR_FUNC_NAME ) )) {
1315
+ } else if (! strcmp ( ptr -> fname , ZEND_CONSTRUCTOR_FUNC_NAME )) {
1347
1316
ctor = reg_function ;
1348
- } else if (( fname_len == sizeof ( ZEND_DESTRUCTOR_FUNC_NAME ) - 1 ) && ! memcmp ( lowercase_name , ZEND_DESTRUCTOR_FUNC_NAME , sizeof ( ZEND_DESTRUCTOR_FUNC_NAME ) )) {
1317
+ } else if (! strcmp ( ptr -> fname , ZEND_DESTRUCTOR_FUNC_NAME )) {
1349
1318
dtor = reg_function ;
1350
1319
if (internal_function -> num_args ) {
1351
1320
zend_error (error_type , "Destructor %s::%s() cannot take arguments" , scope -> name , ptr -> fname );
1352
1321
}
1353
- } else if ((fname_len == sizeof (ZEND_CLONE_FUNC_NAME )- 1 ) && !memcmp (lowercase_name , ZEND_CLONE_FUNC_NAME , sizeof (ZEND_CLONE_FUNC_NAME ))) {
1322
+
1323
+ } else if (!strcmp (ptr -> fname , ZEND_CLONE_FUNC_NAME )) {
1354
1324
clone = reg_function ;
1355
- } else if ((fname_len == sizeof (ZEND_CALL_FUNC_NAME )- 1 ) && !memcmp (lowercase_name , ZEND_CALL_FUNC_NAME , sizeof (ZEND_CALL_FUNC_NAME ))) {
1356
- __call = reg_function ;
1357
- } else if ((fname_len == sizeof (ZEND_GET_FUNC_NAME )- 1 ) && !memcmp (lowercase_name , ZEND_GET_FUNC_NAME , sizeof (ZEND_GET_FUNC_NAME ))) {
1358
- __get = reg_function ;
1359
- } else if ((fname_len == sizeof (ZEND_SET_FUNC_NAME )- 1 ) && !memcmp (lowercase_name , ZEND_SET_FUNC_NAME , sizeof (ZEND_SET_FUNC_NAME ))) {
1360
- __set = reg_function ;
1361
- } else {
1362
- reg_function = NULL ;
1363
- }
1364
- if (reg_function ) {
1365
- zend_check_magic_method_implementation (scope , reg_function , error_type TSRMLS_CC );
1366
1325
}
1367
1326
}
1368
1327
ptr ++ ;
1369
1328
count ++ ;
1370
1329
free_alloca (lowercase_name );
1371
1330
}
1372
1331
if (unload ) { /* before unloading, display all remaining bad function in the module */
1373
- if (scope ) {
1374
- efree (lc_class_name );
1375
- }
1376
1332
while (ptr -> fname ) {
1377
1333
if (zend_hash_exists (target_function_table , ptr -> fname , strlen (ptr -> fname )+ 1 )) {
1378
1334
zend_error (error_type , "Function registration failed - duplicate name - %s" , ptr -> fname );
@@ -1386,49 +1342,27 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, zend_function_entr
1386
1342
scope -> constructor = ctor ;
1387
1343
scope -> destructor = dtor ;
1388
1344
scope -> clone = clone ;
1389
- scope -> __call = __call ;
1390
- scope -> __get = __get ;
1391
- scope -> __set = __set ;
1392
1345
if (ctor ) {
1393
1346
ctor -> common .fn_flags |= ZEND_ACC_CTOR ;
1394
1347
if (ctor -> common .fn_flags & ZEND_ACC_STATIC ) {
1395
- zend_error (error_type , "Constructor %s::%s() cannot be static" , scope -> name , ctor -> common .function_name );
1348
+ zend_error (error_type , "Constructor %s::%s() cannot be static" , ctor -> common . scope -> name , ctor -> common .function_name );
1396
1349
}
1397
1350
ctor -> common .fn_flags &= ~ZEND_ACC_ALLOW_STATIC ;
1398
1351
}
1399
1352
if (dtor ) {
1400
1353
dtor -> common .fn_flags |= ZEND_ACC_DTOR ;
1401
1354
if (dtor -> common .fn_flags & ZEND_ACC_STATIC ) {
1402
- zend_error (error_type , "Destructor %s::%s() cannot be static" , scope -> name , dtor -> common .function_name );
1355
+ zend_error (error_type , "Destructor %s::%s() cannot be static" , dtor -> common . scope -> name , dtor -> common .function_name );
1403
1356
}
1404
1357
dtor -> common .fn_flags &= ~ZEND_ACC_ALLOW_STATIC ;
1405
1358
}
1406
1359
if (clone ) {
1407
1360
clone -> common .fn_flags |= ZEND_ACC_CLONE ;
1408
1361
if (clone -> common .fn_flags & ZEND_ACC_STATIC ) {
1409
- zend_error (error_type , "Constructor %s::%s() cannot be static" , scope -> name , clone -> common .function_name );
1362
+ zend_error (error_type , "Constructor %s::%s() cannot be static" , clone -> common . scope -> name , clone -> common .function_name );
1410
1363
}
1411
1364
clone -> common .fn_flags &= ~ZEND_ACC_ALLOW_STATIC ;
1412
1365
}
1413
- if (__call ) {
1414
- if (__call -> common .fn_flags & ZEND_ACC_STATIC ) {
1415
- zend_error (error_type , "Method %s::%s() cannot be static" , scope -> name , __call -> common .function_name );
1416
- }
1417
- __call -> common .fn_flags &= ~ZEND_ACC_ALLOW_STATIC ;
1418
- }
1419
- if (__get ) {
1420
- if (__get -> common .fn_flags & ZEND_ACC_STATIC ) {
1421
- zend_error (error_type , "Method %s::%s() cannot be static" , scope -> name , __get -> common .function_name );
1422
- }
1423
- __get -> common .fn_flags &= ~ZEND_ACC_ALLOW_STATIC ;
1424
- }
1425
- if (__set ) {
1426
- if (__set -> common .fn_flags & ZEND_ACC_STATIC ) {
1427
- zend_error (error_type , "Method %s::%s() cannot be static" , scope -> name , __set -> common .function_name );
1428
- }
1429
- __set -> common .fn_flags &= ~ZEND_ACC_ALLOW_STATIC ;
1430
- }
1431
- efree (lc_class_name );
1432
1366
}
1433
1367
return SUCCESS ;
1434
1368
}
0 commit comments