~ubuntu-branches/ubuntu/raring/php5/raring

« back to all changes in this revision

Viewing changes to ext/standard/var.c

  • Committer: Package Import Robot
  • Author(s): Clint Byrum
  • Date: 2012-06-18 16:10:26 UTC
  • mfrom: (1.1.24) (0.3.58 sid)
  • Revision ID: package-import@ubuntu.com-20120618161026-hg1fc5r9z1a4hlqz
Tags: 5.4.4-1ubuntu1
* Merge from Debian unstable. Remaining changes:
  - d/rules: Simplify apache config settings since we never build 
    interbase or firebird.
  - debian/rules: export DEB_HOST_MULTIARCH properly.
  - Add build-dependency on lemon, which we now need.
  - Dropped firebird2.1-dev, libc-client-dev, libmcrypt-dev as it is in universe.
  - Dropped libcurl-dev not in the archive.
  - debian/control: replace build-depends on mysql-server with
    mysql-server-core-5.5 and mysql-client-5.5 to avoid upstart and
    mysql-server-5.5 postinst confusion with starting up multiple
    mysqlds listening on the same port.
  - Dropped php5-imap, php5-interbase, php5-mcrypt since we have versions
    already in universe.
  - Dropped libonig-dev and libqgdbm since its in universe. (libonig MIR
    has been declined due to an inactive upstream. So this is probably
    a permanent change).
  - modulelist: Drop imap, interbase, sybase, and mcrypt.
  - debian/rules:
    * Dropped building of mcrypt, imap, and interbase.
    * Install apport hook for php5.
    * stop mysql instance on clean just in case we failed in tests
* Dropped Changes:
  * d/rules: enable Suhosin patch with PHP5_SUHOSIN=yes -- Upstream suhosin
    has been slow to adopt PHP 5.4, and is showing signs of disengagement.
    Therefore, we will follow Debian's lead and drop Suhosin for now.
  - d/control: build-depend on mysql 5.5 instead of 5.1 for running tests.
    -- Debian just deps on mysql-server
  - Suggest php5-suhosin rather than recommends. -- Dropping suhosin
  - d/setup-mysql.sh: modify to work with mysql 5.5 differences -- superseded
    in Debian.
  - Only build php5-sqlite for sqlite3, dropping the obsolete sqlite2. --
    superseded in Debian
  - d/maxlifetime: Improve maxlifetime script to scan for more SAPIs and 
    scan all *.ini in conf.d directory. -- Change came from Debian
  - d/libapache2-mod-php5.postinst,libapache2-mod-php5filter.postinst: 
    Restart apache on first install to ensure module is fully enabled.
    -- Change came from Debian
  - debian/patches/php5-CVE-2012-1823.patch: filter query strings that
    are prefixed with '-' -- Fixed upstream
  - debian/control: Recommend php5-dev for php-pear. -- This was a poorly
    conceived idea anyway.
  - Pre-Depend on a new enough version of dpkg for dpkg-maintscript-helper
    rather than checking whether it exists at run-time, leading to more
    predictable behaviour on upgrades. -- Applied in Debian
  - d/p/gd-multiarch-fix.patch: superseded
* d/NEWS: add note explaining that SUHOSIN is no longer enabled in the
  Ubuntu packages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
   | obtain it through the world-wide-web, please send a note to          |
13
13
   | license@php.net so we can mail you a copy immediately.               |
14
14
   +----------------------------------------------------------------------+
15
 
   | Authors: Jani Lehtim�ki <jkl@njet.net>                               |
 
15
   | Authors: Jani Lehtimäki <jkl@njet.net>                               |
16
16
   |          Thies C. Arntzen <thies@thieso.net>                         |
17
17
   |          Sascha Schumann <sascha@schumann.cx>                        |
18
18
   +----------------------------------------------------------------------+
19
19
*/
20
20
 
21
 
/* $Id: var.c 321634 2012-01-01 13:15:04Z felipe $ */
 
21
/* $Id$ */
22
22
 
23
23
/* {{{ includes
24
24
*/
56
56
static int php_object_property_dump(zval **zv TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */
57
57
{
58
58
        int level;
59
 
        char *prop_name, *class_name;
 
59
        const char *prop_name, *class_name;
60
60
 
61
61
        level = va_arg(args, int);
62
62
 
87
87
PHPAPI void php_var_dump(zval **struc, int level TSRMLS_DC) /* {{{ */
88
88
{
89
89
        HashTable *myht;
90
 
        char *class_name;
 
90
        const char *class_name;
91
91
        zend_uint class_name_len;
92
92
        int (*php_element_dump_func)(zval** TSRMLS_DC, int, va_list, zend_hash_key*);
93
93
        int is_temp;
133
133
                        return;
134
134
                }
135
135
 
136
 
                Z_OBJ_HANDLER(**struc, get_class_name)(*struc, &class_name, &class_name_len, 0 TSRMLS_CC);
137
 
                php_printf("%sobject(%s)#%d (%d) {\n", COMMON, class_name, Z_OBJ_HANDLE_PP(struc), myht ? zend_hash_num_elements(myht) : 0);
138
 
                efree(class_name);
 
136
                if (Z_OBJ_HANDLER(**struc, get_class_name)) {
 
137
                        Z_OBJ_HANDLER(**struc, get_class_name)(*struc, &class_name, &class_name_len, 0 TSRMLS_CC);
 
138
                        php_printf("%sobject(%s)#%d (%d) {\n", COMMON, class_name, Z_OBJ_HANDLE_PP(struc), myht ? zend_hash_num_elements(myht) : 0);
 
139
                        efree((char*)class_name);
 
140
                } else {
 
141
                        php_printf("%sobject(unknown class)#%d (%d) {\n", COMMON, Z_OBJ_HANDLE_PP(struc), myht ? zend_hash_num_elements(myht) : 0);
 
142
                }
139
143
                php_element_dump_func = php_object_property_dump;
140
144
head_done:
141
145
                if (myht) {
152
156
                PUTS("}\n");
153
157
                break;
154
158
        case IS_RESOURCE: {
155
 
                char *type_name;
156
 
 
157
 
                type_name = zend_rsrc_list_get_rsrc_type(Z_LVAL_PP(struc) TSRMLS_CC);
 
159
                const char *type_name = zend_rsrc_list_get_rsrc_type(Z_LVAL_PP(struc) TSRMLS_CC);
158
160
                php_printf("%sresource(%ld) of type (%s)\n", COMMON, Z_LVAL_PP(struc), type_name ? type_name : "Unknown");
159
161
                break;
160
162
        }
211
213
static int zval_object_property_dump(zval **zv TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */
212
214
{
213
215
        int level;
214
 
        char *prop_name, *class_name;
 
216
        const char *prop_name, *class_name;
215
217
 
216
218
        level = va_arg(args, int);
217
219
 
240
242
PHPAPI void php_debug_zval_dump(zval **struc, int level TSRMLS_DC) /* {{{ */
241
243
{
242
244
        HashTable *myht = NULL;
243
 
        char *class_name;
 
245
        const char *class_name;
244
246
        zend_uint class_name_len;
245
247
        int (*zval_element_dump_func)(zval** TSRMLS_DC, int, va_list, zend_hash_key*);
246
248
        int is_temp = 0;
282
284
                        PUTS("*RECURSION*\n");
283
285
                        return;
284
286
                }
285
 
                if (Z_OBJ_HANDLER_PP(struc, get_class_name)) {
286
 
                        Z_OBJ_HANDLER_PP(struc, get_class_name)(*struc, &class_name, &class_name_len, 0 TSRMLS_CC);
287
 
                        php_printf("%sobject(%s)#%d (%d) refcount(%u){\n", COMMON, class_name, Z_OBJ_HANDLE_PP(struc), myht ? zend_hash_num_elements(myht) : 0, Z_REFCOUNT_PP(struc));
288
 
                        efree(class_name);
289
 
                } else {
290
 
                        php_printf("%sobject(unknown class)#%d (%d) refcount(%u){\n", COMMON, Z_OBJ_HANDLE_PP(struc), myht ? zend_hash_num_elements(myht) : 0, Z_REFCOUNT_PP(struc));
291
 
                }
 
287
                Z_OBJ_HANDLER_PP(struc, get_class_name)(*struc, &class_name, &class_name_len, 0 TSRMLS_CC);
 
288
                php_printf("%sobject(%s)#%d (%d) refcount(%u){\n", COMMON, class_name, Z_OBJ_HANDLE_PP(struc), myht ? zend_hash_num_elements(myht) : 0, Z_REFCOUNT_PP(struc));
 
289
                efree((char*)class_name);
292
290
                zval_element_dump_func = zval_object_property_dump;
293
291
head_done:
294
292
                if (myht) {
304
302
                PUTS("}\n");
305
303
                break;
306
304
        case IS_RESOURCE: {
307
 
                char *type_name;
308
 
 
309
 
                type_name = zend_rsrc_list_get_rsrc_type(Z_LVAL_PP(struc) TSRMLS_CC);
 
305
                const char *type_name = zend_rsrc_list_get_rsrc_type(Z_LVAL_PP(struc) TSRMLS_CC);
310
306
                php_printf("%sresource(%ld) of type (%s) refcount(%u)\n", COMMON, Z_LVAL_PP(struc), type_name ? type_name : "Unknown", Z_REFCOUNT_PP(struc));
311
307
                break;
312
308
        }
357
353
                buffer_append_spaces(buf, level+1);
358
354
                smart_str_append_long(buf, (long) hash_key->h);
359
355
                smart_str_appendl(buf, " => ", 4);
 
356
 
360
357
        } else { /* string key */
361
358
                char *key, *tmp_str;
362
359
                int key_len, tmp_len;
376
373
 
377
374
        smart_str_appendc(buf, ',');
378
375
        smart_str_appendc(buf, '\n');
379
 
 
 
376
        
380
377
        return 0;
381
378
}
382
379
/* }}} */
391
388
 
392
389
        buffer_append_spaces(buf, level + 2);
393
390
        if (hash_key->nKeyLength != 0) {
394
 
                char *class_name, /* ignored, but must be passed to unmangle */
395
 
                         *pname,
396
 
                         *pname_esc;
 
391
                const char *class_name; /* ignored, but must be passed to unmangle */
 
392
                const char *pname;
 
393
                char *pname_esc;
397
394
                int  pname_esc_len;
398
395
                
399
396
                zend_unmangle_property_name(hash_key->arKey, hash_key->nKeyLength - 1,
406
403
                smart_str_appendc(buf, '\'');
407
404
                efree(pname_esc);
408
405
        } else {
409
 
                smart_str_append_long(buf, hash_key->h);
 
406
                smart_str_append_long(buf, (long) hash_key->h);
410
407
        }
411
 
 
412
408
        smart_str_appendl(buf, " => ", 4);
413
409
        php_var_export_ex(zv, level + 2, buf TSRMLS_CC);
414
410
        smart_str_appendc(buf, ',');
415
411
        smart_str_appendc(buf, '\n');
416
 
 
417
412
        return 0;
418
413
}
419
414
/* }}} */
423
418
        HashTable *myht;
424
419
        char *tmp_str, *tmp_str2;
425
420
        int tmp_len, tmp_len2;
426
 
        char *class_name;
 
421
        const char *class_name;
427
422
        zend_uint class_name_len;
428
423
 
429
424
        switch (Z_TYPE_PP(struc)) {
430
425
        case IS_BOOL:
431
 
        if (Z_LVAL_PP(struc)) {
432
 
                smart_str_appendl(buf, "true", 4);
433
 
        } else {
434
 
                smart_str_appendl(buf, "false", 5);
435
 
        }
 
426
                if (Z_LVAL_PP(struc)) {
 
427
                        smart_str_appendl(buf, "true", 4);
 
428
                } else {
 
429
                        smart_str_appendl(buf, "false", 5);
 
430
                }
436
431
                break;
437
432
        case IS_NULL:
438
433
                smart_str_appendl(buf, "NULL", 4);
469
464
                        buffer_append_spaces(buf, level - 1);
470
465
                }
471
466
                smart_str_appendc(buf, ')');
 
467
    
 
468
                break;
472
469
 
473
 
                break;
474
470
        case IS_OBJECT:
475
471
                myht = Z_OBJPROP_PP(struc);
476
472
                if (level > 1) {
482
478
                smart_str_appendl(buf, class_name, class_name_len);
483
479
                smart_str_appendl(buf, "::__set_state(array(\n", 21);
484
480
 
485
 
                efree(class_name);
 
481
                efree((char*)class_name);
486
482
                if (myht) {
487
 
                        zend_hash_apply_with_arguments(myht TSRMLS_CC, (apply_func_args_t) php_object_element_export, 2, level, buf);
 
483
                        zend_hash_apply_with_arguments(myht TSRMLS_CC, (apply_func_args_t) php_object_element_export, 1, level, buf);
488
484
                }
489
485
                if (level > 1) {
490
486
                        buffer_append_spaces(buf, level - 1);
510
506
}
511
507
/* }}} */
512
508
 
 
509
 
513
510
/* {{{ proto mixed var_export(mixed var [, bool return])
514
511
   Outputs or returns a string representation of a variable */
515
512
PHP_FUNCTION(var_export)
564
561
                        var_no = -1;
565
562
                        zend_hash_next_index_insert(var_hash, &var_no, sizeof(var_no), NULL);
566
563
                }
 
564
#if 0
 
565
                fprintf(stderr, "- had var (%d): %lu\n", Z_TYPE_P(var), **(ulong**)var_old);
 
566
#endif
567
567
                return FAILURE;
568
568
        }
569
569
 
570
570
        /* +1 because otherwise hash will think we are trying to store NULL pointer */
571
571
        var_no = zend_hash_num_elements(var_hash) + 1;
572
572
        zend_hash_add(var_hash, p, len, &var_no, sizeof(var_no), NULL);
 
573
#if 0
 
574
        fprintf(stderr, "+ add var (%d): %lu\n", Z_TYPE_P(var), var_no);
 
575
#endif
573
576
        return SUCCESS;
574
577
}
575
578
/* }}} */
785
788
                                if (ce && ce != PHP_IC_ENTRY && zend_hash_exists(&ce->function_table, "__sleep", sizeof("__sleep"))) {
786
789
                                        INIT_PZVAL(&fname);
787
790
                                        ZVAL_STRINGL(&fname, "__sleep", sizeof("__sleep") - 1, 0);
 
791
                                        BG(serialize_lock)++;
788
792
                                        res = call_user_function_ex(CG(function_table), &struc, &fname, &retval_ptr, 0, 0, 1, NULL TSRMLS_CC);
 
793
                                        BG(serialize_lock)--;
789
794
 
790
795
                                        if (res == SUCCESS && !EG(exception)) {
791
796
                                                if (retval_ptr) {
880
885
}
881
886
/* }}} */
882
887
 
883
 
PHPAPI void php_var_serialize(smart_str *buf, zval **struc, HashTable *var_hash TSRMLS_DC) /* {{{ */
 
888
PHPAPI void php_var_serialize(smart_str *buf, zval **struc, php_serialize_data_t *var_hash TSRMLS_DC) /* {{{ */
884
889
{
885
 
        php_var_serialize_intern(buf, *struc, var_hash TSRMLS_CC);
 
890
        php_var_serialize_intern(buf, *struc, *var_hash TSRMLS_CC);
886
891
        smart_str_0(buf);
887
892
}
888
893
/* }}} */