Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debug toolbar renderTimeline couses a non well formed numeric value encountered error #2034

Closed
mcsaygili opened this issue Jun 2, 2019 · 7 comments · Fixed by #2315
Closed

Comments

@mcsaygili
Copy link
Contributor

mcsaygili commented Jun 2, 2019

Describe the bug
Debug toolbar gives error when non well formed numeric value passed to renderTimeline
$offset = ((($row['start'] - $startTime) * 1000) / $displayTime) * 100;

workaround
use strtotime() or round() to $row['start']

CRITICAL - 2019-06-02 06:19:58 --> A non well formed numeric value encountered #0 C:\50.personal\01.cagon\dev10-cms\core\Debug\Toolbar.php(238): CodeIgniter\Debug\Exceptions->errorHandler(8, 'A non well form...', 'C:\\50.personal\\...', 238, Array) #1 C:\50.personal\01.cagon\dev10-cms\core\Debug\Toolbar\Views\toolbar.tpl.php(126): CodeIgniter\Debug\Toolbar->renderTimeline(Array, 1559445597.5886, 7, 40, Array) #2 C:\50.personal\01.cagon\dev10-cms\core\Debug\Toolbar.php(486): include('C:\\50.personal\\...') #3 C:\50.personal\01.cagon\dev10-cms\core\Debug\Toolbar.php(444): CodeIgniter\Debug\Toolbar->format(Array, 'html') #4 C:\50.personal\01.cagon\dev10-cms\app\Config\Events.php(39): CodeIgniter\Debug\Toolbar->respond() #5 [internal function]: CodeIgniter\Events\Events::Config\{closure}() #6 C:\50.personal\01.cagon\dev10-cms\core\Events\Events.php(187): call_user_func(Object(Closure)) #7 C:\50.personal\01.cagon\dev10-cms\core\CodeIgniter.php(226): CodeIgniter\Events\Events::trigger('pre_system') #8 C:\50.personal\01.cagon\dev10-cms\public\index.php(60): CodeIgniter\CodeIgniter->run() #9 C:\50.personal\01.cagon\dev10-cms\rewrite.php(37): require_once('C:\\50.personal\\...') #10 {main}

CodeIgniter 4 version
CodeIgniter 4.0.0-beta.3

Affected module(s)
Debug Toolbar

Expected behavior, and steps to reproduce if appropriate
Must be show the toolbar in the right corner

Context

  • OS: Windows 10
  • Web server 2.4.29
  • PHP version 7.3.5
@byazrail
Copy link
Contributor

renderTimeline find on system/Debug/Toolbar.php;
$offset and $length change to;

$offset = ((((float) $row['start'] - (float) $startTime) * 1000) / (float) $displayTime) * 100;
$length = (((float) $row['duration'] * 1000) / (float) $displayTime) * 100;

@MGatner
Copy link
Member

MGatner commented Aug 8, 2019

I've been running into this issue frequently the last week or so. I think there's a bigger underlying issue, perhaps where a timer isn't started? Has anyone solved this?

@jim-parry jim-parry added this to the 4.0.0-rc.2 milestone Sep 8, 2019
@jim-parry jim-parry modified the milestones: 4.0.0-rc.2, 4.0.0-rc.3 Sep 20, 2019
@jim-parry
Copy link
Contributor

How frequently does this happen?
There are three suggested workarounds above. Have any of you tried any of them?
Do they solve the problem? or just mask it?

@MGatner
Copy link
Member

MGatner commented Oct 7, 2019

I haven't had a chance to dig into it - I have a hunch that in my case it was related to failed sessions due to interlocking, but I will try to recreate and test the workarounds.

@jim-parry
Copy link
Contributor

I am inclined to apply oe of the workarounds and call it a day on this issue.
If there is an underlying one, eg a timer not started, that can be treated separately.

@MGatner
Copy link
Member

MGatner commented Oct 7, 2019

Not a bad idea, but I'm not sure we have enough information yet.

use strtotime() or round()

Those two workarounds have drastically different implications, suggesting that the "non well formed numeric value" in a time format in the former and some kind of un-castable float in the latter.

A first step might be type-hinting $startTime in the definition to see if that is causing an issue (doubtful):

	protected function renderTimeline(array $collectors, float $startTime, int $segmentCount, int $segmentDuration, array &$styles): string

Tracing back a couple of the collectors, it looks like the intent is for $row['start'] to be a float or int, so maybe a cast would fix this in the meantime?

@jim-parry
Copy link
Contributor

Adding a type hint for $startTime dpesn't break anything. Not sure it resolves the issue.
I will try some casting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants