Skip to content

Fix #44383: PHP DateTime not converted to xsd:datetime #12437

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

Closed
wants to merge 4 commits into from

Conversation

nielsdos
Copy link
Member

Fixes https://bugs.php.net/bug.php?id=44383
Marking as draft as I've asked Derick for input on the date API.

@@ -841,6 +841,11 @@ static zend_string *date_format(const char *format, size_t format_len, timelib_t
return string.s;
}

PHPAPI zend_string *php_format_date_ex(const char *format, size_t format_len, timelib_time *t, bool localtime)
Copy link
Member

Choose a reason for hiding this comment

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

I think I would prefer it if timelib_time does not get (more) exposed to the external API. Would it perhaps make more sense to have this function accept a php_date_obj instead of a timelib_time?

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed. I vaguely recall having talked about exactly that in room 11 actually.
I changed the signature and function name.

@nielsdos nielsdos marked this pull request as ready for review November 22, 2023 18:37
if (instanceof_function_slow(Z_OBJCE_P(data), php_date_get_interface_ce())) {
php_date_obj *dateobj = Z_PHPDATE_P(data);
if (dateobj->time) {
zend_string *formatted = php_format_date_obj(ext_date_format, ext_date_format_len, dateobj);
Copy link
Member

Choose a reason for hiding this comment

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

You're testing for time here, but IMO that should be done in the new php_format_date_obj function, which, if it returns NULL, can then else into your error message branch?

Copy link
Member Author

Choose a reason for hiding this comment

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

Right of course, that makes sense

Copy link
Member

@Girgias Girgias left a comment

Choose a reason for hiding this comment

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

Ideally this should add a zend_module_dependency struct into the module entry, a bit like XMLReader:

static const zend_module_dep soap_deps[] = {
	ZEND_MOD_REQUIRED("date")
	ZEND_MOD_END
};

@nielsdos
Copy link
Member Author

I guess so? Although date is always available. And if it were not then the module won't even load: it would fail at dlopen even before the dependencies are checked so it is a bit pointless anyway to add the dependency requirement.
But I'll add it anyway for completeness.

@derickr
Copy link
Member

derickr commented Dec 8, 2023

FWIW, I don't think it would fail at dlopen(), unless we've changed away from RTLD_LAZY.

Copy link
Member

@derickr derickr left a comment

Choose a reason for hiding this comment

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

LGTM

@nielsdos nielsdos closed this in b34b4d5 Dec 8, 2023
@nielsdos
Copy link
Member Author

nielsdos commented Dec 8, 2023

FWIW, I don't think it would fail at dlopen(), unless we've changed away from RTLD_LAZY.

Ah right, I somehow forgot this was the default instead of RTLD_NOW.

Thanks for reviewing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants