Py-Image / PL_PYIS_MEPR_LTV

0 stars 0 forks source link

Fatal error for timezone #15

Open joelworsham opened 7 years ago

joelworsham commented 7 years ago

Just installed/activated for first time and went to the LTV submenu. Got this fatal error:

Xdebug: Fatal error: Uncaught Exception: DateTimeZone::__construct(): Unknown or bad timezone () in /srv/www/wordpress-develop/public_html/src/wp-content/plugins/PL_PYIS_MEPR_LTV-master/core/admin/class-pyis-mepr-ltv-admin.php:285 **Stack trace:** - 0 /srv/www/wordpress-develop/public_html/src/wp-content/plugins/PL_PYIS_MEPR_LTV-master/core/admin/class-pyis-mepr-ltv-admin.php(285): DateTimeZone->__construct('') - 1 /srv/www/wordpress-develop/public_html/src/wp-content/plugins/PL_PYIS_MEPR_LTV-master/core/admin/class-pyis-mepr-ltv-admin.php(122): PYIS_MEPR_LTV_Admin->date_i18n_timezone('F j, Y \\a\\t g:i...', 1487606397) - 2 /srv/www/wordpress-develop/public_html/src/wp-includes/class-wp-hook.php(298): PYIS_MEPR_LTV_Admin->page_content('') - 3 /srv/www/wordpress-develop/public_html/src/wp-includes/class-wp-hook.php(323): WP_Hook->apply_filters('', Array) - 4 /srv/www/wordpress-develop/public_html/src/wp-includes/plugin.php(453): WP_Hook->do_action(Array) - 5 /srv/www/wordpress-develop/public_html/src/wp-admin/admin.php(222): do_action('memb in /srv/www/wordpress-develop/public_html/src/wp-content/plugins/PL_PYIS_MEPR_LTV-master/core/admin/class-pyis-mepr-ltv-admin.php on line 285. Output triggered in /srv/www/wordpress-develop/public_html/src/wp-content/plugins/query-monitor/collectors/php_errors.php on line 163

joelworsham commented 7 years ago

Did more research. The issue is that you pass the timezone string from the options table, but that option is empty until set: https://github.com/realbig/PL_PYIS_MEPR_LTV/blob/master/core/admin/class-pyis-mepr-ltv-admin.php#L281

WP Core has a default when there is no option setup, but it's a few lines of code: https://github.com/WordPress/WordPress/blob/master/wp-admin/options-general.php#L170-L187

d4mation commented 7 years ago

From @joelworsham on Slack:

Use something like this when creating the Transient instead of converting to the Timezone on Display of the String.

$expiration = date_i18n(
    get_option( 'date_format', 'F j, Y' ),
    (int) $expiration + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) 
);
d4mation commented 7 years ago

@joelworsham If you get the chance, could you check out the issue/15/timezone-fatal-error branch? I think I've got this sorted out thanks to your help.