Skip to content

Conversation

@jhdxr
Copy link
Member

@jhdxr jhdxr commented Aug 13, 2017

this PR update the properties of DateTimeZone immediately after the object created. this should solve #68406 and #74940

btw, I found this patch cannot apply to php 7.1 or above and master, since php_error_docref has been replaced with zend_throw_error in those branches. I'm not sure if I need to open a new PR targeting php 7.1 for this problem.

@jhdxr jhdxr force-pushed the bugfix/68406 branch 2 times, most recently from c86515c to a02a690 Compare August 13, 2017 14:40
return FAILURE;
}
if (SUCCESS == timezone_initialize(*tzobj, Z_STRVAL_P(z_timezone), Z_STRLEN_P(z_timezone))) {
printf("testtest\n");
Copy link
Contributor

Choose a reason for hiding this comment

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

I presume this shouldn't be here?

Copy link
Member Author

Choose a reason for hiding this comment

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

@tpunt oh sorry, it seems I forget to push my latest commit...

@jhdxr jhdxr force-pushed the bugfix/68406 branch 2 times, most recently from 8e2e17b to 98ccb51 Compare August 13, 2017 17:08
@krakjoe
Copy link
Member

krakjoe commented Aug 14, 2017

Please do open PR(s) for the other branches ...

@krakjoe krakjoe added the Bug label Aug 14, 2017
@andrewnester
Copy link
Contributor

@jhdxr @krakjoe seems like php_error_docref is still in PHP-7.1+ branches
https://github.com/php/php-src/blob/PHP-7.1/main/php.h#L329

return props;
} /* }}} */

static inline void date_object_update_properties_timezone(zval *object) /* {{{ */
Copy link
Contributor

Choose a reason for hiding this comment

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

just for clarification - you decided to create new inline function just to have more obvious function name, am I right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep. IMHO I'd like to rewrite these parts of code, since I think get_properties should do retrieve only, updating data inside should have been forbidden. but it's really a huge project, and modifying a code which still can work is not a good idea, so I just leave them alone.

@krakjoe
Copy link
Member

krakjoe commented Aug 14, 2017

I haven't read the patch in detail, only done triage ... if other patches are needed, they need to exist before merge can happen is all I'm saying at this point ...

@jhdxr
Copy link
Member Author

jhdxr commented Aug 14, 2017

@andrewnester I guess the php_error_docref is still there just because of the BC for other extensions, like those in PECL. the code inside this repo has been replace since this commit: 771e5cc

@jhdxr
Copy link
Member Author

jhdxr commented Aug 14, 2017

@krakjoe ok, I'll ping you after I've provided all the necessary patches.

@andrewnester
Copy link
Contributor

@jhdxr not sure that php_error_docref is left just because of BC.
zend_throw_error and php_error_docref have different purposes as far as I remember - one is to use it inside Zend code, the second - in extensions.
I also tried to search for internals discussion about deprecation of php_error_docref - haven't found anything

@nikic
Copy link
Member

nikic commented Aug 14, 2017

zend_throw_error throws an Error exception. You're probably thinking about zend_error, which is kinda similar to php_error_docref (but well, without the "docref" part). In any case, none of those are deprecated.

@jhdxr jhdxr changed the title bugfix for #68406 #74940 [php7.0] bugfix for #68406 #74940 Aug 14, 2017
@jhdxr
Copy link
Member Author

jhdxr commented Aug 14, 2017

@krakjoe I'm all set.
this one for 7.0
#2685 for 7.1
#2686 for 7.2 and master.

@nikic
Copy link
Member

nikic commented Aug 19, 2017

@derickr Are any properties supposed to be exposed on DateTimeZone or is this just the usual get_properties side effect?

If DateTimeZone is not intended to expose properties, then the proper way to fix the comparison issue is by implementing a comparison handler.

@jhdxr
Copy link
Member Author

jhdxr commented Aug 19, 2017

@nikic I took implementing compare_objects into consideration, but the problem is how to define the rules of greater than and less than for DateTimeZone.

In fact, there are lots of issues on bugs.php.net of date extension which are caused by the same reason, get_properties updates the inner property, and leads to inconsistent behaviors.

@nikic
Copy link
Member

nikic commented Aug 22, 2017

I took implementing compare_objects into consideration, but the problem is how to define the rules of greater than and less than for DateTimeZone.

This patch doesn't solve that though, it just ignores it. Now it will use the default object property comparison semantics, which most likely will not result in any sensible behavior.

The "standard" way of handling non-trichotomous comparisons in PHP to is always return "greater" for non-equal comparisons. Together with the fact that the "$a > $b" comparison is defined as "$b < $a", this means that all non-equality comparisons return false. This is not perfect, but the only possibility we really have right now.

In fact, there are lots of issues on bugs.php.net of date extension which are caused by the same reason, get_properties updates the inner property, and leads to inconsistent behaviors.

Indeed. This is a long standing issue caused by the lack of specific object handlers for serialization (and in the case of DateTime objects, unfortunately also var_exporting).

@jhdxr
Copy link
Member Author

jhdxr commented Aug 23, 2017

The "standard" way of handling non-trichotomous comparisons in PHP to is always return "greater" for non-equal comparisons.

I suggest to add this to https://wiki.php.net/internals/engine/objects#compare_objects. I cannot find an implementation meeting all the requirements, so I just use the default handler. And yes, I know it doesn't make sense for DateTimeZone.

Indeed. This is a long standing issue caused by the lack of specific object handlers for serialization (and in the case of DateTime objects, unfortunately also var_exporting).

This is a point people usually used to blame php. IMHO, we should put our priority on standards. If we had a standard of the internal namespace, the arguments that sodium should use namespace or not wouldn't happen. In addtion, it also bring the possibilty to standlize and clean up the existed functions. There are many things we can do without BC break.

Back to the issue here, I can use compare_objects to fix #74940, and use get_debug_info to fix #68406. But I think it doesn't fix the root cause of these problem. An method named getXXX are supposed to do, and only do retrive. Maybe I should send an email to internal see other people's idea on these object handlers, and then someone may start an RFC to standlize these things.

@derickr
Copy link
Member

derickr commented Aug 29, 2017

@nikic These properties should only be exposed through the debug handler. As they are read only and meant for debugging only.

@derickr
Copy link
Member

derickr commented Aug 29, 2017

@jhdxr Greater than should probably done on:

  1. timezone_type

And then depending on type:

  1. UTC offset
  2. UTC offset (plus an extra hour if the DST flag is set)
  3. Time Zone Identifier

@jhdxr
Copy link
Member Author

jhdxr commented Sep 10, 2017

@derickr ok. I'll create a new pr to fix 68406 by implementing get_debug_info, since the properties are not supoosed to be exposed. However, I don't think the rules of greater than you provided make sense. Shouldn't we put offset at the first priority? or maybe you think there is no meaningful compare rule, and we just need a consistent rule?

anyway, I'm closing #2685 and #2686, and leave this one open for discussion.

@arjenschol
Copy link

#2766 stil isn't merged.

And just spent an hour finding out this is also a problem in DateInterval and DatePeriod:

DateInterval: https://3v4l.org/3FaWi
DatePeriod: https://3v4l.org/LBOMs

And already forgot about this issue...

@jhdxr
Copy link
Member Author

jhdxr commented Mar 18, 2018

abandoned

@jhdxr jhdxr closed this Mar 18, 2018
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.

7 participants