• Resolved Seath

    (@seath)


    Hello I keep getting this error when I visit the statistics page.

    Fatal error: Uncaught TypeError: burst_statistics::convert_date_to_utc(): Return value must be of type int, string returned in /wp-content/plugins/burst-statistics/statistics/class-statistics.php:665
    
    Stack Trace
    1.	
    burst_statistics->convert_date_to_utc(' 00:00:00')
    /wp-content/plugins/burst-statistics/settings/settings.php:363
    2.	
    burst_get_data(Object(WP_REST_Request))
    /wp-includes/rest-api/class-wp-rest-server.php:1171
    3.	
    WP_REST_Server->respond_to_request(Object(WP_REST_Request), '/burst/v1/data/...', Array, NULL)
    /wp-includes/rest-api/class-wp-rest-server.php:1018
    4.	
    WP_REST_Server->dispatch(Object(WP_REST_Request))
    /wp-includes/rest-api/class-wp-rest-server.php:442
    5.	
    WP_REST_Server->serve_request('/burst/v1/data/...')
    /wp-includes/rest-api.php:410
    6.	
    rest_api_loaded(Object(WP))
    /wp-includes/class-wp-hook.php:308
    7.	
    WP_Hook->apply_filters('', Array)
    /wp-includes/class-wp-hook.php:332
    8.	
    WP_Hook->do_action(Array)
    /wp-includes/plugin.php:565
    9.	
    do_action_ref_array('parse_request', Array)
    /wp-includes/class-wp.php:399
    10.	
    WP->parse_request('')
    /wp-includes/class-wp.php:780
    11.	
    WP->main('')
    /wp-includes/functions.php:1332
    12.	
    wp()
    /wp-blog-header.php:16
    13.	
    require('/home/niowaholt...')
    /index.php:17
    14.	
    {main}
    thrown in /wp-content/plugins/burst-statistics/statistics/class-statistics.php on line 665

Viewing 15 replies - 1 through 15 (of 20 total)
  • Plugin Author Rogier Lankhorst

    (@rogierlankhorst)

    @seath which php version are you using?

    I’ve created a fix that should catch this error:
    https://github.com/Really-Simple-Plugins/burst/tree/cast-timestamp-to-int

    Let me know if that resolves your issue.

    Thread Starter Seath

    (@seath)

    @rogierlankhorst

    PHP Version: 8.0.27

    Sorry it didn’t worked. I am getting the same error.

    Plugin Author Rogier Lankhorst

    (@rogierlankhorst)

    @seath I can’t reproduce the error yet, but I think I know where the issue is coming from: a function which converts dates to a Unix timestamp returns the string when the date isn’t understood, but it should always return a unix int.

    Can you try this branch again?
    https://github.com/Really-Simple-Plugins/burst/tree/cast-timestamp-to-int

    What date time format do you use on your site? If I can reproduce the exact settings, I can test myself if the change works. Haven’t found the configuration yet.

    Thread Starter Seath

    (@seath)

    @rogierlankhorst I am using F j, Y date, and g:i A time format.

    The error changed after the last branch…

    Fatal error: Uncaught Error: Undefined constant "_IN_SECONDS" in /wp-content/plugins/burst-cast-timestamp-to-int/statistics/class-statistics.php:760
    
    Stack Trace
    1.	
    constant('_IN_SECONDS')
    /wp-content/plugins/burst-cast-timestamp-to-int/statistics/class-statistics.php:760
    2.	
    burst_statistics->get_nr_of_periods('', 1674540000, 1674626399)
    /wp-content/plugins/burst-cast-timestamp-to-int/statistics/class-statistics.php:296
    3.	
    burst_statistics->get_insights_data(Array)
    /wp-content/plugins/burst-cast-timestamp-to-int/settings/settings.php:375
    4.	
    burst_get_data(Object(WP_REST_Request))
    /wp-includes/rest-api/class-wp-rest-server.php:1171
    5.	
    WP_REST_Server->respond_to_request(Object(WP_REST_Request), '/burst/v1/data/...', Array, NULL)
    /wp-includes/rest-api/class-wp-rest-server.php:1018
    6.	
    WP_REST_Server->dispatch(Object(WP_REST_Request))
    /wp-includes/rest-api/class-wp-rest-server.php:442
    7.	
    WP_REST_Server->serve_request('/burst/v1/data/...')
    /wp-includes/rest-api.php:410
    8.	
    rest_api_loaded(Object(WP))
    /wp-includes/class-wp-hook.php:308
    9.	
    WP_Hook->apply_filters('', Array)
    /wp-includes/class-wp-hook.php:332
    10.	
    WP_Hook->do_action(Array)
    /wp-includes/plugin.php:565
    11.	
    do_action_ref_array('parse_request', Array)
    /wp-includes/class-wp.php:399
    12.	
    WP->parse_request('')
    /wp-includes/class-wp.php:780
    13.	
    WP->main('')
    /wp-includes/functions.php:1332
    14.	
    wp()
    /wp-blog-header.php:16
    15.	
    require('/home/nownow/pu...')
    /index.php:17
    16.	
    {main}
    thrown in /wp-content/plugins/burst-cast-timestamp-to-int/statistics/class-statistics.php on line 760
    

    And there are two warnings now….

    Warning: Trying to access array offset on value of type null in /wp-content/plugins/burst-cast-timestamp-to-int/settings/settings.php on line 374
    
    and
    
    Warning: Undefined variable $data in /wp-content/plugins/burst-cast-timestamp-to-int/statistics/class-statistics.php on line 575
    Plugin Author Rogier Lankhorst

    (@rogierlankhorst)

    @seath thanks for the details bug reports, that helps!

    It looks like the Rest Request that is retrieving the statistics overview does not receive the parameters for this specific request. In one location the fallback to a missing interval is not ‘day’, but ”, this results in several notices and errors. I’ve added fixes for that, which should fix the errors.

    The interesting part is why the ‘interval’ array key is missing in the first place. I don’t think it’s related to the date format.

    Can you try the latest version of the above branch? The above warnings should be resolved, but please check if the graph (for which this request is made) is showing the correct range etc.

    Thread Starter Seath

    (@seath)

    @rogierlankhorst The graph is showing up but its all the way cross on 0 line. And I still getting a Warning.

    Warning: Trying to access array offset on value of type null in /wp-content/plugins/burst-cast-timestamp-to-int/settings/settings.php on line 375
    Plugin Author Rogier Lankhorst

    (@rogierlankhorst)

    I have updated the above warning, missed that one.

    In the latest version this is fixed. Possibly it caused the empty statistics as well. This branch now also includes dynamic cache clearing if the cached data is empty.

    Thread Starter Seath

    (@seath)

    @rogierlankhorst I’m guessing the branch wasn’t updated, because the problem is still there.

    Plugin Author Rogier Lankhorst

    (@rogierlankhorst)

    I’m sorry you’re right, I forgot to push to github…. Done now.

    Thread Starter Seath

    (@seath)

    @rogierlankhorst I am sorry to do that to you, but the graph is still on 0 and now I am getting all this stuff in my error file….

     
    Jan 25, 06:21:14
    
    Array
    (
    [date_start] => 1674626400
    [date_end] => 1674712799
    [date_range] => custom
    [metrics] => Array
    (
    )
    [interval] => day
    )
    
     
    Jan 25, 06:21:14
    
    insights args
    
     
    
    )
    
     
    
    [parsed_body:protected] =>
    
     
    
    [parsed_json:protected] => 1
    
     
    
    )
    
     
    
    )
    
     
    
    (
    
     
    
    [permission_callback] => Closure Object
    
     
    
    [callback] => burst_get_data
    
     
    
    )
    
     
    
    (
    
     
    
    [args] => Array
    
     
    
    [show_in_index] => 1
    
     
    
    [accept_raw] =>
    
     
    
    [accept_json] =>
    
     
    
    )
    
     
    
    [GET] => 1
    
     
    
    (
    
    Mark as fixed | Ignore
     
    
    [methods] => Array
    Plugin Author Rogier Lankhorst

    (@rogierlankhorst)

    @seath No problem at all! I put those logs in there to see if the request data is correct. The logs you posted shows me that the metric is not there, so I’ve adjusted for that as well.

    Thanks for taking the time to check this. It’s difficult to test otherwise!

    I’ve pushed the latest changes to github (including the logs still, will remove them if we’ve resolved it).

    Thread Starter Seath

    (@seath)

    @rogierlankhorst Ok this is what I am getting now….

    Fatal error: Uncaught TypeError: Illegal offset type in isset or empty in /wp-content/plugins/burst-cast-timestamp-to-int/statistics/class-statistics.php:110
    
    Stack Trace
    1.	
    burst_statistics->sanitize_metric(Array)
    /wp-content/plugins/burst-cast-timestamp-to-int/settings/settings.php:369
    2.	
    burst_get_data(Object(WP_REST_Request))
    /wp-includes/rest-api/class-wp-rest-server.php:1171
    3.	
    WP_REST_Server->respond_to_request(Object(WP_REST_Request), '/burst/v1/data/...', Array, NULL)
    /wp-includes/rest-api/class-wp-rest-server.php:1018
    4.	
    WP_REST_Server->dispatch(Object(WP_REST_Request))
    /wp-includes/rest-api/class-wp-rest-server.php:442
    5.	
    WP_REST_Server->serve_request('/burst/v1/data/...')
    /wp-includes/rest-api.php:410
    6.	
    rest_api_loaded(Object(WP))
    /wp-includes/class-wp-hook.php:308
    7.	
    WP_Hook->apply_filters('', Array)
    /wp-includes/class-wp-hook.php:332
    8.	
    WP_Hook->do_action(Array)
    /wp-includes/plugin.php:565
    9.	
    do_action_ref_array('parse_request', Array)
    /wp-includes/class-wp.php:399
    10.	
    WP->parse_request('')
    /wp-includes/class-wp.php:780
    11.	
    WP->main('')
    /wp-includes/functions.php:1332
    12.	
    wp()
    /wp-blog-header.php:16
    13.	
    require('/home/niowaholt...')
    /index.php:17
    14.	
    {main}
    thrown in /wp-content/plugins/burst-cast-timestamp-to-int/statistics/class-statistics.php on line 110

    The stats are all gone no information at all.

    Plugin Author Rogier Lankhorst

    (@rogierlankhorst)

    @seath sorry for that. I skipped a check and missed this.

    I pushed a change that correctly sanitizes the metric data, and makes sure there’s a fallback.

    I think we’re nearly there.

    Thread Starter Seath

    (@seath)

    @rogierlankhorst The graph is still on 0 line and back to this….

     
    Jan 25, 07:39:54
    
    Array
    (
    [date_start] => 1674626400
    [date_end] => 1674712799
    [date_range] => custom
    [metrics] => Array
    (
    [0] => visitors
    )
    [interval] => day
    )
    
     
    Jan 25, 07:39:54
    
    insights args
    
     
    
    )
    
     
    
    [parsed_body:protected] =>
    
     
    
    [parsed_json:protected] => 1
    
     
    
    )
    
     
    
    )
    
     
    
    (
    
     
    
    [permission_callback] => Closure Object
    
     
    
    [callback] => burst_get_data
    
     
    
    )
    
     
    
    (
    
     
    
    [args] => Array
    
     
    
    [show_in_index] => 1
    
     
    
    [accept_raw] =>
    
     
    
    [accept_json] =>
    
     
    
    )
    
     
    
    [GET] => 1
    
     
    
    (
    
     
    
    [methods] => Array
    Plugin Author Rogier Lankhorst

    (@rogierlankhorst)

    Ok, the logs are fine, the metric has a default now, and there’s an interval.

    Can you try to select a default range, for example “last 7 days”, and try several different ranges to see if the issue is on all ranges or just some?

Viewing 15 replies - 1 through 15 (of 20 total)
  • The topic ‘Fatal error: Uncaught TypeError’ is closed to new replies.