-
Notifications
You must be signed in to change notification settings - Fork 30
Fixes for invalid GMT offset when creating new DateTimeZone in post-edit widget #53
Conversation
…ction, and write a test for that that iterates over the known valid GMT offsets from WordPress's database. This is for #52
… the boilerplate from the 'wp scaffold plugin' command, without removing existing bootstrap.php functionality.
…story_publish_meta_box Fixes the error seen in https://travis-ci.com/npr/nprapi-wordpress/jobs/146555595 1) Test_MetaBoxes::test_nprstory_publish_meta_box Missing argument 1 for nprstory_publish_meta_box(), called in /tmp/wordpress/src/wp-content/plugins/nprapi-wordpress/tests/test-meta-boxes.php on line 17 and defined /tmp/wordpress/src/wp-content/plugins/nprapi-wordpress/meta-boxes.php:18 /tmp/wordpress/src/wp-content/plugins/nprapi-wordpress/tests/test-meta-boxes.php:17
…prstory_get_datetimezone_all The error message: 2) Test_PushStory::test_nprstory_get_datetimezone_all Use of undefined constant DateTimeZone - assumed 'DateTimeZone' /tmp/wordpress/src/wp-content/plugins/nprapi-wordpress/tests/test-push_story.php:163 Must pass the class.
Automated tests pass. Human-run tests should perform the following tasks:
|
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.
Code looks good to me
I have uploaded the master repo to our test WP site. I made posts and changed dates, but I am unable to get stories to or pull stories from the API. There could be some operator error here, however, when I tried to pull just one story, I got this error message. Do you think this error is related to plugin updates or something in our WP site's config? Any insights helpful. Thank you. |
There's two issues there: "non-static method DS_NPR_API::load_page_hook() should not be called statically" — this should not prevent the page from loading. "call to undefined function simplexml_load_string()" — this has me puzzled, because that function appears to be a standard part of PHP. Was your test server's PHP compiled without the SimpleXML extension? https://secure.php.net/manual/en/simplexml.setup.php |
Changes
DateTimeZone
object from the database, moves that construction into its own separate testable functionnprstory_get_datetime()
''
empty-string option_value of'gmt_offset'
, which is what this plugin was tested under in the first place.Notes
'timezone_string'
because WordPress uses that value in the functionwp_timezone_override_offset
which is a filter upon the output ofget_option( 'gmt_offset' );
Why
#52 is described based on an email from Erin, and is caused by
DateTimeZone::__construct()
not accepting GMT offsets in the format that WordPress saves them in the database. WordPress saves them as decimal hours; PHP'sDateTimeZone::__construct()
seems to want the offset in seconds. I say "seems" because it's not explicitly described as such in any php.net documentation, but the documentation forDateTimeZone::listAbbreviations()
and the output of that function both describe offsets in numbers that only make sense as whole hours if the number displayed is a number of hours multiplied by360
.As a sample:
The time zone "America/Porto_Acre" has an offset
-14400
.-14400
divided by powers of ten doesn't seem correct.-14400
divided by 60 is-240
; divided by60*60=360
is-4
. Checking https://en.wikipedia.org/wiki/List_of_tz_database_time_zones shows that the offset for "America/Porto_Acre" is presently-05:00
. The one-hour discrepancy between-4
and-05:00
is explained by "America/Porto_Acre" being subject to daylight saving time.Fixes #52.