[wp-trac] [WordPress Trac] #56358: PHP8 TypeError on current_time( 'timestamp' ) if timezone is set to GMT / 0

WordPress Trac noreply at wordpress.org
Thu Mar 7 18:23:25 UTC 2024


#56358: PHP8 TypeError on current_time( 'timestamp' ) if timezone is set to GMT / 0
---------------------------+-----------------------
 Reporter:  toastercookie  |       Owner:  (none)
     Type:  defect (bug)   |      Status:  reopened
 Priority:  normal         |   Milestone:
Component:  Date/Time      |     Version:  6.0
 Severity:  minor          |  Resolution:
 Keywords:  php8           |     Focuses:
---------------------------+-----------------------
Changes (by verygoode):

 * status:  closed => reopened
 * resolution:  invalid =>


Comment:

 Encountered on a site, found that in some situations the `gmt_offset`
 option may get left empty -- seemingly due to plugin conflicts causing the
 save function to error out before `gmt_offset` gets stored.

 Here's an example set of reproduction instructions using WordPress 6.4.3
 and PHP 8.1.

 1. Install and activate aryo-activity-log
 2. Navigate to `/wp-admin/options-general.php` and change Timezone to UTC
 and Start of Week to Sunday
 3. Encounter the following fatal



 {{{
 PHP Fatal error:  Uncaught TypeError: Unsupported operand types: string *
 int in /wordpress/core/6.4.3/wp-includes/functions.php:76
 Stack trace:
 #0 /srv/htdocs/wp-content/plugins/aryo-activity-log/classes/class-aal-
 api.php(95): current_time('timestamp')
 #1 /srv/htdocs/wp-content/plugins/aryo-activity-log/classes/class-aal-
 api.php(186): AAL_API->insert(Array)
 #2 /srv/htdocs/wp-content/plugins/aryo-activity-log/hooks/class-aal-hook-
 options.php(105): aal_insert_log(Array)
 #3 /srv/htdocs/wp-content/plugins/aryo-activity-log/hooks/class-aal-hook-
 options.php(96): AAL_Hook_Options->insert_log('start_of_week')
 #4 /wordpress/core/6.4.3/wp-includes/class-wp-hook.php(324):
 AAL_Hook_Options->hooks_updated_option('start_of_week', '1', 0)
 #5 /wordpress/core/6.4.3/wp-includes/class-wp-hook.php(348):
 WP_Hook->apply_filters(NULL, Array)
 #6 /wordpress/core/6.4.3/wp-includes/plugin.php(517):
 WP_Hook->do_action(Array)
 #7 /wordpress/core/6.4.3/wp-includes/option.php(894):
 do_action('updated_option', 'start_of_week', '1', 0)
 #8 /wordpress/core/6.4.3/wp-admin/options.php(339):
 update_option('start_of_week', 0)
 #9 {main}
   thrown in /wordpress/core/6.4.3/wp-includes/functions.php on line 76
 }}}


 4. Observe that the `gmt_offset` option is empty in the database.
 5.
 Revisit `/wp-admin/options-general.php`, observe critical error message
 under Date Format option, lack of Save button. Observe the following
 fatal.


 {{{
 PHP Fatal error:  Uncaught TypeError: Unsupported operand types: string *
 int in /wordpress/core/6.4.3/wp-includes/functions.php:76
 Stack trace:
 #0 /wordpress/core/6.4.3/wp-includes/functions.php(180):
 current_time('timestamp', false)
 #1 /wordpress/core/6.4.3/wp-admin/options-general.php(364): date_i18n('F
 j, Y')
 #2 {main}
   thrown in /wordpress/core/6.4.3/wp-includes/functions.php on line 76
 }}}

 #### Resolving

 To resolve, give the `gmt_offset` option a value.

 E.g., via WP-CLI:  `wp option update gmt_offset 0`

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/56358#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list