[wp-trac] [WordPress Trac] #58986: TypeError: Unsupported operand types: string * int *

WordPress Trac noreply at wordpress.org
Sat Aug 5 19:05:33 UTC 2023


#58986: TypeError: Unsupported operand types: string * int *
--------------------------+------------------------------------------
 Reporter:  nurielmeni    |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Date/Time     |     Version:  6.2.2
 Severity:  critical      |  Resolution:
 Keywords:  needs-patch   |     Focuses:  rest-api, php-compatibility
--------------------------+------------------------------------------
Changes (by sabernhardt):

 * keywords:   => needs-patch
 * focuses:  php-compatibility => rest-api, php-compatibility
 * component:  REST API => Date/Time


Old description:

> Path: /wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
> File: class-wp-rest-posts-controller.php
> Line: 1833
>
> **Expression Error: get_option('gmt_offset') * HOUR_IN_SECONDS
> **Rais Exception: TypeError: Unsupported operand types: string * int
>

> Suggested Fix: intval(get_option('gmt_offset')) * HOUR_IN_SECONDS
>
> Thanks

New description:

 Path: `/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php`
 File: `class-wp-rest-posts-controller.php`
 Line: 1833

 **Expression Error:** `get_option('gmt_offset') * HOUR_IN_SECONDS`
 **Rais Exception:** `TypeError: Unsupported operand types: string * int`


 Suggested Fix: `intval(get_option('gmt_offset')) * HOUR_IN_SECONDS`

 Thanks

--

Comment:

 Hi and thanks for the ticket!

 `WP_REST_Posts_Controller::prepare_item_for_response()` probably needs the
 same change as the `current_time()` function in #57035. Note: the offset
 is not always an integer (#57998).

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


More information about the wp-trac mailing list