#9730 closed defect (bug) (fixed)
The new date_i18n hook creates potential bugs in the admin interface
Reported by: | Denis-de-Bernardy | Owned by: | ryan |
---|---|---|---|
Milestone: | 2.8 | Priority: | normal |
Severity: | major | Version: | 2.8 |
Component: | I18N | Keywords: | has-patch tested commit |
Focuses: | Cc: |
Description
Details here:
http://core.trac.wordpress.org/ticket/7753#comment:17
If somebody write a plugin and use the new date_i18n hook to override calendar system or to localize date/time digits, it will corrupt the fields of publish date. While editing a post, the fields of its publish date/time should kept in Gregorian calendar with Latin digits to prevent such problem.
I'll scan through the various calls.
Attachments (10)
Change History (40)
#1
@
15 years ago
- Keywords has-patch needs-testing reporter-feedback added; needs-patch removed
patch looks good according to description on the linked comments. hook is date_i18n hook. i wonder if someone can provide a crazy conversion funktion for that hook sothat i can try to break it? a plugin as attachment would be nice sothat this can be tested easily.
#4
@
15 years ago
@kambiz: There are plenty more. Doing the wp-admin functions as I write.
@hakre: There is a latin2persian number formatting function in #7753.
strtr 0-9 into arbitrary strings is a good test too. :-)
#5
@
15 years ago
in function date_i18n() docblock should be changed to signal that parameter $unixtimestamp should be UTC value.
#6
follow-up:
↓ 14
@
15 years ago
there is one I'm not 100% on:
- wp_get_archives(), $text = mysql2date($archive_day_date_format, $date); no?
and the calendar function might need to be looked into.
#7
@
15 years ago
in function date_i18n() docblock should be changed to signal that parameter $dateformatstring should get a detailed description which of the formats. link to approriate resources online etc. .
#8
@
15 years ago
- Keywords reporter-feedback removed
@hakre: please upload the docblock patch.
@kambiz: 9730.diff changes every call to mysql2date that doesn't show on the front-end. Can you give that one a shot and verify that everything continues to work as expected when you translate latin digits to persian digits?
#10
@
15 years ago
docblock patch having my suggestions for date_i18n. testplugin that will convert any date into a mooddate. mooddate uses persian numbers and know only one year: the year I felt like a timeless beauty.
i will test 9730.diff now.
#12
@
15 years ago
admin interface remains functional. options screen, new/edit post, page, image, comment all work fine, no scripts seem to be breaking.
#13
@
15 years ago
archives and calendar are not translated, but that is what #7753 was about in the first place.
#14
in reply to:
↑ 6
@
15 years ago
Replying to Denis-de-Bernardy:
there is one I'm not 100% on:
- wp_get_archives(), $text = mysql2date($archive_day_date_format, $date); no?
and the calendar function might need to be looked into.
wp_get_archives() is a template function used in themes. should be okay to be hooked.
calender function? if you mean get_calendar() in genreal-template the I would say, is a place to take a look into:
$thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('${thisyear}0101', INTERVAL $d DAY) ), '%m')");
and it makes heavy use of $wp_locale.
patch looks good to me. i tested it in the backend and the frontend. where applicable, the translated date is displayed. editing for posts works as known.
#17
@
15 years ago
latest patch fixes an issue in the original one related to comment feeds. xml-rpc needs a few tests too.
#19
@
15 years ago
- Keywords commit added
and so is hakre... let's hope this quickly gets into trunk, as I wouldn't want to end up needing to redo it after trunk gets edited all over the place.
#20
@
15 years ago
@Ryan or Andrew -- this one is related and good to go as well:
http://core.trac.wordpress.org/attachment/ticket/7753/7753.2.diff
#21
@
15 years ago
- Keywords commit removed
mm, nm that. I'm going to give get_post_time() et al the same treatment as get_comment_time(), for consistency's sake.
#22
follow-up:
↓ 24
@
15 years ago
i could take a look into archives, that is especially wp_get_archives() in /wp-includes/general-template.php .
compareable with the calender stuff, this function uses misc approaches to translate date and time information:
- Just numbers. If only a fragment of a date/time is used (like year or day), often only a number is used.
- WP_locale / $wp_locale - this is used to translate month names etc.
- {{()}} - often the result is "translated" again.
i assume that all this is done sothat current users can already translate (at least some) of those values.
as denis already pointed, archives and calendar are not translated, but that is what #7753 is after.
to enable translation of archives and calendar, these functions must make use of date_i18n() or make use of the $translate (the 3rd) parameter of mysql2date().
i suggest to use that parameter at least for wp_get_archives() and get_calendar() in general-template.php.
other potention functions: the_date(), get_post_modified_time().
i must first read on how to get UTC timestamps from partial data values before continue.
@
15 years ago
same as 9730.diff, with a slightly different approach for get_post_time() and get_post_modified_time()
#24
in reply to:
↑ 22
@
15 years ago
Replying to hakre:
i could take a look into archives, that is especially wp_get_archives() in /wp-includes/general-template.php .
compareable with the calender stuff, this function uses misc approaches to translate date and time information:
#25
@
15 years ago
yeah i think it is a good idea to stop at this certain level. this will at least offer a lot more possibilities.
for the frontend / theme / widget areas some best practice suggestions should be made, like let's say, convert partially values (number of the year), convert it into a timestamp and the pass it over with the 'Y' formatstring to date_i18n() or mysql2date() with $translate = true.
plust +1 to have widgets with their own calendars. maybe archive strings are fixable, there is one myslq2date left i mean:
$text = mysql2date($archive_day_date_format, $date, true);
line 838. will add a patch for that one.
Patch for [wp-admin\includes\template.php] to fix the issue