summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/com_dotnet/com_handlers.c10
-rw-r--r--ext/com_dotnet/com_saproxy.c8
-rw-r--r--ext/dom/dom_properties.h2
-rw-r--r--ext/dom/nodelist.c3
-rw-r--r--ext/dom/php_dom.c37
-rw-r--r--ext/dom/php_dom.h2
-rw-r--r--ext/dom/tests/bug67949.phpt61
-rw-r--r--ext/filter/filter.c18
-rw-r--r--ext/filter/filter_private.h11
-rw-r--r--ext/filter/logical_filters.c2
-rw-r--r--ext/filter/tests/filter_var_array_with_ref.phpt23
-rw-r--r--ext/gd/gd.c156
-rw-r--r--ext/mbstring/php_mbregex.c3
-rw-r--r--ext/opcache/ZendAccelerator.c4
-rw-r--r--ext/opcache/ZendAccelerator.h4
-rw-r--r--ext/opcache/zend_accelerator_util_funcs.c27
-rw-r--r--ext/opcache/zend_persist.c30
-rw-r--r--ext/opcache/zend_persist_calc.c108
-rw-r--r--ext/opcache/zend_shared_alloc.c2
-rw-r--r--ext/pdo/pdo_stmt.c16
-rw-r--r--ext/reflection/php_reflection.c2
-rw-r--r--ext/session/session.c5
-rw-r--r--ext/simplexml/simplexml.c2
-rw-r--r--ext/soap/soap.c21
-rw-r--r--ext/spl/spl_array.c2
-rw-r--r--ext/spl/spl_iterators.c2
-rw-r--r--ext/standard/array.c2
-rw-r--r--ext/standard/file.h4
-rw-r--r--ext/standard/pack.c154
-rw-r--r--ext/standard/php_incomplete_class.h5
-rw-r--r--ext/standard/php_string.h4
-rw-r--r--ext/standard/string.c74
-rw-r--r--ext/standard/tests/strings/pack64.phpt115
-rw-r--r--ext/standard/tests/strings/pack64_32.phpt44
-rw-r--r--ext/standard/tests/strings/url_t.phpt212
-rw-r--r--ext/standard/tests/url/parse_url_basic_001.phpt8
-rw-r--r--ext/standard/tests/url/parse_url_basic_005.phpt2
-rw-r--r--ext/standard/tests/url/parse_url_basic_006.phpt2
-rw-r--r--ext/standard/type.c7
-rw-r--r--ext/standard/url.c12
-rw-r--r--ext/standard/var.c29
41 files changed, 787 insertions, 448 deletions
diff --git a/ext/com_dotnet/com_handlers.c b/ext/com_dotnet/com_handlers.c
index 74a3920e34..6f63a1fbd8 100644
--- a/ext/com_dotnet/com_handlers.c
+++ b/ext/com_dotnet/com_handlers.c
@@ -423,14 +423,7 @@ static union _zend_function *com_constructor_get(zend_object *object TSRMLS_DC)
}
}
-static zend_class_entry *com_class_entry_get(const zend_object *object TSRMLS_DC)
-{
- php_com_dotnet_object *obj = (php_com_dotnet_object *)object;
-
- return obj->ce;
-}
-
-static zend_string* com_class_name_get(const zend_object *object, int parent TSRMLS_DC)
+static zend_string* com_class_name_get(const zend_object *object TSRMLS_DC)
{
php_com_dotnet_object *obj = (php_com_dotnet_object *)object;
@@ -564,7 +557,6 @@ zend_object_handlers php_com_object_handlers = {
com_method_get,
com_call_method,
com_constructor_get,
- com_class_entry_get,
com_class_name_get,
com_objects_compare,
com_object_cast,
diff --git a/ext/com_dotnet/com_saproxy.c b/ext/com_dotnet/com_saproxy.c
index 881ebfbaea..ddee9bc179 100644
--- a/ext/com_dotnet/com_saproxy.c
+++ b/ext/com_dotnet/com_saproxy.c
@@ -333,12 +333,7 @@ static union _zend_function *saproxy_constructor_get(zend_object *object TSRMLS_
return NULL;
}
-static zend_class_entry *saproxy_class_entry_get(const zend_object *object TSRMLS_DC)
-{
- return php_com_saproxy_class_entry;
-}
-
-static zend_string* saproxy_class_name_get(const zend_object *object, int parent TSRMLS_DC)
+static zend_string* saproxy_class_name_get(const zend_object *object TSRMLS_DC)
{
return zend_string_copy(php_com_saproxy_class_entry->name);
}
@@ -420,7 +415,6 @@ zend_object_handlers php_com_saproxy_handlers = {
saproxy_method_get,
saproxy_call_method,
saproxy_constructor_get,
- saproxy_class_entry_get,
saproxy_class_name_get,
saproxy_objects_compare,
saproxy_object_cast,
diff --git a/ext/dom/dom_properties.h b/ext/dom/dom_properties.h
index 7e607f0a2e..b5c81d271b 100644
--- a/ext/dom/dom_properties.h
+++ b/ext/dom/dom_properties.h
@@ -137,6 +137,8 @@ int dom_node_text_content_write(dom_object *obj, zval *newval TSRMLS_DC);
/* nodelist properties */
int dom_nodelist_length_read(dom_object *obj, zval *retval TSRMLS_DC);
+xmlNodePtr dom_nodelist_xml_item(dom_nnodemap_object *objmap, long index);
+xmlNodePtr dom_nodelist_baseobj_item(dom_nnodemap_object *objmap, long index);
/* notation properties */
int dom_notation_public_id_read(dom_object *obj, zval *retval TSRMLS_DC);
diff --git a/ext/dom/nodelist.c b/ext/dom/nodelist.c
index 68292d1983..15071739d2 100644
--- a/ext/dom/nodelist.c
+++ b/ext/dom/nodelist.c
@@ -153,8 +153,7 @@ PHP_FUNCTION(dom_nodelist_item)
} else {
nodep = nodep->children;
}
- itemnode = dom_get_elements_by_tag_name_ns_raw(
- nodep, (char *) objmap->ns, (char *) objmap->local, &count, index);
+ itemnode = dom_get_elements_by_tag_name_ns_raw(nodep, objmap->ns, objmap->local, &count, index);
}
}
}
diff --git a/ext/dom/php_dom.c b/ext/dom/php_dom.c
index 8a00ad5a08..71c06612db 100644
--- a/ext/dom/php_dom.c
+++ b/ext/dom/php_dom.c
@@ -619,6 +619,8 @@ PHP_MINIT_FUNCTION(dom)
memcpy(&dom_nnodemap_object_handlers, &dom_object_handlers, sizeof(zend_object_handlers));
dom_nnodemap_object_handlers.free_obj = dom_nnodemap_objects_free_storage;
dom_nnodemap_object_handlers.dtor_obj = dom_nnodemap_object_dtor;
+ dom_nnodemap_object_handlers.read_dimension = dom_nodelist_read_dimension;
+ dom_nnodemap_object_handlers.has_dimension = dom_nodelist_has_dimension;
zend_hash_init(&classes, 0, NULL, NULL, 1);
@@ -1542,6 +1544,41 @@ xmlNsPtr dom_get_nsdecl(xmlNode *node, xmlChar *localName) {
}
/* }}} end dom_get_nsdecl */
+zval *dom_nodelist_read_dimension(zval *object, zval *offset, int type, zval *rv TSRMLS_DC) /* {{{ */
+{
+ zval offset_copy;
+
+ if (!offset) {
+ return NULL;
+ }
+
+ ZVAL_COPY(&offset_copy, offset);
+ convert_to_long(&offset_copy);
+
+ zend_call_method_with_1_params(object, Z_OBJCE_P(object), NULL, "item", rv, &offset_copy);
+
+ return rv;
+} /* }}} end dom_nodelist_read_dimension */
+
+int dom_nodelist_has_dimension(zval *object, zval *member, int check_empty TSRMLS_DC)
+{
+ zval *length, offset_copy;
+ int ret;
+
+ ZVAL_COPY(&offset_copy, member);
+ convert_to_long(&offset_copy);
+
+ if (Z_LVAL(offset_copy) < 0) {
+ return 0;
+ }
+
+ length = zend_read_property(Z_OBJCE_P(object), object, "length", sizeof("length") - 1, 0 TSRMLS_CC);
+
+ ret = Z_LVAL(offset_copy) < Z_LVAL_P(length);
+
+ return ret;
+} /* }}} end dom_nodelist_has_dimension */
+
#endif /* HAVE_DOM */
/*
diff --git a/ext/dom/php_dom.h b/ext/dom/php_dom.h
index 9162031a90..02eb2d9509 100644
--- a/ext/dom/php_dom.h
+++ b/ext/dom/php_dom.h
@@ -126,6 +126,8 @@ xmlNode *php_dom_libxml_hash_iter(xmlHashTable *ht, int index);
xmlNode *php_dom_libxml_notation_iter(xmlHashTable *ht, int index);
zend_object_iterator *php_dom_get_iterator(zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC);
int dom_set_doc_classmap(php_libxml_ref_obj *document, zend_class_entry *basece, zend_class_entry *ce TSRMLS_DC);
+zval *dom_nodelist_read_dimension(zval *object, zval *offset, int type, zval *rv TSRMLS_DC);
+int dom_nodelist_has_dimension(zval *object, zval *member, int check_empty TSRMLS_DC);
#define REGISTER_DOM_CLASS(ce, name, parent_ce, funcs, entry) \
INIT_CLASS_ENTRY(ce, name, funcs); \
diff --git a/ext/dom/tests/bug67949.phpt b/ext/dom/tests/bug67949.phpt
new file mode 100644
index 0000000000..fc29881ca7
--- /dev/null
+++ b/ext/dom/tests/bug67949.phpt
@@ -0,0 +1,61 @@
+--TEST--
+Bug #67949: DOMNodeList elements should be accessible through array notation
+--FILE--
+<?php
+
+$html = <<<HTML
+<div>data</div>
+<a href="test">hello world</a>
+HTML;
+$doc = new DOMDocument;
+$doc->loadHTML($html);
+
+$nodes = $doc->getElementsByTagName('div');
+
+echo "testing has_dimension\n";
+var_dump(isset($nodes[0]));
+var_dump(isset($nodes[1]));
+var_dump(isset($nodes[-1]));
+
+echo "testing property access\n";
+var_dump($nodes[0]->textContent);
+var_dump($nodes[1]->textContent);
+
+echo "testing offset not a long\n";
+$offset = 'test';
+var_dump($offset);
+var_dump($nodes[$offset]->textContent);
+var_dump($offset);
+var_dump(isset($nodes[$offset]));
+var_dump($offset);
+
+echo "testing read_dimension with null offset\n";
+var_dump($nodes[][] = 1);
+
+echo "testing attribute access\n";
+$anchor = $doc->getElementsByTagName('a')[0];
+var_dump($anchor->attributes[0]->name);
+
+echo "==DONE==\n";
+
+--EXPECTF--
+testing has_dimension
+bool(true)
+bool(false)
+bool(false)
+testing property access
+string(4) "data"
+
+Notice: Trying to get property of non-object in %s on line %d
+NULL
+testing offset not a long
+string(4) "test"
+string(4) "data"
+string(4) "test"
+bool(true)
+string(4) "test"
+testing read_dimension with null offset
+NULL
+testing attribute access
+string(4) "href"
+==DONE==
diff --git a/ext/filter/filter.c b/ext/filter/filter.c
index 7ef65bc196..530dce6f53 100644
--- a/ext/filter/filter.c
+++ b/ext/filter/filter.c
@@ -491,7 +491,8 @@ static void php_zval_filter_recursive(zval *value, zend_long filter, zend_long f
}
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(value), element) {
- SEPARATE_ZVAL_IF_NOT_REF(element);
+ ZVAL_DEREF(element);
+ SEPARATE_ZVAL_NOREF(element);
if (Z_TYPE_P(element) == IS_ARRAY) {
Z_ARRVAL_P(element)->u.v.nApplyCount++;
php_zval_filter_recursive(element, filter, flags, options, charset, copy TSRMLS_CC);
@@ -581,9 +582,7 @@ static void php_filter_call(zval *filtered, zend_long filter, zval *filter_args,
char *charset = NULL;
if (filter_args && Z_TYPE_P(filter_args) != IS_ARRAY) {
- zend_long lval;
-
- PHP_FILTER_GET_LONG_OPT(filter_args, lval);
+ zend_long lval = zval_get_long(filter_args);
if (filter != -1) { /* handler for array apply */
/* filter_args is the filter_flags */
@@ -597,11 +596,11 @@ static void php_filter_call(zval *filtered, zend_long filter, zval *filter_args,
}
} else if (filter_args) {
if ((option = zend_hash_str_find(HASH_OF(filter_args), "filter", sizeof("filter") - 1)) != NULL) {
- PHP_FILTER_GET_LONG_OPT(option, filter);
+ filter = zval_get_long(option);
}
if ((option = zend_hash_str_find(HASH_OF(filter_args), "flags", sizeof("flags") - 1)) != NULL) {
- PHP_FILTER_GET_LONG_OPT(option, filter_flags);
+ filter_flags = zval_get_long(option);
if (!(filter_flags & FILTER_REQUIRE_ARRAY || filter_flags & FILTER_FORCE_ARRAY)) {
filter_flags |= FILTER_REQUIRE_SCALAR;
@@ -661,7 +660,6 @@ static void php_filter_call(zval *filtered, zend_long filter, zval *filter_args,
static void php_filter_array_handler(zval *input, zval *op, zval *return_value, zend_bool add_empty TSRMLS_DC) /* {{{ */
{
- zend_ulong index;
zend_string *arg_key;
zval *tmp, *arg_elm;
@@ -676,7 +674,7 @@ static void php_filter_array_handler(zval *input, zval *op, zval *return_value,
} else if (Z_TYPE_P(op) == IS_ARRAY) {
array_init(return_value);
- ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(op), index, arg_key, arg_elm) {
+ ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(op), arg_key, arg_elm) {
if (arg_key == NULL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Numeric keys are not allowed in the definition array");
zval_ptr_dtor(return_value);
@@ -732,7 +730,7 @@ PHP_FUNCTION(filter_input)
if (Z_TYPE_P(filter_args) == IS_LONG) {
filter_flags = Z_LVAL_P(filter_args);
} else if (Z_TYPE_P(filter_args) == IS_ARRAY && (option = zend_hash_str_find(HASH_OF(filter_args), "flags", sizeof("flags") - 1)) != NULL) {
- PHP_FILTER_GET_LONG_OPT(option, filter_flags);
+ filter_flags = zval_get_long(option);
}
if (Z_TYPE_P(filter_args) == IS_ARRAY &&
(opt = zend_hash_str_find(HASH_OF(filter_args), "options", sizeof("options") - 1)) != NULL &&
@@ -809,7 +807,7 @@ PHP_FUNCTION(filter_input_array)
if (Z_TYPE_P(op) == IS_LONG) {
filter_flags = Z_LVAL_P(op);
} else if (Z_TYPE_P(op) == IS_ARRAY && (option = zend_hash_str_find(HASH_OF(op), "flags", sizeof("flags") - 1)) != NULL) {
- PHP_FILTER_GET_LONG_OPT(option, filter_flags);
+ filter_flags = zval_get_long(option);
}
}
diff --git a/ext/filter/filter_private.h b/ext/filter/filter_private.h
index 8c41d8811e..b07b6ca534 100644
--- a/ext/filter/filter_private.h
+++ b/ext/filter/filter_private.h
@@ -117,17 +117,6 @@
} \
}
-#define PHP_FILTER_GET_LONG_OPT(zv, opt) { \
- if (Z_TYPE_P(zv) != IS_LONG) { \
- zval ___tmp; \
- ZVAL_DUP(&___tmp, zv); \
- convert_to_long(&___tmp); \
- opt = Z_LVAL(___tmp); \
- } else { \
- opt = Z_LVAL_P(zv); \
- } \
-}
-
#endif /* FILTER_PRIVATE_H */
/*
diff --git a/ext/filter/logical_filters.c b/ext/filter/logical_filters.c
index c37df628d2..b7c0b49a85 100644
--- a/ext/filter/logical_filters.c
+++ b/ext/filter/logical_filters.c
@@ -41,7 +41,7 @@
var_name##_set = 0; \
if (option_array) { \
if ((option_val = zend_hash_str_find(HASH_OF(option_array), option_name, sizeof(option_name) - 1)) != NULL) { \
- PHP_FILTER_GET_LONG_OPT(option_val, var_name); \
+ var_name = zval_get_long(option_val); \
var_name##_set = 1; \
} \
}
diff --git a/ext/filter/tests/filter_var_array_with_ref.phpt b/ext/filter/tests/filter_var_array_with_ref.phpt
new file mode 100644
index 0000000000..cd202edf4d
--- /dev/null
+++ b/ext/filter/tests/filter_var_array_with_ref.phpt
@@ -0,0 +1,23 @@
+--TEST--
+filter_var_array() on array with reference
+--FILE--
+<?php
+
+$array = ["123foo"];
+$array2 = [&$array];
+var_dump(filter_var_array($array2, FILTER_VALIDATE_INT));
+var_dump($array);
+
+?>
+--EXPECTF--
+array(1) {
+ [0]=>
+ &array(1) {
+ [0]=>
+ bool(false)
+ }
+}
+array(1) {
+ [0]=>
+ bool(false)
+}
diff --git a/ext/gd/gd.c b/ext/gd/gd.c
index fe7ea1c4b1..c08f9d4271 100644
--- a/ext/gd/gd.c
+++ b/ext/gd/gd.c
@@ -1537,14 +1537,7 @@ PHP_FUNCTION(imagesetstyle)
stylearr = safe_emalloc(sizeof(int), zend_hash_num_elements(HASH_OF(styles)), 0);
ZEND_HASH_FOREACH_VAL(HASH_OF(styles), item) {
- if (Z_TYPE_P(item) != IS_LONG) {
- zval lval;
- ZVAL_COPY(&lval, item);
- convert_to_long(&lval);
- stylearr[index++] = Z_LVAL(lval);
- } else {
- stylearr[index++] = Z_LVAL_P(item);
- }
+ stylearr[index++] = zval_get_long(item);
} ZEND_HASH_FOREACH_END();
gdImageSetStyle(im, stylearr, index);
@@ -3354,24 +3347,10 @@ static void php_imagepolygon(INTERNAL_FUNCTION_PARAMETERS, int filled)
for (i = 0; i < npoints; i++) {
if ((var = zend_hash_index_find(Z_ARRVAL_P(POINTS), (i * 2))) != NULL) {
- if (Z_TYPE_P(var) != IS_LONG) {
- zval lval;
- ZVAL_COPY(&lval, var);
- convert_to_long(&lval);
- points[i].x = Z_LVAL(lval);
- } else {
- points[i].x = Z_LVAL_P(var);
- }
+ points[i].x = zval_get_long(var);
}
if ((var = zend_hash_index_find(Z_ARRVAL_P(POINTS), (i * 2) + 1)) != NULL) {
- if (Z_TYPE_P(var) != IS_LONG) {
- zval lval;
- ZVAL_COPY(&lval, var);
- convert_to_long(&lval);
- points[i].y = Z_LVAL(lval);
- } else {
- points[i].y = Z_LVAL_P(var);
- }
+ points[i].y = zval_get_long(var);
}
}
@@ -3842,9 +3821,8 @@ static void php_imagettftext_common(INTERNAL_FUNCTION_PARAMETERS, int mode, int
continue;
}
if (strcmp("linespacing", key->val) == 0) {
- convert_to_double_ex(item);
strex.flags |= gdFTEX_LINESPACE;
- strex.linespacing = Z_DVAL_P(item);
+ strex.linespacing = zval_get_double(item);
}
} ZEND_HASH_FOREACH_END();
}
@@ -4871,15 +4849,8 @@ PHP_FUNCTION(imageconvolution)
}
for (j=0; j<3; j++) {
- if ((var2 = zend_hash_index_find(Z_ARRVAL_P(var), (j))) != NULL) {
- if (Z_TYPE_P(var2) != IS_DOUBLE) {
- zval dval;
- ZVAL_COPY(&dval, var2);
- convert_to_double(&dval);
- matrix[i][j] = (float)Z_DVAL(dval);
- } else {
- matrix[i][j] = (float)Z_DVAL_P(var2);
- }
+ if ((var2 = zend_hash_index_find(Z_ARRVAL_P(var), j)) != NULL) {
+ matrix[i][j] = (float) zval_get_double(var2);
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "You must have a 3x3 matrix");
RETURN_FALSE;
@@ -4972,56 +4943,28 @@ PHP_FUNCTION(imagecrop)
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
if ((tmp = zend_hash_str_find(HASH_OF(z_rect), "x", sizeof("x") -1)) != NULL) {
- if (Z_TYPE_P(tmp) != IS_LONG) {
- zval lval;
- ZVAL_COPY(&lval, tmp);
- convert_to_long(&lval);
- rect.x = Z_LVAL(lval);
- } else {
- rect.x = Z_LVAL_P(tmp);
- }
+ rect.x = zval_get_long(tmp);
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Missing x position");
RETURN_FALSE;
}
if ((tmp = zend_hash_str_find(HASH_OF(z_rect), "y", sizeof("y") - 1)) != NULL) {
- if (Z_TYPE_P(tmp) != IS_LONG) {
- zval lval;
- ZVAL_COPY(&lval, tmp);
- convert_to_long(&lval);
- rect.y = Z_LVAL(lval);
- } else {
- rect.y = Z_LVAL_P(tmp);
- }
+ rect.y = zval_get_long(tmp);
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Missing y position");
RETURN_FALSE;
}
if ((tmp = zend_hash_str_find(HASH_OF(z_rect), "width", sizeof("width") - 1)) != NULL) {
- if (Z_TYPE_P(tmp) != IS_LONG) {
- zval lval;
- ZVAL_COPY(&lval, tmp);
- convert_to_long(&lval);
- rect.width = Z_LVAL(lval);
- } else {
- rect.width = Z_LVAL_P(tmp);
- }
+ rect.width = zval_get_long(tmp);
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Missing width");
RETURN_FALSE;
}
if ((tmp = zend_hash_str_find(HASH_OF(z_rect), "height", sizeof("height") - 1)) != NULL) {
- if (Z_TYPE_P(tmp) != IS_LONG) {
- zval lval;
- ZVAL_COPY(&lval, tmp);
- convert_to_long(&lval);
- rect.height = Z_LVAL(lval);
- } else {
- rect.height = Z_LVAL_P(tmp);
- }
+ rect.height = zval_get_long(tmp);
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Missing height");
RETURN_FALSE;
@@ -5154,12 +5097,7 @@ PHP_FUNCTION(imageaffine)
affine[i] = Z_DVAL_P(zval_affine_elem);
break;
case IS_STRING:
- {
- zval dval;
- ZVAL_COPY(&dval, zval_affine_elem);
- convert_to_double(&dval);
- affine[i] = Z_DVAL(dval);
- }
+ affine[i] = zval_get_double(zval_affine_elem);
break;
default:
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid type for element %i", i);
@@ -5170,56 +5108,28 @@ PHP_FUNCTION(imageaffine)
if (z_rect != NULL) {
if ((tmp = zend_hash_str_find(HASH_OF(z_rect), "x", sizeof("x") - 1)) != NULL) {
- if (Z_TYPE_P(tmp) != IS_LONG) {
- zval lval;
- ZVAL_COPY(&lval, tmp);
- convert_to_long(&lval);
- rect.x = Z_LVAL(lval);
- } else {
- rect.x = Z_LVAL_P(tmp);
- }
+ rect.x = zval_get_long(tmp);
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Missing x position");
RETURN_FALSE;
}
if ((tmp = zend_hash_str_find(HASH_OF(z_rect), "y", sizeof("y") - 1)) != NULL) {
- if (Z_TYPE_P(tmp) != IS_LONG) {
- zval lval;
- ZVAL_COPY(&lval, tmp);
- convert_to_long(&lval);
- rect.y = Z_LVAL(lval);
- } else {
- rect.y = Z_LVAL_P(tmp);
- }
+ rect.y = zval_get_long(tmp);
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Missing y position");
RETURN_FALSE;
}
if ((tmp = zend_hash_str_find(HASH_OF(z_rect), "width", sizeof("width") - 1)) != NULL) {
- if (Z_TYPE_P(tmp) != IS_LONG) {
- zval lval;
- ZVAL_COPY(&lval, tmp);
- convert_to_long(&lval);
- rect.width = Z_LVAL(lval);
- } else {
- rect.width = Z_LVAL_P(tmp);
- }
+ rect.width = zval_get_long(tmp);
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Missing width");
RETURN_FALSE;
}
if ((tmp = zend_hash_str_find(HASH_OF(z_rect), "height", sizeof("height") - 1)) != NULL) {
- if (Z_TYPE_P(tmp) != IS_LONG) {
- zval lval;
- ZVAL_COPY(&lval, tmp);
- convert_to_long(&lval);
- rect.height = Z_LVAL(lval);
- } else {
- rect.height = Z_LVAL_P(tmp);
- }
+ rect.height = zval_get_long(tmp);
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Missing height");
RETURN_FALSE;
@@ -5268,28 +5178,14 @@ PHP_FUNCTION(imageaffinematrixget)
RETURN_FALSE;
}
if ((tmp = zend_hash_str_find(HASH_OF(options), "x", sizeof("x") - 1)) != NULL) {
- if (Z_TYPE_P(tmp) != IS_DOUBLE) {
- zval dval;
- ZVAL_COPY(&dval, tmp);
- convert_to_double(&dval);
- x = Z_DVAL(dval);
- } else {
- x = Z_DVAL_P(tmp);
- }
+ x = zval_get_double(tmp);
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Missing x position");
RETURN_FALSE;
}
if ((tmp = zend_hash_str_find(HASH_OF(options), "y", sizeof("y") - 1)) != NULL) {
- if (Z_TYPE_P(tmp) != IS_DOUBLE) {
- zval dval;
- ZVAL_COPY(&dval, tmp);
- convert_to_double(&dval);
- y = Z_DVAL(dval);
- } else {
- y = Z_DVAL_P(tmp);
- }
+ y = zval_get_double(tmp);
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Missing y position");
RETURN_FALSE;
@@ -5312,8 +5208,8 @@ PHP_FUNCTION(imageaffinematrixget)
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Number is expected as option");
RETURN_FALSE;
}
- convert_to_double_ex(options);
- angle = Z_DVAL_P(options);
+
+ angle = zval_get_double(options);
if (type == GD_AFFINE_SHEAR_HORIZONTAL) {
res = gdAffineShearHorizontal(affine, angle);
@@ -5372,12 +5268,7 @@ PHP_FUNCTION(imageaffinematrixconcat)
m1[i] = Z_DVAL_P(tmp);
break;
case IS_STRING:
- {
- zval dval;
- ZVAL_COPY(&dval, tmp);
- convert_to_double(&dval);
- m1[i] = Z_DVAL(dval);
- }
+ m1[i] = zval_get_double(tmp);
break;
default:
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid type for element %i", i);
@@ -5393,12 +5284,7 @@ PHP_FUNCTION(imageaffinematrixconcat)
m2[i] = Z_DVAL_P(tmp);
break;
case IS_STRING:
- {
- zval dval;
- ZVAL_COPY(&dval, tmp);
- convert_to_double(&dval);
- m2[i] = Z_DVAL(dval);
- }
+ m2[i] = zval_get_double(tmp);
break;
default:
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid type for element %i", i);
diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c
index de0bc768ad..8be88c3fee 100644
--- a/ext/mbstring/php_mbregex.c
+++ b/ext/mbstring/php_mbregex.c
@@ -1343,8 +1343,7 @@ PHP_FUNCTION(mb_ereg_search_init)
zval_ptr_dtor(&MBREX(search_str));
}
- ZVAL_COPY(&MBREX(search_str), arg_str);
- SEPARATE_ZVAL_IF_NOT_REF(&MBREX(search_str));
+ ZVAL_DUP(&MBREX(search_str), arg_str);
MBREX(search_pos) = 0;
diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c
index 1bd3734718..beab9be59c 100644
--- a/ext/opcache/ZendAccelerator.c
+++ b/ext/opcache/ZendAccelerator.c
@@ -1171,10 +1171,6 @@ static zend_persistent_script *cache_script_in_shared_memory(zend_persistent_scr
return new_persistent_script;
}
- /* cleanup after calculation */
- new_persistent_script->mem = ZCG(mem);
- new_persistent_script->size = memory_used;
-
/* Copy into shared memory */
new_persistent_script = zend_accel_script_persist(new_persistent_script, &key, key_length TSRMLS_CC);
diff --git a/ext/opcache/ZendAccelerator.h b/ext/opcache/ZendAccelerator.h
index c3c7285c48..28c3d21102 100644
--- a/ext/opcache/ZendAccelerator.h
+++ b/ext/opcache/ZendAccelerator.h
@@ -164,6 +164,8 @@ typedef struct _zend_persistent_script {
void *mem; /* shared memory area used by script structures */
size_t size; /* size of used shared memory */
+ void *arena_mem; /* part that should be copied into process */
+ size_t arena_size;
/* All entries that shouldn't be counted in the ADLER32
* checksum must be declared in this struct
@@ -234,6 +236,8 @@ typedef struct _zend_accel_globals {
time_t request_time;
/* preallocated shared-memory block to save current script */
void *mem;
+ void *arena_mem;
+ zend_persistent_script *current_persistent_script;
/* cache to save hash lookup on the same INCLUDE opcode */
const zend_op *cache_opline;
zend_persistent_script *cache_persistent_script;
diff --git a/ext/opcache/zend_accelerator_util_funcs.c b/ext/opcache/zend_accelerator_util_funcs.c
index bae6121f7e..1d949e4db4 100644
--- a/ext/opcache/zend_accelerator_util_funcs.c
+++ b/ext/opcache/zend_accelerator_util_funcs.c
@@ -38,6 +38,9 @@ static uint32_t zend_accel_refcount = ZEND_PROTECTED_REFCOUNT;
# define accel_xlat_get(old, new) ((new) = zend_hash_str_find_ptr(&ZCG(bind_hash), (char*)&(old), sizeof(void*), (zend_ulong)(zend_uintptr_t)(old), (void**)&(new)))
#endif
+#define ARENA_REALLOC(ptr) \
+ (void*)(((char*)(ptr)) + ((char*)ZCG(arena_mem) - (char*)ZCG(current_persistent_script)->arena_mem))
+
typedef int (*id_function_t)(void *, void *);
typedef void (*unique_copy_ctor_func_t)(void *pElement);
@@ -467,9 +470,8 @@ static void zend_hash_clone_methods(HashTable *ht, HashTable *source, zend_class
q->key = zend_clone_str(p->key TSRMLS_CC);
/* Copy data */
- ZVAL_PTR(&q->val, (void *) zend_arena_alloc(&CG(arena), sizeof(zend_op_array)));
+ ZVAL_PTR(&q->val, ARENA_REALLOC(Z_PTR(p->val)));
new_entry = (zend_op_array*)Z_PTR(q->val);
- *new_entry = *(zend_op_array*)Z_PTR(p->val);
/* Copy constructor */
/* we use refcount to show that op_array is referenced from several places */
@@ -544,9 +546,8 @@ static void zend_hash_clone_prop_info(HashTable *ht, HashTable *source, zend_cla
q->key = zend_clone_str(p->key TSRMLS_CC);
/* Copy data */
- ZVAL_PTR(&q->val, (void *) zend_arena_alloc(&CG(arena), sizeof(zend_property_info)));
+ ZVAL_PTR(&q->val, ARENA_REALLOC(Z_PTR(p->val)));
prop_info = Z_PTR(q->val);
- *prop_info = *(zend_property_info*)Z_PTR(p->val);
/* Copy constructor */
prop_info->name = zend_clone_str(prop_info->name TSRMLS_CC);
@@ -604,8 +605,7 @@ static void zend_class_copy_ctor(zend_class_entry **pce)
zend_class_entry *new_ce;
zend_function *new_func;
- *pce = ce = zend_arena_alloc(&CG(arena), sizeof(zend_class_entry));
- *ce = *old_ce;
+ *pce = ce = ARENA_REALLOC(old_ce);
ce->refcount = 1;
if (old_ce->refcount != 1) {
@@ -796,8 +796,7 @@ static void zend_accel_function_hash_copy(HashTable *target, HashTable *source,
}
}
if (pCopyConstructor) {
- Z_PTR_P(t) = zend_arena_alloc(&CG(arena), sizeof(zend_op_array));
- memcpy(Z_PTR_P(t), Z_PTR(p->val), sizeof(zend_op_array));
+ Z_PTR_P(t) = ARENA_REALLOC(Z_PTR(p->val));
pCopyConstructor(Z_PTR_P(t));
}
}
@@ -873,9 +872,16 @@ zend_op_array* zend_accel_load_script(zend_persistent_script *persistent_script,
op_array = (zend_op_array *) emalloc(sizeof(zend_op_array));
*op_array = persistent_script->main_op_array;
- if (from_shared_memory) {
+ if (EXPECTED(from_shared_memory)) {
zend_hash_init(&ZCG(bind_hash), 10, NULL, NULL, 0);
+ ZCG(current_persistent_script) = persistent_script;
+ ZCG(arena_mem) = NULL;
+ if (EXPECTED(persistent_script->arena_size)) {
+ ZCG(arena_mem) = zend_arena_alloc(&CG(arena), persistent_script->arena_size);
+ memcpy(ZCG(arena_mem), persistent_script->arena_mem, persistent_script->arena_size);
+ }
+
/* Copy all the necessary stuff from shared memory to regular memory, and protect the shared script */
if (zend_hash_num_elements(&persistent_script->class_table) > 0) {
zend_accel_class_hash_copy(CG(class_table), &persistent_script->class_table, (unique_copy_ctor_func_t) zend_class_copy_ctor TSRMLS_CC);
@@ -902,6 +908,7 @@ zend_op_array* zend_accel_load_script(zend_persistent_script *persistent_script,
}
zend_hash_destroy(&ZCG(bind_hash));
+ ZCG(current_persistent_script) = NULL;
} else /* if (!from_shared_memory) */ {
if (zend_hash_num_elements(&persistent_script->function_table) > 0) {
zend_accel_function_hash_copy(CG(function_table), &persistent_script->function_table, NULL TSRMLS_CC);
@@ -918,7 +925,7 @@ zend_op_array* zend_accel_load_script(zend_persistent_script *persistent_script,
CG(compiled_filename) = orig_compiled_filename;
}
- if (!from_shared_memory) {
+ if (UNEXPECTED(!from_shared_memory)) {
free_persistent_script(persistent_script, 0); /* free only hashes */
}
diff --git a/ext/opcache/zend_persist.c b/ext/opcache/zend_persist.c
index 6491b9d781..3e91740a71 100644
--- a/ext/opcache/zend_persist.c
+++ b/ext/opcache/zend_persist.c
@@ -486,7 +486,10 @@ static void zend_persist_op_array_ex(zend_op_array *op_array, zend_persistent_sc
static void zend_persist_op_array(zval *zv TSRMLS_DC)
{
- Z_PTR_P(zv) = zend_accel_memdup(Z_PTR_P(zv), sizeof(zend_op_array));
+ memcpy(ZCG(arena_mem), Z_PTR_P(zv), sizeof(zend_op_array));
+ zend_shared_alloc_register_xlat_entry(Z_PTR_P(zv), ZCG(arena_mem));
+ Z_PTR_P(zv) = ZCG(arena_mem);
+ ZCG(arena_mem) = (void*)((char*)ZCG(arena_mem) + ZEND_ALIGNED_SIZE(sizeof(zend_op_array)));
zend_persist_op_array_ex(Z_PTR_P(zv), NULL TSRMLS_CC);
}
@@ -494,7 +497,10 @@ static void zend_persist_property_info(zval *zv TSRMLS_DC)
{
zend_property_info *prop;
- prop = Z_PTR_P(zv) = zend_accel_memdup(Z_PTR_P(zv), sizeof(zend_property_info));
+ memcpy(ZCG(arena_mem), Z_PTR_P(zv), sizeof(zend_property_info));
+ zend_shared_alloc_register_xlat_entry(Z_PTR_P(zv), ZCG(arena_mem));
+ prop = Z_PTR_P(zv) = ZCG(arena_mem);
+ ZCG(arena_mem) = (void*)((char*)ZCG(arena_mem) + ZEND_ALIGNED_SIZE(sizeof(zend_property_info)));
zend_accel_store_interned_string(prop->name);
if (prop->doc_comment) {
if (ZCG(accel_directives).save_comments) {
@@ -514,7 +520,10 @@ static void zend_persist_class_entry(zval *zv TSRMLS_DC)
zend_class_entry *ce = Z_PTR_P(zv);
if (ce->type == ZEND_USER_CLASS) {
- ce = Z_PTR_P(zv) = zend_accel_memdup(ce, sizeof(zend_class_entry));
+ memcpy(ZCG(arena_mem), Z_PTR_P(zv), sizeof(zend_class_entry));
+ zend_shared_alloc_register_xlat_entry(Z_PTR_P(zv), ZCG(arena_mem));
+ ce = Z_PTR_P(zv) = ZCG(arena_mem);
+ ZCG(arena_mem) = (void*)((char*)ZCG(arena_mem) + ZEND_ALIGNED_SIZE(sizeof(zend_class_entry)));
zend_accel_store_interned_string(ce->name);
zend_hash_persist(&ce->function_table, zend_persist_op_array TSRMLS_CC);
if (ce->default_properties_table) {
@@ -703,13 +712,20 @@ static void zend_accel_persist_class_table(HashTable *class_table TSRMLS_DC)
zend_persistent_script *zend_accel_script_persist(zend_persistent_script *script, char **key, unsigned int key_length TSRMLS_DC)
{
+ script->mem = ZCG(mem);
+
zend_shared_alloc_clear_xlat_table();
- zend_hash_persist(&script->function_table, zend_persist_op_array TSRMLS_CC);
- zend_accel_persist_class_table(&script->class_table TSRMLS_CC);
- zend_persist_op_array_ex(&script->main_op_array, script TSRMLS_CC);
+
+ zend_accel_store(script, sizeof(zend_persistent_script));
*key = zend_accel_memdup(*key, key_length + 1);
zend_accel_store_string(script->full_path);
- zend_accel_store(script, sizeof(zend_persistent_script));
+
+ script->arena_mem = ZCG(arena_mem) = ZCG(mem);
+ ZCG(mem) = (void*)((char*)ZCG(mem) + script->arena_size);
+
+ zend_accel_persist_class_table(&script->class_table TSRMLS_CC);
+ zend_hash_persist(&script->function_table, zend_persist_op_array TSRMLS_CC);
+ zend_persist_op_array_ex(&script->main_op_array, script TSRMLS_CC);
return script;
}
diff --git a/ext/opcache/zend_persist_calc.c b/ext/opcache/zend_persist_calc.c
index d2de94f05c..0a7b835648 100644
--- a/ext/opcache/zend_persist_calc.c
+++ b/ext/opcache/zend_persist_calc.c
@@ -26,10 +26,10 @@
#include "zend_shared_alloc.h"
#include "zend_operators.h"
-#define START_SIZE() uint memory_used = 0
-#define ADD_DUP_SIZE(m,s) memory_used += zend_shared_memdup_size((void*)m, s)
-#define ADD_SIZE(m) memory_used += ZEND_ALIGNED_SIZE(m)
-#define RETURN_SIZE() return memory_used
+#define ADD_DUP_SIZE(m,s) ZCG(current_persistent_script)->size += zend_shared_memdup_size((void*)m, s)
+#define ADD_SIZE(m) ZCG(current_persistent_script)->size += ZEND_ALIGNED_SIZE(m)
+
+#define ADD_ARENA_SIZE(m) ZCG(current_persistent_script)->arena_size += ZEND_ALIGNED_SIZE(m)
# define ADD_STRING(str) \
ADD_DUP_SIZE((str), _STR_HEADER_SIZE + (str)->len + 1)
@@ -47,16 +47,15 @@
} \
} while (0)
-static uint zend_persist_zval_calc(zval *z TSRMLS_DC);
+static void zend_persist_zval_calc(zval *z TSRMLS_DC);
-static uint zend_hash_persist_calc(HashTable *ht, uint (*pPersistElement)(zval *pElement TSRMLS_DC) TSRMLS_DC)
+static void zend_hash_persist_calc(HashTable *ht, void (*pPersistElement)(zval *pElement TSRMLS_DC) TSRMLS_DC)
{
uint idx;
Bucket *p;
- START_SIZE();
if (!ht->nTableMask) {
- RETURN_SIZE();
+ return;
}
if (ht->u.flags & HASH_FLAG_PACKED) {
ADD_SIZE(sizeof(Bucket) * ht->nNumUsed);
@@ -75,26 +74,23 @@ static uint zend_hash_persist_calc(HashTable *ht, uint (*pPersistElement)(zval *
GC_FLAGS(p->key) |= flags;
}
- ADD_SIZE(pPersistElement(&p->val TSRMLS_CC));
+ pPersistElement(&p->val TSRMLS_CC);
}
-
- RETURN_SIZE();
}
-static uint zend_persist_ast_calc(zend_ast *ast TSRMLS_DC)
+static void zend_persist_ast_calc(zend_ast *ast TSRMLS_DC)
{
uint32_t i;
- START_SIZE();
if (ast->kind == ZEND_AST_ZVAL) {
ADD_SIZE(sizeof(zend_ast_zval));
- ADD_SIZE(zend_persist_zval_calc(zend_ast_get_zval(ast) TSRMLS_CC));
+ zend_persist_zval_calc(zend_ast_get_zval(ast) TSRMLS_CC);
} else if (zend_ast_is_list(ast)) {
zend_ast_list *list = zend_ast_get_list(ast);
ADD_SIZE(sizeof(zend_ast_list) - sizeof(zend_ast *) + sizeof(zend_ast *) * list->children);
for (i = 0; i < list->children; i++) {
if (list->child[i]) {
- ADD_SIZE(zend_persist_ast_calc(list->child[i] TSRMLS_CC));
+ zend_persist_ast_calc(list->child[i] TSRMLS_CC);
}
}
} else {
@@ -102,18 +98,16 @@ static uint zend_persist_ast_calc(zend_ast *ast TSRMLS_DC)
ADD_SIZE(sizeof(zend_ast) - sizeof(zend_ast *) + sizeof(zend_ast *) * children);
for (i = 0; i < children; i++) {
if (ast->child[i]) {
- ADD_SIZE(zend_persist_ast_calc(ast->child[i] TSRMLS_CC));
+ zend_persist_ast_calc(ast->child[i] TSRMLS_CC);
}
}
}
- RETURN_SIZE();
}
-static uint zend_persist_zval_calc(zval *z TSRMLS_DC)
+static void zend_persist_zval_calc(zval *z TSRMLS_DC)
{
zend_uchar flags;
uint size;
- START_SIZE();
switch (Z_TYPE_P(z)) {
case IS_STRING:
@@ -129,38 +123,35 @@ static uint zend_persist_zval_calc(zval *z TSRMLS_DC)
size = zend_shared_memdup_size(Z_ARR_P(z), sizeof(zend_array));
if (size) {
ADD_SIZE(size);
- ADD_SIZE(zend_hash_persist_calc(Z_ARRVAL_P(z), zend_persist_zval_calc TSRMLS_CC));
+ zend_hash_persist_calc(Z_ARRVAL_P(z), zend_persist_zval_calc TSRMLS_CC);
}
break;
case IS_REFERENCE:
size = zend_shared_memdup_size(Z_REF_P(z), sizeof(zend_reference));
if (size) {
ADD_SIZE(size);
- ADD_SIZE(zend_persist_zval_calc(Z_REFVAL_P(z) TSRMLS_CC));
+ zend_persist_zval_calc(Z_REFVAL_P(z) TSRMLS_CC);
}
break;
case IS_CONSTANT_AST:
size = zend_shared_memdup_size(Z_AST_P(z), sizeof(zend_ast_ref));
if (size) {
ADD_SIZE(size);
- ADD_SIZE(zend_persist_ast_calc(Z_ASTVAL_P(z) TSRMLS_CC));
+ zend_persist_ast_calc(Z_ASTVAL_P(z) TSRMLS_CC);
}
break;
}
- RETURN_SIZE();
}
-static uint zend_persist_op_array_calc_ex(zend_op_array *op_array TSRMLS_DC)
+static void zend_persist_op_array_calc_ex(zend_op_array *op_array TSRMLS_DC)
{
- START_SIZE();
-
if (op_array->type != ZEND_USER_FUNCTION) {
- return 0;
+ return;
}
if (op_array->static_variables) {
ADD_DUP_SIZE(op_array->static_variables, sizeof(HashTable));
- ADD_SIZE(zend_hash_persist_calc(op_array->static_variables, zend_persist_zval_calc TSRMLS_CC));
+ zend_hash_persist_calc(op_array->static_variables, zend_persist_zval_calc TSRMLS_CC);
}
if (zend_shared_alloc_get_xlat_entry(op_array->opcodes)) {
@@ -171,7 +162,7 @@ static uint zend_persist_op_array_calc_ex(zend_op_array *op_array TSRMLS_DC)
op_array->function_name = new_name;
}
}
- RETURN_SIZE();
+ return;
}
if (op_array->literals) {
@@ -179,7 +170,7 @@ static uint zend_persist_op_array_calc_ex(zend_op_array *op_array TSRMLS_DC)
zval *end = p + op_array->last_literal;
ADD_DUP_SIZE(op_array->literals, sizeof(zval) * op_array->last_literal);
while (p < end) {
- ADD_SIZE(zend_persist_zval_calc(p TSRMLS_CC));
+ zend_persist_zval_calc(p TSRMLS_CC);
p++;
}
}
@@ -239,46 +230,39 @@ static uint zend_persist_op_array_calc_ex(zend_op_array *op_array TSRMLS_DC)
ADD_INTERNED_STRING(op_array->vars[i], 0);
}
}
-
- RETURN_SIZE();
}
-static uint zend_persist_op_array_calc(zval *zv TSRMLS_DC)
+static void zend_persist_op_array_calc(zval *zv TSRMLS_DC)
{
- START_SIZE();
- ADD_SIZE(sizeof(zend_op_array));
- ADD_SIZE(zend_persist_op_array_calc_ex(Z_PTR_P(zv) TSRMLS_CC));
- RETURN_SIZE();
+ ADD_ARENA_SIZE(sizeof(zend_op_array));
+ zend_persist_op_array_calc_ex(Z_PTR_P(zv) TSRMLS_CC);
}
-static uint zend_persist_property_info_calc(zval *zv TSRMLS_DC)
+static void zend_persist_property_info_calc(zval *zv TSRMLS_DC)
{
zend_property_info *prop = Z_PTR_P(zv);
- START_SIZE();
- ADD_SIZE(sizeof(zend_property_info));
+ ADD_ARENA_SIZE(sizeof(zend_property_info));
ADD_INTERNED_STRING(prop->name, 0);
if (ZCG(accel_directives).save_comments && prop->doc_comment) {
ADD_STRING(prop->doc_comment);
}
- RETURN_SIZE();
}
-static uint zend_persist_class_entry_calc(zval *zv TSRMLS_DC)
+static void zend_persist_class_entry_calc(zval *zv TSRMLS_DC)
{
zend_class_entry *ce = Z_PTR_P(zv);
- START_SIZE();
if (ce->type == ZEND_USER_CLASS) {
- ADD_DUP_SIZE(ce, sizeof(zend_class_entry));
+ ADD_ARENA_SIZE(sizeof(zend_class_entry));
ADD_INTERNED_STRING(ce->name, 0);
- ADD_SIZE(zend_hash_persist_calc(&ce->function_table, zend_persist_op_array_calc TSRMLS_CC));
+ zend_hash_persist_calc(&ce->function_table, zend_persist_op_array_calc TSRMLS_CC);
if (ce->default_properties_table) {
int i;
ADD_SIZE(sizeof(zval) * ce->default_properties_count);
for (i = 0; i < ce->default_properties_count; i++) {
- ADD_SIZE(zend_persist_zval_calc(&ce->default_properties_table[i] TSRMLS_CC));
+ zend_persist_zval_calc(&ce->default_properties_table[i] TSRMLS_CC);
}
}
if (ce->default_static_members_table) {
@@ -286,10 +270,10 @@ static uint zend_persist_class_entry_calc(zval *zv TSRMLS_DC)
ADD_SIZE(sizeof(zval) * ce->default_static_members_count);
for (i = 0; i < ce->default_static_members_count; i++) {
- ADD_SIZE(zend_persist_zval_calc(&ce->default_static_members_table[i] TSRMLS_CC));
+ zend_persist_zval_calc(&ce->default_static_members_table[i] TSRMLS_CC);
}
}
- ADD_SIZE(zend_hash_persist_calc(&ce->constants_table, zend_persist_zval_calc TSRMLS_CC));
+ zend_hash_persist_calc(&ce->constants_table, zend_persist_zval_calc TSRMLS_CC);
if (ZEND_CE_FILENAME(ce)) {
ADD_STRING(ZEND_CE_FILENAME(ce));
@@ -298,7 +282,7 @@ static uint zend_persist_class_entry_calc(zval *zv TSRMLS_DC)
ADD_STRING(ZEND_CE_DOC_COMMENT(ce));
}
- ADD_SIZE(zend_hash_persist_calc(&ce->properties_info, zend_persist_property_info_calc TSRMLS_CC));
+ zend_hash_persist_calc(&ce->properties_info, zend_persist_property_info_calc TSRMLS_CC);
if (ce->trait_aliases) {
int i = 0;
@@ -345,24 +329,32 @@ static uint zend_persist_class_entry_calc(zval *zv TSRMLS_DC)
ADD_SIZE(sizeof(zend_trait_precedence*) * (i + 1));
}
}
- RETURN_SIZE();
}
-static uint zend_accel_persist_class_table_calc(HashTable *class_table TSRMLS_DC)
+static void zend_accel_persist_class_table_calc(HashTable *class_table TSRMLS_DC)
{
- return zend_hash_persist_calc(class_table, zend_persist_class_entry_calc TSRMLS_CC);
+ zend_hash_persist_calc(class_table, zend_persist_class_entry_calc TSRMLS_CC);
}
uint zend_accel_script_persist_calc(zend_persistent_script *new_persistent_script, char *key, unsigned int key_length TSRMLS_DC)
{
- START_SIZE();
+ new_persistent_script->mem = NULL;
+ new_persistent_script->size = 0;
+ new_persistent_script->arena_mem = NULL;
+ new_persistent_script->arena_size = 0;
+ ZCG(current_persistent_script) = new_persistent_script;
- ADD_SIZE(zend_hash_persist_calc(&new_persistent_script->function_table, zend_persist_op_array_calc TSRMLS_CC));
- ADD_SIZE(zend_accel_persist_class_table_calc(&new_persistent_script->class_table TSRMLS_CC));
- ADD_SIZE(zend_persist_op_array_calc_ex(&new_persistent_script->main_op_array TSRMLS_CC));
+ ADD_DUP_SIZE(new_persistent_script, sizeof(zend_persistent_script));
ADD_DUP_SIZE(key, key_length + 1);
ADD_STRING(new_persistent_script->full_path);
- ADD_DUP_SIZE(new_persistent_script, sizeof(zend_persistent_script));
- RETURN_SIZE();
+ zend_accel_persist_class_table_calc(&new_persistent_script->class_table TSRMLS_CC);
+ zend_hash_persist_calc(&new_persistent_script->function_table, zend_persist_op_array_calc TSRMLS_CC);
+ zend_persist_op_array_calc_ex(&new_persistent_script->main_op_array TSRMLS_CC);
+
+ new_persistent_script->size += new_persistent_script->arena_size;
+
+ ZCG(current_persistent_script) = NULL;
+
+ return new_persistent_script->size;
}
diff --git a/ext/opcache/zend_shared_alloc.c b/ext/opcache/zend_shared_alloc.c
index 9ecb2a0eae..f3f7bd7d30 100644
--- a/ext/opcache/zend_shared_alloc.c
+++ b/ext/opcache/zend_shared_alloc.c
@@ -340,7 +340,7 @@ void *_zend_shared_memdup(void *source, size_t size, zend_bool free_source TSRML
/* we already duplicated this pointer */
return old_p;
}
- retval = ZCG(mem);;
+ retval = ZCG(mem);
ZCG(mem) = (void*)(((char*)ZCG(mem)) + ZEND_ALIGNED_SIZE(size));
memcpy(retval, source, size);
if (free_source) {
diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c
index 1586695d96..4a958d92cf 100644
--- a/ext/pdo/pdo_stmt.c
+++ b/ext/pdo/pdo_stmt.c
@@ -977,7 +977,7 @@ static int do_fetch(pdo_stmt_t *stmt, int do_bind, zval *return_value, enum pdo_
ZVAL_COPY(return_value, &stmt->fetch.into);
- if (zend_get_class_entry(Z_OBJ_P(return_value) TSRMLS_CC) == ZEND_STANDARD_CLASS_DEF_PTR) {
+ if (Z_OBJ_P(return_value)->ce == ZEND_STANDARD_CLASS_DEF_PTR) {
how = PDO_FETCH_OBJ;
}
break;
@@ -2635,18 +2635,9 @@ static union _zend_function *row_get_ctor(zend_object *object TSRMLS_DC)
return (union _zend_function*)&ctor;
}
-static zend_class_entry *row_get_ce(const zend_object *object TSRMLS_DC)
+static zend_string *row_get_classname(const zend_object *object TSRMLS_DC)
{
- return pdo_row_ce;
-}
-
-static zend_string *row_get_classname(const zend_object *object, int parent TSRMLS_DC)
-{
- if (parent) {
- return NULL;
- } else {
- return zend_string_init("PDORow", sizeof("PDORow") - 1, 0);
- }
+ return zend_string_init("PDORow", sizeof("PDORow") - 1, 0);
}
static int row_compare(zval *object1, zval *object2 TSRMLS_DC)
@@ -2674,7 +2665,6 @@ zend_object_handlers pdo_row_object_handlers = {
row_method_get,
row_call_method,
row_get_ctor,
- row_get_ce,
row_get_classname,
row_compare,
NULL, /* cast */
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index d6c37e37fb..7291d64213 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -4157,7 +4157,7 @@ ZEND_METHOD(reflection_class, isInstance)
return;
}
GET_REFLECTION_OBJECT_PTR(ce);
- RETURN_BOOL(HAS_CLASS_ENTRY(*object) && instanceof_function(Z_OBJCE_P(object), ce TSRMLS_CC));
+ RETURN_BOOL(instanceof_function(Z_OBJCE_P(object), ce TSRMLS_CC));
}
/* }}} */
diff --git a/ext/session/session.c b/ext/session/session.c
index 63bb00e06a..dae965b048 100644
--- a/ext/session/session.c
+++ b/ext/session/session.c
@@ -2105,10 +2105,7 @@ static PHP_FUNCTION(session_unset)
}
IF_SESSION_VARS() {
- HashTable *ht_sess_var;
-
- SEPARATE_ZVAL_IF_NOT_REF(&PS(http_session_vars));
- ht_sess_var = Z_ARRVAL_P(Z_REFVAL(PS(http_session_vars)));
+ HashTable *ht_sess_var = Z_ARRVAL_P(Z_REFVAL(PS(http_session_vars)));
/* Clean $_SESSION. */
zend_hash_clean(ht_sess_var);
diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c
index 366a6f0d3b..ba70ecca9d 100644
--- a/ext/simplexml/simplexml.c
+++ b/ext/simplexml/simplexml.c
@@ -1958,7 +1958,6 @@ static zend_object_handlers sxe_object_handlers = { /* {{{ */
NULL, /* zend_get_std_object_handlers()->get_method,*/
NULL, /* zend_get_std_object_handlers()->call_method,*/
NULL, /* zend_get_std_object_handlers()->get_constructor, */
- NULL, /* zend_get_std_object_handlers()->get_class_entry,*/
NULL, /* zend_get_std_object_handlers()->get_class_name,*/
sxe_objects_compare,
sxe_object_cast,
@@ -2580,7 +2579,6 @@ PHP_MINIT_FUNCTION(simplexml)
sxe_object_handlers.clone_obj = sxe_object_clone;
sxe_object_handlers.get_method = zend_get_std_object_handlers()->get_method;
sxe_object_handlers.get_constructor = zend_get_std_object_handlers()->get_constructor;
- sxe_object_handlers.get_class_entry = zend_get_std_object_handlers()->get_class_entry;
sxe_object_handlers.get_class_name = zend_get_std_object_handlers()->get_class_name;
sxe_class_entry->serialize = zend_class_serialize_deny;
sxe_class_entry->unserialize = zend_class_unserialize_deny;
diff --git a/ext/soap/soap.c b/ext/soap/soap.c
index 3a091faddd..7c03b9ced4 100644
--- a/ext/soap/soap.c
+++ b/ext/soap/soap.c
@@ -93,7 +93,7 @@ static void soap_error_handler(int error_num, const char *error_filename, const
int _old_soap_version = SOAP_GLOBAL(soap_version);\
zend_bool _old_in_compilation = CG(in_compilation); \
zend_execute_data *_old_current_execute_data = EG(current_execute_data); \
- zval *_old_stack_top = EG(argument_stack)->top; \
+ zval *_old_stack_top = EG(vm_stack_top); \
int _bailout = 0;\
SOAP_GLOBAL(use_soap_error_handler) = 1;\
SOAP_GLOBAL(error_code) = "Client";\
@@ -105,18 +105,19 @@ static void soap_error_handler(int error_num, const char *error_filename, const
CG(in_compilation) = _old_in_compilation; \
EG(current_execute_data) = _old_current_execute_data; \
if (EG(exception) == NULL || \
- !instanceof_function(zend_get_class_entry(EG(exception) TSRMLS_CC), soap_fault_class_entry TSRMLS_CC)) {\
+ !instanceof_function(EG(exception)->ce, soap_fault_class_entry TSRMLS_CC)) {\
_bailout = 1;\
}\
- if (_old_stack_top != EG(argument_stack)->top) { \
- while (EG(argument_stack)->prev != NULL && \
- ((char*)_old_stack_top < (char*)EG(argument_stack) || \
- (char*) _old_stack_top > (char*)EG(argument_stack)->end)) { \
- zend_vm_stack tmp = EG(argument_stack)->prev; \
- efree(EG(argument_stack)); \
- EG(argument_stack) = tmp; \
+ if (_old_stack_top != EG(vm_stack_top)) { \
+ while (EG(vm_stack)->prev != NULL && \
+ ((char*)_old_stack_top < (char*)EG(vm_stack) || \
+ (char*) _old_stack_top > (char*)EG(vm_stack)->end)) { \
+ zend_vm_stack tmp = EG(vm_stack)->prev; \
+ efree(EG(vm_stack)); \
+ EG(vm_stack) = tmp; \
+ EG(vm_stack_end) = tmp->end; \
} \
- EG(argument_stack)->top = _old_stack_top; \
+ EG(vm_stack)->top = _old_stack_top; \
} \
} zend_end_try();\
SOAP_GLOBAL(use_soap_error_handler) = _old_handler;\
diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c
index 211180a08d..8aab4c49bf 100644
--- a/ext/spl/spl_array.c
+++ b/ext/spl/spl_array.c
@@ -1144,7 +1144,7 @@ static void spl_array_it_rewind(zend_object_iterator *iter TSRMLS_DC) /* {{{ */
static void spl_array_set_array(zval *object, spl_array_object *intern, zval *array, zend_long ar_flags, int just_array TSRMLS_DC) {
if (Z_TYPE_P(array) == IS_ARRAY) {
- SEPARATE_ZVAL_IF_NOT_REF(array);
+ SEPARATE_ARRAY(array);
}
if (Z_TYPE_P(array) == IS_OBJECT && (Z_OBJ_HT_P(array) == &spl_handler_ArrayObject || Z_OBJ_HT_P(array) == &spl_handler_ArrayIterator)) {
diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c
index dddc8c5e73..f47093bf4c 100644
--- a/ext/spl/spl_iterators.c
+++ b/ext/spl/spl_iterators.c
@@ -883,7 +883,7 @@ static union _zend_function *spl_recursive_it_get_method(zend_object **zobject,
zval *zobj;
if (!object->iterators) {
- php_error_docref(NULL TSRMLS_CC, E_ERROR, "The %s instance wasn't initialized properly", zend_get_class_entry(*zobject TSRMLS_CC)->name->val);
+ php_error_docref(NULL TSRMLS_CC, E_ERROR, "The %s instance wasn't initialized properly", (*zobject)->ce->name->val);
}
zobj = &object->iterators[level].zobject;
diff --git a/ext/standard/array.c b/ext/standard/array.c
index c8e79957b5..7b49b2fd13 100644
--- a/ext/standard/array.c
+++ b/ext/standard/array.c
@@ -331,7 +331,7 @@ PHP_FUNCTION(count)
}
#ifdef HAVE_SPL
/* if not and the object implements Countable we call its count() method */
- if (Z_OBJ_HT_P(array)->get_class_entry && instanceof_function(Z_OBJCE_P(array), spl_ce_Countable TSRMLS_CC)) {
+ if (instanceof_function(Z_OBJCE_P(array), spl_ce_Countable TSRMLS_CC)) {
zend_call_method_with_0_params(array, NULL, NULL, "count", &retval);
if (Z_TYPE(retval) != IS_UNDEF) {
RETVAL_LONG(zval_get_long(&retval));
diff --git a/ext/standard/file.h b/ext/standard/file.h
index e7de88f3de..78cab4f62f 100644
--- a/ext/standard/file.h
+++ b/ext/standard/file.h
@@ -23,6 +23,8 @@
#ifndef FILE_H
#define FILE_H
+#include "php_network.h"
+
PHP_MINIT_FUNCTION(file);
PHP_MSHUTDOWN_FUNCTION(file);
@@ -73,7 +75,7 @@ PHP_FUNCTION(sys_get_temp_dir);
PHP_MINIT_FUNCTION(user_streams);
PHPAPI int php_le_stream_context(TSRMLS_D);
-PHPAPI int php_set_sock_blocking(int socketd, int block TSRMLS_DC);
+PHPAPI int php_set_sock_blocking(php_socket_t socketd, int block TSRMLS_DC);
PHPAPI int php_copy_file(const char *src, const char *dest TSRMLS_DC);
PHPAPI int php_copy_file_ex(const char *src, const char *dest, int src_chk TSRMLS_DC);
PHPAPI int php_copy_file_ctx(const char *src, const char *dest, int src_chk, php_stream_context *ctx TSRMLS_DC);
diff --git a/ext/standard/pack.c b/ext/standard/pack.c
index f2bcb09723..a95c226b97 100644
--- a/ext/standard/pack.c
+++ b/ext/standard/pack.c
@@ -82,6 +82,13 @@ static int machine_endian_long_map[4];
static int big_endian_long_map[4];
static int little_endian_long_map[4];
+#if SIZEOF_ZEND_LONG > 4
+/* Mappings of bytes from quads (64bit) for all endian environments */
+static int machine_endian_longlong_map[8];
+static int big_endian_longlong_map[8];
+static int little_endian_longlong_map[8];
+#endif
+
/* {{{ php_pack
*/
static void php_pack(zval *val, size_t size, int *map, char *output)
@@ -98,8 +105,8 @@ static void php_pack(zval *val, size_t size, int *map, char *output)
}
/* }}} */
-/* pack() idea stolen from Perl (implemented formats behave the same as there)
- * Implemented formats are Z, A, a, h, H, c, C, s, S, i, I, l, L, n, N, f, d, x, X, @.
+/* pack() idea stolen from Perl (implemented formats behave the same as there except J and P)
+ * Implemented formats are Z, A, a, h, H, c, C, s, S, i, I, l, L, n, N, q, Q, J, P, f, d, x, X, @.
*/
/* {{{ proto string pack(string format, mixed arg1 [, mixed arg2 [, mixed ...]])
Takes one or more arguments and packs them into a binary string according to the format argument */
@@ -198,6 +205,17 @@ PHP_FUNCTION(pack)
break;
/* Use as many args as specified */
+ case 'q':
+ case 'Q':
+ case 'J':
+ case 'P':
+#if SIZEOF_ZEND_LONG < 8
+ efree(argv);
+ efree(formatcodes);
+ efree(formatargs);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "64-bit format codes are not available for 32-bit versions of PHP");
+ RETURN_FALSE;
+#endif
case 'c':
case 'C':
case 's':
@@ -280,6 +298,15 @@ PHP_FUNCTION(pack)
INC_OUTPUTPOS(arg,4) /* 32 bit per arg */
break;
+#if SIZEOF_ZEND_LONG > 4
+ case 'q':
+ case 'Q':
+ case 'J':
+ case 'P':
+ INC_OUTPUTPOS(arg,8) /* 32 bit per arg */
+ break;
+#endif
+
case 'f':
INC_OUTPUTPOS(arg,sizeof(float))
break;
@@ -430,6 +457,27 @@ PHP_FUNCTION(pack)
break;
}
+#if SIZEOF_ZEND_LONG > 4
+ case 'q':
+ case 'Q':
+ case 'J':
+ case 'P': {
+ int *map = machine_endian_longlong_map;
+
+ if (code == 'J') {
+ map = big_endian_longlong_map;
+ } else if (code == 'P') {
+ map = little_endian_longlong_map;
+ }
+
+ while (arg-- > 0) {
+ php_pack(&argv[currentarg++], 8, map, &output[outputpos]);
+ outputpos += 8;
+ }
+ break;
+ }
+#endif
+
case 'f': {
while (arg-- > 0) {
float v = (float) zval_get_double(&argv[currentarg++]);
@@ -506,7 +554,7 @@ static zend_long php_unpack(char *data, size_t size, int issigned, int *map)
* chars1, chars2, and ints.
* Numeric pack types will return numbers, a and A will return strings,
* f and d will return doubles.
- * Implemented formats are Z, A, a, h, H, c, C, s, S, i, I, l, L, n, N, f, d, x, X, @.
+ * Implemented formats are Z, A, a, h, H, c, C, s, S, i, I, l, L, n, N, q, Q, J, P, f, d, x, X, @.
*/
/* {{{ proto array unpack(string format, string input)
Unpack binary string into named array elements according to format argument */
@@ -622,6 +670,20 @@ PHP_FUNCTION(unpack)
size = 4;
break;
+ /* Use 8 bytes of input */
+ case 'q':
+ case 'Q':
+ case 'J':
+ case 'P':
+#if SIZEOF_ZEND_LONG > 4
+ size = 8;
+ break;
+#else
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "64-bit format codes are not available for 32-bit versions of PHP");
+ zval_dtor(return_value);
+ RETURN_FALSE;
+#endif
+
/* Use sizeof(float) bytes of input */
case 'f':
size = sizeof(float);
@@ -845,6 +907,38 @@ PHP_FUNCTION(unpack)
break;
}
+#if SIZEOF_ZEND_LONG > 4
+ case 'q':
+ case 'Q':
+ case 'J':
+ case 'P': {
+ int issigned = 0;
+ int *map = machine_endian_longlong_map;
+ long v = 0;
+
+ if (type == 'q' || type == 'Q') {
+ issigned = input[inputpos + (machine_little_endian ? 7 : 0)] & 0x80;
+ } else if (type == 'J') {
+ issigned = input[inputpos] & 0x80;
+ map = big_endian_longlong_map;
+ } else if (type == 'P') {
+ issigned = input[inputpos + 7] & 0x80;
+ map = little_endian_longlong_map;
+ }
+
+ v = php_unpack(&input[inputpos], 8, issigned, map);
+
+ if (type == 'q') {
+ v = (signed long int) v;
+ } else {
+ v = (unsigned long int) v;
+ }
+
+ add_assoc_long(return_value, n, v);
+ break;
+ }
+#endif
+
case 'f': {
float v;
@@ -948,6 +1042,33 @@ PHP_MINIT_FUNCTION(pack)
little_endian_long_map[1] = 1;
little_endian_long_map[2] = 2;
little_endian_long_map[3] = 3;
+
+#if SIZEOF_ZEND_LONG > 4
+ machine_endian_longlong_map[0] = 0;
+ machine_endian_longlong_map[1] = 1;
+ machine_endian_longlong_map[2] = 2;
+ machine_endian_longlong_map[3] = 3;
+ machine_endian_longlong_map[4] = 4;
+ machine_endian_longlong_map[5] = 5;
+ machine_endian_longlong_map[6] = 6;
+ machine_endian_longlong_map[7] = 7;
+ big_endian_longlong_map[0] = 7;
+ big_endian_longlong_map[1] = 6;
+ big_endian_longlong_map[2] = 5;
+ big_endian_longlong_map[3] = 4;
+ big_endian_longlong_map[4] = 3;
+ big_endian_longlong_map[5] = 2;
+ big_endian_longlong_map[6] = 1;
+ big_endian_longlong_map[7] = 0;
+ little_endian_longlong_map[0] = 0;
+ little_endian_longlong_map[1] = 1;
+ little_endian_longlong_map[2] = 2;
+ little_endian_longlong_map[3] = 3;
+ little_endian_longlong_map[4] = 4;
+ little_endian_longlong_map[5] = 5;
+ little_endian_longlong_map[6] = 6;
+ little_endian_longlong_map[7] = 7;
+#endif
}
else {
zval val;
@@ -980,6 +1101,33 @@ PHP_MINIT_FUNCTION(pack)
little_endian_long_map[1] = size - 2;
little_endian_long_map[2] = size - 3;
little_endian_long_map[3] = size - 4;
+
+#if SIZEOF_ZEND_LONG > 4
+ machine_endian_longlong_map[0] = size - 8;
+ machine_endian_longlong_map[1] = size - 7;
+ machine_endian_longlong_map[2] = size - 6;
+ machine_endian_longlong_map[3] = size - 5;
+ machine_endian_longlong_map[0] = size - 4;
+ machine_endian_longlong_map[1] = size - 3;
+ machine_endian_longlong_map[2] = size - 2;
+ machine_endian_longlong_map[3] = size - 1;
+ big_endian_longlong_map[0] = size - 8;
+ big_endian_longlong_map[1] = size - 7;
+ big_endian_longlong_map[2] = size - 6;
+ big_endian_longlong_map[3] = size - 5;
+ big_endian_longlong_map[0] = size - 4;
+ big_endian_longlong_map[1] = size - 3;
+ big_endian_longlong_map[2] = size - 2;
+ big_endian_longlong_map[3] = size - 1;
+ little_endian_longlong_map[0] = size - 1;
+ little_endian_longlong_map[1] = size - 2;
+ little_endian_longlong_map[2] = size - 3;
+ little_endian_longlong_map[3] = size - 4;
+ little_endian_longlong_map[0] = size - 5;
+ little_endian_longlong_map[1] = size - 6;
+ little_endian_longlong_map[2] = size - 7;
+ little_endian_longlong_map[3] = size - 8;
+#endif
}
return SUCCESS;
diff --git a/ext/standard/php_incomplete_class.h b/ext/standard/php_incomplete_class.h
index 6001e35bbe..177e960765 100644
--- a/ext/standard/php_incomplete_class.h
+++ b/ext/standard/php_incomplete_class.h
@@ -28,15 +28,14 @@
#define PHP_SET_CLASS_ATTRIBUTES(struc) \
/* OBJECTS_FIXME: Fix for new object model */ \
- if (Z_OBJ_HT_P(struc)->get_class_entry && \
- Z_OBJCE_P(struc) == BG(incomplete_class)) { \
+ if (Z_OBJCE_P(struc) == BG(incomplete_class)) { \
class_name = php_lookup_class_name(struc); \
if (!class_name) { \
class_name = zend_string_init(INCOMPLETE_CLASS, sizeof(INCOMPLETE_CLASS) - 1, 0); \
} \
incomplete_class = 1; \
} else { \
- class_name = zend_get_object_classname(Z_OBJ_P(struc) TSRMLS_CC); \
+ class_name = zend_string_copy(Z_OBJCE_P(struc)->name); \
}
#define PHP_CLEANUP_CLASS_ATTRIBUTES() \
diff --git a/ext/standard/php_string.h b/ext/standard/php_string.h
index 9e872222fd..0b655bfbdf 100644
--- a/ext/standard/php_string.h
+++ b/ext/standard/php_string.h
@@ -137,8 +137,8 @@ PHPAPI size_t php_strip_tags(char *rbuf, size_t len, int *state, char *allow, si
PHPAPI size_t php_strip_tags_ex(char *rbuf, size_t len, int *stateptr, char *allow, size_t allow_len, zend_bool allow_tag_spaces);
PHPAPI size_t php_char_to_str_ex(char *str, size_t len, char from, char *to, size_t to_len, zval *result, int case_sensitivity, size_t *replace_count);
PHPAPI size_t php_char_to_str(char *str, size_t len, char from, char *to, size_t to_len, zval *result);
-PHPAPI void php_implode(zval *delim, zval *arr, zval *return_value TSRMLS_DC);
-PHPAPI void php_explode(zval *delim, zval *str, zval *return_value, zend_long limit);
+PHPAPI void php_implode(const zend_string *delim, zval *arr, zval *return_value TSRMLS_DC);
+PHPAPI void php_explode(const zend_string *delim, zend_string *str, zval *return_value, zend_long limit);
PHPAPI size_t php_strspn(char *s1, char *s2, char *s1_end, char *s2_end);
PHPAPI size_t php_strcspn(char *s1, char *s2, char *s1_end, char *s2_end);
diff --git a/ext/standard/string.c b/ext/standard/string.c
index 87fde1e802..1975f19b3f 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -1013,41 +1013,36 @@ PHP_FUNCTION(wordwrap)
/* {{{ php_explode
*/
-PHPAPI void php_explode(zval *delim, zval *str, zval *return_value, zend_long limit)
+PHPAPI void php_explode(const zend_string *delim, zend_string *str, zval *return_value, zend_long limit)
{
- char *p1, *p2, *endp;
-
- endp = Z_STRVAL_P(str) + Z_STRLEN_P(str);
-
- p1 = Z_STRVAL_P(str);
- p2 = (char*)php_memnstr(Z_STRVAL_P(str), Z_STRVAL_P(delim), Z_STRLEN_P(delim), endp);
+ char *p1 = str->val;
+ char *endp = str->val + str->len;
+ char *p2 = (char *) php_memnstr(str->val, delim->val, delim->len, endp);
if (p2 == NULL) {
- add_next_index_stringl(return_value, p1, Z_STRLEN_P(str));
+ add_next_index_str(return_value, zend_string_copy(str));
} else {
do {
add_next_index_stringl(return_value, p1, p2 - p1);
- p1 = p2 + Z_STRLEN_P(delim);
- } while ((p2 = (char*)php_memnstr(p1, Z_STRVAL_P(delim), Z_STRLEN_P(delim), endp)) != NULL &&
- --limit > 1);
+ p1 = p2 + delim->len;
+ p2 = (char *) php_memnstr(p1, delim->val, delim->len, endp);
+ } while (p2 != NULL && --limit > 1);
- if (p1 <= endp)
- add_next_index_stringl(return_value, p1, endp-p1);
+ if (p1 <= endp) {
+ add_next_index_stringl(return_value, p1, endp - p1);
+ }
}
}
/* }}} */
/* {{{ php_explode_negative_limit
*/
-PHPAPI void php_explode_negative_limit(zval *delim, zval *str, zval *return_value, zend_long limit)
+PHPAPI void php_explode_negative_limit(const zend_string *delim, zend_string *str, zval *return_value, zend_long limit)
{
#define EXPLODE_ALLOC_STEP 64
- char *p1, *p2, *endp;
-
- endp = Z_STRVAL_P(str) + Z_STRLEN_P(str);
-
- p1 = Z_STRVAL_P(str);
- p2 = (char*)php_memnstr(Z_STRVAL_P(str), Z_STRVAL_P(delim), Z_STRLEN_P(delim), endp);
+ char *p1 = str->val;
+ char *endp = str->val + str->len;
+ char *p2 = (char *) php_memnstr(str->val, delim->val, delim->len, endp);
if (p2 == NULL) {
/*
@@ -1065,14 +1060,15 @@ PHPAPI void php_explode_negative_limit(zval *delim, zval *str, zval *return_valu
allocated = found + EXPLODE_ALLOC_STEP;/* make sure we have enough memory */
positions = erealloc(positions, allocated*sizeof(char *));
}
- positions[found++] = p1 = p2 + Z_STRLEN_P(delim);
- } while ((p2 = (char*)php_memnstr(p1, Z_STRVAL_P(delim), Z_STRLEN_P(delim), endp)) != NULL);
+ positions[found++] = p1 = p2 + delim->len;
+ p2 = (char *) php_memnstr(p1, delim->val, delim->len, endp);
+ } while (p2 != NULL);
to_return = limit + found;
/* limit is at least -1 therefore no need of bounds checking : i will be always less than found */
- for (i = 0;i < to_return;i++) { /* this checks also for to_return > 0 */
+ for (i = 0; i < to_return; i++) { /* this checks also for to_return > 0 */
add_next_index_stringl(return_value, positions[i],
- (positions[i+1] - Z_STRLEN_P(delim)) - positions[i]);
+ (positions[i+1] - delim->len) - positions[i]);
}
efree(positions);
}
@@ -1086,7 +1082,6 @@ PHP_FUNCTION(explode)
{
zend_string *str, *delim;
zend_long limit = ZEND_LONG_MAX; /* No limit */
- zval zdelim, zstr;
#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS|l", &delim, &str, &limit) == FAILURE) {
@@ -1110,17 +1105,15 @@ PHP_FUNCTION(explode)
if (str->len == 0) {
if (limit >= 0) {
- add_next_index_stringl(return_value, "", sizeof("") - 1);
+ add_next_index_str(return_value, STR_EMPTY_ALLOC());
}
return;
}
- ZVAL_STR(&zstr, str);
- ZVAL_STR(&zdelim, delim);
if (limit > 1) {
- php_explode(&zdelim, &zstr, return_value, limit);
+ php_explode(delim, str, return_value, limit);
} else if (limit < 0) {
- php_explode_negative_limit(&zdelim, &zstr, return_value, limit);
+ php_explode_negative_limit(delim, str, return_value, limit);
} else {
add_index_stringl(return_value, 0, str->val, str->len);
}
@@ -1133,7 +1126,7 @@ PHP_FUNCTION(explode)
/* {{{ php_implode
*/
-PHPAPI void php_implode(zval *delim, zval *arr, zval *return_value TSRMLS_DC)
+PHPAPI void php_implode(const zend_string *delim, zval *arr, zval *return_value TSRMLS_DC)
{
zval *tmp;
smart_str implstr = {0};
@@ -1170,8 +1163,8 @@ again:
size_t str_len = spprintf(&stmp, 0, "%.*G", (int) EG(precision), Z_DVAL_P(tmp));
smart_str_appendl(&implstr, stmp, str_len);
efree(stmp);
- }
break;
+ }
case IS_REFERENCE:
tmp = Z_REFVAL_P(tmp);
@@ -1186,7 +1179,7 @@ again:
}
if (++i != numelems) {
- smart_str_append(&implstr, Z_STR_P(delim));
+ smart_str_append(&implstr, delim);
}
} ZEND_HASH_FOREACH_END();
@@ -1205,7 +1198,8 @@ again:
Joins array elements placing glue string between items and return one string */
PHP_FUNCTION(implode)
{
- zval *arg1 = NULL, *arg2 = NULL, *delim, *arr, tmp;
+ zval *arg1, *arg2 = NULL, *arr;
+ zend_string *delim;
#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|z", &arg1, &arg2) == FAILURE) {
@@ -1225,20 +1219,15 @@ PHP_FUNCTION(implode)
return;
}
- ZVAL_EMPTY_STRING(&tmp);
- delim = &tmp;
-
- SEPARATE_ZVAL(arg1);
+ delim = STR_EMPTY_ALLOC();
arr = arg1;
} else {
if (Z_TYPE_P(arg1) == IS_ARRAY) {
+ delim = zval_get_string(arg2);
arr = arg1;
- convert_to_string_ex(arg2);
- delim = arg2;
} else if (Z_TYPE_P(arg2) == IS_ARRAY) {
+ delim = zval_get_string(arg1);
arr = arg2;
- convert_to_string_ex(arg1);
- delim = arg1;
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid arguments passed");
return;
@@ -1246,6 +1235,7 @@ PHP_FUNCTION(implode)
}
php_implode(delim, arr, return_value TSRMLS_CC);
+ zend_string_release(delim);
}
/* }}} */
diff --git a/ext/standard/tests/strings/pack64.phpt b/ext/standard/tests/strings/pack64.phpt
new file mode 100644
index 0000000000..9bc24928fe
--- /dev/null
+++ b/ext/standard/tests/strings/pack64.phpt
@@ -0,0 +1,115 @@
+--TEST--
+64bit pack()/unpack() tests
+--SKIPIF--
+<?php
+if (PHP_INT_SIZE < 8) {
+ die("skip 64bit test only");
+}
+?>
+--FILE--
+<?php
+print_r(unpack("Q", pack("Q", 0xfffffffffffe)));
+print_r(unpack("Q", pack("Q", 0)));
+print_r(unpack("Q", pack("Q", 0x8000000000000002)));
+print_r(unpack("Q", pack("Q", -1)));
+print_r(unpack("Q", pack("Q", 0x8000000000000000)));
+
+print_r(unpack("J", pack("J", 0xfffffffffffe)));
+print_r(unpack("J", pack("J", 0)));
+print_r(unpack("J", pack("J", 0x8000000000000002)));
+print_r(unpack("J", pack("J", -1)));
+print_r(unpack("J", pack("J", 0x8000000000000000)));
+
+print_r(unpack("P", pack("P", 0xfffffffffffe)));
+print_r(unpack("P", pack("P", 0)));
+print_r(unpack("P", pack("P", 0x8000000000000002)));
+print_r(unpack("P", pack("P", -1)));
+print_r(unpack("P", pack("P", 0x8000000000000000)));
+
+print_r(unpack("q", pack("q", 0xfffffffffffe)));
+print_r(unpack("q", pack("q", 0)));
+print_r(unpack("q", pack("q", 0x8000000000000002)));
+print_r(unpack("q", pack("q", -1)));
+print_r(unpack("q", pack("q", 0x8000000000000000)));
+?>
+--EXPECTF--
+Array
+(
+ [1] => 281474976710654
+)
+Array
+(
+ [1] => 0
+)
+Array
+(
+ [1] => -9223372036854775808
+)
+Array
+(
+ [1] => -1
+)
+Array
+(
+ [1] => -9223372036854775808
+)
+Array
+(
+ [1] => 281474976710654
+)
+Array
+(
+ [1] => 0
+)
+Array
+(
+ [1] => -9223372036854775808
+)
+Array
+(
+ [1] => -1
+)
+Array
+(
+ [1] => -9223372036854775808
+)
+Array
+(
+ [1] => 281474976710654
+)
+Array
+(
+ [1] => 0
+)
+Array
+(
+ [1] => -9223372036854775808
+)
+Array
+(
+ [1] => -1
+)
+Array
+(
+ [1] => -9223372036854775808
+)
+Array
+(
+ [1] => 281474976710654
+)
+Array
+(
+ [1] => 0
+)
+Array
+(
+ [1] => -9223372036854775808
+)
+Array
+(
+ [1] => -1
+)
+Array
+(
+ [1] => -9223372036854775808
+)
diff --git a/ext/standard/tests/strings/pack64_32.phpt b/ext/standard/tests/strings/pack64_32.phpt
new file mode 100644
index 0000000000..f52de63ca4
--- /dev/null
+++ b/ext/standard/tests/strings/pack64_32.phpt
@@ -0,0 +1,44 @@
+--TEST--
+64bit pack()/unpack() tests
+--SKIPIF--
+<?php
+if (PHP_INT_SIZE > 4) {
+ die("skip 32bit test only");
+}
+?>
+--FILE--
+<?php
+var_dump(pack("Q", 0));
+var_dump(pack("J", 0));
+var_dump(pack("P", 0));
+var_dump(pack("q", 0));
+
+var_dump(unpack("Q", ''));
+var_dump(unpack("J", ''));
+var_dump(unpack("P", ''));
+var_dump(unpack("q", ''));
+?>
+--EXPECTF--
+Warning: pack(): 64-bit format codes are not available for 32-bit versions of PHP in %s on line %d
+bool(false)
+
+Warning: pack(): 64-bit format codes are not available for 32-bit versions of PHP in %s on line %d
+bool(false)
+
+Warning: pack(): 64-bit format codes are not available for 32-bit versions of PHP in %s on line %d
+bool(false)
+
+Warning: pack(): 64-bit format codes are not available for 32-bit versions of PHP in %s on line %d
+bool(false)
+
+Warning: unpack(): 64-bit format codes are not available for 32-bit versions of PHP in %s on line %d
+bool(false)
+
+Warning: unpack(): 64-bit format codes are not available for 32-bit versions of PHP in %s on line %d
+bool(false)
+
+Warning: unpack(): 64-bit format codes are not available for 32-bit versions of PHP in %s on line %d
+bool(false)
+
+Warning: unpack(): 64-bit format codes are not available for 32-bit versions of PHP in %s on line %d
+bool(false)
diff --git a/ext/standard/tests/strings/url_t.phpt b/ext/standard/tests/strings/url_t.phpt
index e0e5411036..e172061ec2 100644
--- a/ext/standard/tests/strings/url_t.phpt
+++ b/ext/standard/tests/strings/url_t.phpt
@@ -75,6 +75,7 @@ $sample_urls = array (
);
foreach ($sample_urls as $url) {
+ echo "\n--> $url: ";
var_dump(@parse_url($url));
}
@@ -84,21 +85,24 @@ $sample_urls = array (
}
?>
--EXPECT--
-array(1) {
+--> : array(1) {
["path"]=>
string(0) ""
}
-array(1) {
+
+--> 64.246.30.37: array(1) {
["path"]=>
string(12) "64.246.30.37"
}
-array(2) {
+
+--> http://64.246.30.37: array(2) {
["scheme"]=>
string(4) "http"
["host"]=>
string(12) "64.246.30.37"
}
-array(3) {
+
+--> http://64.246.30.37/: array(3) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -106,11 +110,13 @@ array(3) {
["path"]=>
string(1) "/"
}
-array(1) {
+
+--> 64.246.30.37/: array(1) {
["path"]=>
string(13) "64.246.30.37/"
}
-array(3) {
+
+--> 64.246.30.37:80/: array(3) {
["host"]=>
string(12) "64.246.30.37"
["port"]=>
@@ -118,21 +124,25 @@ array(3) {
["path"]=>
string(1) "/"
}
-array(1) {
+
+--> php.net: array(1) {
["path"]=>
string(7) "php.net"
}
-array(1) {
+
+--> php.net/: array(1) {
["path"]=>
string(8) "php.net/"
}
-array(2) {
+
+--> http://php.net: array(2) {
["scheme"]=>
string(4) "http"
["host"]=>
string(7) "php.net"
}
-array(3) {
+
+--> http://php.net/: array(3) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -140,21 +150,25 @@ array(3) {
["path"]=>
string(1) "/"
}
-array(1) {
+
+--> www.php.net: array(1) {
["path"]=>
string(11) "www.php.net"
}
-array(1) {
+
+--> www.php.net/: array(1) {
["path"]=>
string(12) "www.php.net/"
}
-array(2) {
+
+--> http://www.php.net: array(2) {
["scheme"]=>
string(4) "http"
["host"]=>
string(11) "www.php.net"
}
-array(3) {
+
+--> http://www.php.net/: array(3) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -162,13 +176,15 @@ array(3) {
["path"]=>
string(1) "/"
}
-array(2) {
+
+--> www.php.net:80: array(2) {
["host"]=>
string(11) "www.php.net"
["port"]=>
int(80)
}
-array(3) {
+
+--> http://www.php.net:80: array(3) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -176,7 +192,8 @@ array(3) {
["port"]=>
int(80)
}
-array(4) {
+
+--> http://www.php.net:80/: array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -186,7 +203,8 @@ array(4) {
["path"]=>
string(1) "/"
}
-array(3) {
+
+--> http://www.php.net/index.php: array(3) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -194,11 +212,13 @@ array(3) {
["path"]=>
string(10) "/index.php"
}
-array(1) {
+
+--> www.php.net/?: array(1) {
["path"]=>
string(12) "www.php.net/"
}
-array(3) {
+
+--> www.php.net:80/?: array(3) {
["host"]=>
string(11) "www.php.net"
["port"]=>
@@ -206,7 +226,8 @@ array(3) {
["path"]=>
string(1) "/"
}
-array(3) {
+
+--> http://www.php.net/?: array(3) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -214,7 +235,8 @@ array(3) {
["path"]=>
string(1) "/"
}
-array(4) {
+
+--> http://www.php.net:80/?: array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -224,7 +246,8 @@ array(4) {
["path"]=>
string(1) "/"
}
-array(4) {
+
+--> http://www.php.net:80/index.php: array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -234,7 +257,8 @@ array(4) {
["path"]=>
string(10) "/index.php"
}
-array(4) {
+
+--> http://www.php.net:80/foo/bar/index.php: array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -244,7 +268,8 @@ array(4) {
["path"]=>
string(18) "/foo/bar/index.php"
}
-array(4) {
+
+--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php: array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -254,7 +279,8 @@ array(4) {
["path"]=>
string(53) "/this/is/a/very/deep/directory/structure/and/file.php"
}
-array(5) {
+
+--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php?lots=1&of=2&parameters=3&too=4&here=5: array(5) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -266,7 +292,8 @@ array(5) {
["query"]=>
string(37) "lots=1&of=2&parameters=3&too=4&here=5"
}
-array(4) {
+
+--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/: array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -276,7 +303,8 @@ array(4) {
["path"]=>
string(45) "/this/is/a/very/deep/directory/structure/and/"
}
-array(4) {
+
+--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php: array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -286,7 +314,8 @@ array(4) {
["path"]=>
string(53) "/this/is/a/very/deep/directory/structure/and/file.php"
}
-array(4) {
+
+--> http://www.php.net:80/this/../a/../deep/directory: array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -296,7 +325,8 @@ array(4) {
["path"]=>
string(28) "/this/../a/../deep/directory"
}
-array(4) {
+
+--> http://www.php.net:80/this/../a/../deep/directory/: array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -306,7 +336,8 @@ array(4) {
["path"]=>
string(29) "/this/../a/../deep/directory/"
}
-array(4) {
+
+--> http://www.php.net:80/this/is/a/very/deep/directory/../file.php: array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -316,7 +347,8 @@ array(4) {
["path"]=>
string(42) "/this/is/a/very/deep/directory/../file.php"
}
-array(4) {
+
+--> http://www.php.net:80/index.php: array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -326,7 +358,8 @@ array(4) {
["path"]=>
string(10) "/index.php"
}
-array(4) {
+
+--> http://www.php.net:80/index.php?: array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -336,7 +369,8 @@ array(4) {
["path"]=>
string(10) "/index.php"
}
-array(5) {
+
+--> http://www.php.net:80/#foo: array(5) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -348,7 +382,8 @@ array(5) {
["fragment"]=>
string(3) "foo"
}
-array(4) {
+
+--> http://www.php.net:80/?#: array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -358,7 +393,8 @@ array(4) {
["path"]=>
string(1) "/"
}
-array(5) {
+
+--> http://www.php.net:80/?test=1: array(5) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -370,7 +406,8 @@ array(5) {
["query"]=>
string(6) "test=1"
}
-array(4) {
+
+--> http://www.php.net/?test=1&: array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -380,7 +417,8 @@ array(4) {
["query"]=>
string(7) "test=1&"
}
-array(5) {
+
+--> http://www.php.net:80/?&: array(5) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -392,7 +430,8 @@ array(5) {
["query"]=>
string(1) "&"
}
-array(5) {
+
+--> http://www.php.net:80/index.php?test=1&: array(5) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -404,7 +443,8 @@ array(5) {
["query"]=>
string(7) "test=1&"
}
-array(4) {
+
+--> http://www.php.net/index.php?&: array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -414,7 +454,8 @@ array(4) {
["query"]=>
string(1) "&"
}
-array(5) {
+
+--> http://www.php.net:80/index.php?foo&: array(5) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -426,7 +467,8 @@ array(5) {
["query"]=>
string(4) "foo&"
}
-array(4) {
+
+--> http://www.php.net/index.php?&foo: array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -436,7 +478,8 @@ array(4) {
["query"]=>
string(4) "&foo"
}
-array(5) {
+
+--> http://www.php.net:80/index.php?test=1&test2=char&test3=mixesCI: array(5) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -448,7 +491,8 @@ array(5) {
["query"]=>
string(31) "test=1&test2=char&test3=mixesCI"
}
-array(5) {
+
+--> www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(5) {
["host"]=>
string(11) "www.php.net"
["port"]=>
@@ -460,7 +504,8 @@ array(5) {
["fragment"]=>
string(16) "some_page_ref123"
}
-array(7) {
+
+--> http://secret@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(7) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -476,13 +521,16 @@ array(7) {
["fragment"]=>
string(16) "some_page_ref123"
}
-array(6) {
+
+--> http://secret:@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(7) {
["scheme"]=>
string(4) "http"
["host"]=>
string(11) "www.php.net"
["user"]=>
string(6) "secret"
+ ["pass"]=>
+ string(0) ""
["path"]=>
string(10) "/index.php"
["query"]=>
@@ -490,13 +538,16 @@ array(6) {
["fragment"]=>
string(16) "some_page_ref123"
}
-array(7) {
+
+--> http://:hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(8) {
["scheme"]=>
string(4) "http"
["host"]=>
string(11) "www.php.net"
["port"]=>
int(80)
+ ["user"]=>
+ string(0) ""
["pass"]=>
string(7) "hideout"
["path"]=>
@@ -506,7 +557,8 @@ array(7) {
["fragment"]=>
string(16) "some_page_ref123"
}
-array(7) {
+
+--> http://secret:hideout@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(7) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -522,7 +574,8 @@ array(7) {
["fragment"]=>
string(16) "some_page_ref123"
}
-array(7) {
+
+--> http://secret@hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(7) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -538,7 +591,8 @@ array(7) {
["fragment"]=>
string(16) "some_page_ref123"
}
-array(8) {
+
+--> http://secret:hid:out@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(8) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -556,13 +610,15 @@ array(8) {
["fragment"]=>
string(16) "some_page_ref123"
}
-array(2) {
+
+--> nntp://news.php.net: array(2) {
["scheme"]=>
string(4) "nntp"
["host"]=>
string(12) "news.php.net"
}
-array(3) {
+
+--> ftp://ftp.gnu.org/gnu/glic/glibc.tar.gz: array(3) {
["scheme"]=>
string(3) "ftp"
["host"]=>
@@ -570,25 +626,29 @@ array(3) {
["path"]=>
string(22) "/gnu/glic/glibc.tar.gz"
}
-array(2) {
+
+--> zlib:http://foo@bar: array(2) {
["scheme"]=>
string(4) "zlib"
["path"]=>
string(14) "http://foo@bar"
}
-array(2) {
+
+--> zlib:filename.txt: array(2) {
["scheme"]=>
string(4) "zlib"
["path"]=>
string(12) "filename.txt"
}
-array(2) {
+
+--> zlib:/path/to/my/file/file.txt: array(2) {
["scheme"]=>
string(4) "zlib"
["path"]=>
string(25) "/path/to/my/file/file.txt"
}
-array(3) {
+
+--> foo://foo@bar: array(3) {
["scheme"]=>
string(3) "foo"
["host"]=>
@@ -596,25 +656,29 @@ array(3) {
["user"]=>
string(3) "foo"
}
-array(2) {
+
+--> mailto:me@mydomain.com: array(2) {
["scheme"]=>
string(6) "mailto"
["path"]=>
string(15) "me@mydomain.com"
}
-array(2) {
+
+--> /foo.php?a=b&c=d: array(2) {
["path"]=>
string(8) "/foo.php"
["query"]=>
string(7) "a=b&c=d"
}
-array(2) {
+
+--> foo.php?a=b&c=d: array(2) {
["path"]=>
string(7) "foo.php"
["query"]=>
string(7) "a=b&c=d"
}
-array(6) {
+
+--> http://user:passwd@www.example.com:8080?bar=1&boom=0: array(6) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -628,13 +692,15 @@ array(6) {
["query"]=>
string(12) "bar=1&boom=0"
}
-array(2) {
+
+--> file:///path/to/file: array(2) {
["scheme"]=>
string(4) "file"
["path"]=>
string(13) "/path/to/file"
}
-array(3) {
+
+--> file://path/to/file: array(3) {
["scheme"]=>
string(4) "file"
["host"]=>
@@ -642,13 +708,15 @@ array(3) {
["path"]=>
string(8) "/to/file"
}
-array(2) {
+
+--> file:/path/to/file: array(2) {
["scheme"]=>
string(4) "file"
["path"]=>
string(13) "/path/to/file"
}
-array(4) {
+
+--> http://1.2.3.4:/abc.asp?a=1&b=2: array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -658,7 +726,8 @@ array(4) {
["query"]=>
string(7) "a=1&b=2"
}
-array(3) {
+
+--> http://foo.com#bar: array(3) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -666,11 +735,13 @@ array(3) {
["fragment"]=>
string(3) "bar"
}
-array(1) {
+
+--> scheme:: array(1) {
["scheme"]=>
string(6) "scheme"
}
-array(4) {
+
+--> foo+bar://baz@bang/bla: array(4) {
["scheme"]=>
string(7) "foo+bar"
["host"]=>
@@ -680,13 +751,15 @@ array(4) {
["path"]=>
string(4) "/bla"
}
-array(2) {
+
+--> gg:9130731: array(2) {
["scheme"]=>
string(2) "gg"
["path"]=>
string(7) "9130731"
}
-array(7) {
+
+--> http://user:@pass@host/path?argument?value#etc: array(7) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -710,3 +783,4 @@ string(7) "hideout"
string(10) "/index.php"
string(31) "test=1&test2=char&test3=mixesCI"
string(16) "some_page_ref123"
+
diff --git a/ext/standard/tests/url/parse_url_basic_001.phpt b/ext/standard/tests/url/parse_url_basic_001.phpt
index a6f4f7a252..0708691fe3 100644
--- a/ext/standard/tests/url/parse_url_basic_001.phpt
+++ b/ext/standard/tests/url/parse_url_basic_001.phpt
@@ -454,13 +454,15 @@ echo "Done";
string(16) "some_page_ref123"
}
---> http://secret:@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(6) {
+--> http://secret:@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(7) {
["scheme"]=>
string(4) "http"
["host"]=>
string(11) "www.php.net"
["user"]=>
string(6) "secret"
+ ["pass"]=>
+ string(0) ""
["path"]=>
string(10) "/index.php"
["query"]=>
@@ -469,13 +471,15 @@ echo "Done";
string(16) "some_page_ref123"
}
---> http://:hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(7) {
+--> http://:hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(8) {
["scheme"]=>
string(4) "http"
["host"]=>
string(11) "www.php.net"
["port"]=>
int(80)
+ ["user"]=>
+ string(0) ""
["pass"]=>
string(7) "hideout"
["path"]=>
diff --git a/ext/standard/tests/url/parse_url_basic_005.phpt b/ext/standard/tests/url/parse_url_basic_005.phpt
index 1fc946e5b3..5b2cb98f8b 100644
--- a/ext/standard/tests/url/parse_url_basic_005.phpt
+++ b/ext/standard/tests/url/parse_url_basic_005.phpt
@@ -66,7 +66,7 @@ echo "Done";
--> www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : NULL
--> http://secret@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(6) "secret"
--> http://secret:@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(6) "secret"
---> http://:hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : NULL
+--> http://:hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(0) ""
--> http://secret:hideout@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(6) "secret"
--> http://secret@hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(14) "secret@hideout"
--> http://secret:hid:out@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(6) "secret"
diff --git a/ext/standard/tests/url/parse_url_basic_006.phpt b/ext/standard/tests/url/parse_url_basic_006.phpt
index 5104326198..79af6b8b62 100644
--- a/ext/standard/tests/url/parse_url_basic_006.phpt
+++ b/ext/standard/tests/url/parse_url_basic_006.phpt
@@ -65,7 +65,7 @@ echo "Done";
--> http://www.php.net:80/index.php?test=1&test2=char&test3=mixesCI : NULL
--> www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : NULL
--> http://secret@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : NULL
---> http://secret:@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : NULL
+--> http://secret:@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(0) ""
--> http://:hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(7) "hideout"
--> http://secret:hideout@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(7) "hideout"
--> http://secret@hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : NULL
diff --git a/ext/standard/type.c b/ext/standard/type.c
index fa5cd4639e..67d5ed1e75 100644
--- a/ext/standard/type.c
+++ b/ext/standard/type.c
@@ -219,12 +219,7 @@ static inline void php_is_type(INTERNAL_FUNCTION_PARAMETERS, int type)
if (Z_TYPE_P(arg) == type) {
if (type == IS_OBJECT) {
- zend_class_entry *ce;
- if (Z_OBJ_HT_P(arg)->get_class_entry == NULL) {
- /* if there's no get_class_entry it's not a PHP object, so it can't be INCOMPLETE_CLASS */
- RETURN_TRUE;
- }
- ce = Z_OBJCE_P(arg);
+ zend_class_entry *ce = Z_OBJCE_P(arg);
if (ce->name->len == sizeof(INCOMPLETE_CLASS) - 1
&& !strncmp(ce->name->val, INCOMPLETE_CLASS, ce->name->len)) {
RETURN_FALSE;
diff --git a/ext/standard/url.c b/ext/standard/url.c
index 81f9b2ac9a..4fb2c73edb 100644
--- a/ext/standard/url.c
+++ b/ext/standard/url.c
@@ -240,16 +240,12 @@ PHPAPI php_url *php_url_parse_ex(char const *str, int length)
/* check for login and password */
if ((p = zend_memrchr(s, '@', (e-s)))) {
if ((pp = memchr(s, ':', (p-s)))) {
- if ((pp-s) > 0) {
- ret->user = estrndup(s, (pp-s));
- php_replace_controlchars_ex(ret->user, (pp - s));
- }
+ ret->user = estrndup(s, (pp-s));
+ php_replace_controlchars_ex(ret->user, (pp - s));
pp++;
- if (p-pp > 0) {
- ret->pass = estrndup(pp, (p-pp));
- php_replace_controlchars_ex(ret->pass, (p-pp));
- }
+ ret->pass = estrndup(pp, (p-pp));
+ php_replace_controlchars_ex(ret->pass, (p-pp));
} else {
ret->user = estrndup(s, (p-s));
php_replace_controlchars_ex(ret->user, (p-s));
diff --git a/ext/standard/var.c b/ext/standard/var.c
index 53fd54c647..6e5bd703d3 100644
--- a/ext/standard/var.c
+++ b/ext/standard/var.c
@@ -163,13 +163,10 @@ again:
return;
}
- if (Z_OBJ_HANDLER_P(struc, get_class_name)) {
- class_name = Z_OBJ_HANDLER_P(struc, get_class_name)(Z_OBJ_P(struc), 0 TSRMLS_CC);
- php_printf("%sobject(%s)#%d (%d) {\n", COMMON, class_name->val, Z_OBJ_HANDLE_P(struc), myht ? zend_obj_num_elements(myht) : 0);
- zend_string_release(class_name);
- } else {
- php_printf("%sobject(unknown class)#%d (%d) {\n", COMMON, Z_OBJ_HANDLE_P(struc), myht ? zend_obj_num_elements(myht) : 0);
- }
+ class_name = Z_OBJ_HANDLER_P(struc, get_class_name)(Z_OBJ_P(struc) TSRMLS_CC);
+ php_printf("%sobject(%s)#%d (%d) {\n", COMMON, class_name->val, Z_OBJ_HANDLE_P(struc), myht ? zend_obj_num_elements(myht) : 0);
+ zend_string_release(class_name);
+
if (myht) {
zend_ulong num;
zend_string *key;
@@ -334,7 +331,7 @@ again:
myht->u.v.nApplyCount++;
}
}
- class_name = Z_OBJ_HANDLER_P(struc, get_class_name)(Z_OBJ_P(struc), 0 TSRMLS_CC);
+ class_name = Z_OBJ_HANDLER_P(struc, get_class_name)(Z_OBJ_P(struc) TSRMLS_CC);
php_printf("%sobject(%s)#%d (%d) refcount(%u){\n", COMMON, class_name->val, Z_OBJ_HANDLE_P(struc), myht ? zend_obj_num_elements(myht) : 0, Z_REFCOUNT_P(struc));
zend_string_release(class_name);
if (myht) {
@@ -456,7 +453,6 @@ PHPAPI void php_var_export_ex(zval *struc, int level, smart_str *buf TSRMLS_DC)
HashTable *myht;
char *tmp_str;
size_t tmp_len;
- zend_string *class_name;
zend_string *ztmp, *ztmp2;
zend_ulong index;
zend_string *key;
@@ -533,12 +529,10 @@ again:
smart_str_appendc(buf, '\n');
buffer_append_spaces(buf, level - 1);
}
- class_name = Z_OBJ_HANDLER_P(struc, get_class_name)(Z_OBJ_P(struc), 0 TSRMLS_CC);
- smart_str_append(buf, class_name);
+ smart_str_append(buf, Z_OBJCE_P(struc)->name);
smart_str_appendl(buf, "::__set_state(array(\n", 21);
- zend_string_release(class_name);
if (myht) {
ZEND_HASH_FOREACH_KEY_VAL_IND(myht, index, key, val) {
php_object_element_export(val, index, key, level, buf TSRMLS_CC);
@@ -727,8 +721,7 @@ static void php_var_serialize_class(smart_str *buf, zval *struc, zval *retval_pt
php_var_serialize_string(buf, Z_STRVAL_P(name), Z_STRLEN_P(name));
php_var_serialize_intern(buf, d, var_hash TSRMLS_CC);
} else {
- zend_class_entry *ce;
- ce = zend_get_class_entry(Z_OBJ_P(struc) TSRMLS_CC);
+ zend_class_entry *ce = Z_OBJ_P(struc)->ce;
if (ce) {
zend_string *prot_name, *priv_name;
@@ -838,13 +831,9 @@ again:
zval retval;
zval fname;
int res;
- zend_class_entry *ce = NULL;
-
- if (Z_OBJ_HT_P(struc)->get_class_entry) {
- ce = Z_OBJCE_P(struc);
- }
+ zend_class_entry *ce = Z_OBJCE_P(struc);
- if (ce && ce->serialize != NULL) {
+ if (ce->serialize != NULL) {
/* has custom handler */
unsigned char *serialized_data = NULL;
size_t serialized_length;