Skip to content

Conversation

flaupretre
Copy link
Contributor

This PR allows to test several potential changes in the ZPP ruleset, which is used when parsing internal function input arguments and will be potentially used for scalar type hinting.

Potential changes can be activated one by one or in any combination. Configuration is done by setting/unsetting values in Zend/zend_tmp_sth.h before compilation.

Please run configure with the '--disable-phar' option when testing this, as building phar.phar breaks when 'null to string' conversion is disabled (this is caused by a bug in phar code, and I don't have time to fix it).

The set of available flags will be extended when needed to propose additional restrictions or changes in behavior.

This conditional stuff is temporary and exists only as an addtional help for testing potential BC breaks before a final ruleset is voted upon. It will in no way be kept in the future released code.

@flaupretre flaupretre changed the title ZPP PHP 7 ruleset ZPP changes evaluation tool Feb 23, 2015
#if STH_DISABLE_NULL_TO_STRING
} else {
return 0;
#endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need an else here to prevent a segfault (null pointer). I added a goto to the conversion logic in an else branch and it worked fine:

@@ -1241,6 +1241,9 @@ static zend_always_inline int zend_parse_arg_str(zval *arg, zend_string **dest,
 #if STH_DISABLE_NULL_TO_STRING 
                        } else {
                                return 0;
+#else
+            } else {
+                goto convert;        
 #endif
                        }
 #if STH_DISABLE_BOOL_TO_STRING
@@ -1248,6 +1251,7 @@ static zend_always_inline int zend_parse_arg_str(zval *arg, zend_string **dest,
                        return 0;
 #endif
                } else {
+convert:
                        if (Z_COPYABLE_P(arg) && Z_REFCOUNT_P(arg) > 1) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems I fixed it almost the same way before I saw your comment. Fixed another small bug. Hope it's cleaner now. Thanks.

return 0;
#endif
#if STH_DISABLE_STRING_TO_BOOL
} else if (Z_TYPE_P(arg) == IS_DOUBLE) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo. should be IS_STRING

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Thanks

@smalyshev smalyshev added the RFC label Mar 9, 2015
@nikic
Copy link
Member

nikic commented Mar 30, 2015

Closing as the corresponding RFC was rejected.

@nikic nikic closed this Mar 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants