-
Notifications
You must be signed in to change notification settings - Fork 7.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] 65672 - Allow DatePeriod extensions to have writable properties #3121
Conversation
Can this be used to write to DatePeriod native properties? |
According to the docs there aren't any public properties on the class, unless I've missed something? |
As we now use delayed wakeup in unserialization the original reason for preventing writes to properties has gone away, so this LGTM. |
If it was possible to arbitrarily change these properties, I'd expect malfunctions. |
Thanks for that Christoph, I'll take a look at ensuring any public properties are prevented from being updated and that we have tests for them. I'll also update the docs with any public properties I find |
1c88abb
to
4bff86f
Compare
I've re-written this PR now, it changes the current functionality from preventing writes to any properties, to only prevent writes to native properties. I've also added tests to ensure native properties can be read, to ensure they can't be written, and to ensure custom properties can be read and written. I've also submit a documentation patch via the Docbook Online Editor to list these public properties |
4bff86f
to
363fcb8
Compare
I only had a question about functionality. I didn't look at the patch or implementation, so I defer to @nikic — however, Travis tests show failed for this PR. |
363fcb8
to
ebb34f4
Compare
ebb34f4
to
a6a188a
Compare
a6a188a
to
a3442d8
Compare
I've rebased this against 7.3 to take advantage of the memory leak fix. |
get_properties() constructs these as fresh objects with no relation to the internals, there is no need to clone them again. Additionally the current implementation leaks memory, because the original objects are never freed (see PR #3121).
@duncan3dc I've fixed the leak in a109fdd, please rebase again. |
a3442d8
to
d190959
Compare
You'll also want to make similar modifications to date_period_read_property. The thing to test would be operations like |
d190959
to
8eafad5
Compare
@nikic Thanks for the help, I've updated now to handle the string properly, and ensure reading for modification is handled the same way |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Please be careful when merging up, I think in 7.4 you may need to change tests due to DateInterval comparison and in master you'll have to change the object handler signatures.
Do I remember right that you have php-src karma? If not, I can commit this change for you. |
@nikic I do, let me refactor those repeated property checks first though. Unless you'd prefer to get this merged sooner, in which case I'm happy for you to go ahead 👍 |
Although these properties are not currently documented, they've been publically available so we should ensure they remain so
8eafad5
to
3681261
Compare
I noticed an issue on |
3681261
to
5c05be5
Compare
It looks like the properties were prevented from being writable as part of a serialization fix: 0ee7155
However there are no tests for this, so it seems it may have been unintentional. Also a bug was opened and hasn't been marked as "not a bug" so this PR restores the previous functionality, and includes tests for it.