bernhard Posted March 19, 2023 Share Posted March 19, 2023 Hey @adrian I'm getting an error when having a Nette ArrayHash in a session variable: Error: Object of class __PHP_Incomplete_Class could not be converted to string in /var/www/html/site/assets/cache/FileCompiler/site/modules/TracyDebugger/panels/RequestInfoPanel.php:813 Stack trace: #0 /var/www/html/site/assets/cache/FileCompiler/site/modules/TracyDebugger/tracy-2.10.x/src/Tracy/Bar/Bar.php(143): RequestInfoPanel->getPanel() #1 /var/www/html/site/assets/cache/FileCompiler/site/modules/TracyDebugger/tracy-2.10.x/src/Tracy/Bar/Bar.php(115): Tracy\Bar->renderPanels('') #2 /var/www/html/site/assets/cache/FileCompiler/site/modules/TracyDebugger/tracy-2.10.x/src/Tracy/Bar/Bar.php(89): Tracy\Bar->renderPartial('main') #3 /var/www/html/site/modules/TracyDebugger/tracy-2.10.x/src/Tracy/Debugger/DevelopmentStrategy.php(123): Tracy\Bar->render(Object(Tracy\DeferredContent)) #4 /var/www/html/site/assets/cache/FileCompiler/site/modules/TracyDebugger/tracy-2.10.x/src/Tracy/Debugger/Debugger.php(309): Tracy\DevelopmentStrategy->renderBar() #5 [internal function]: Tracy\Debugger::shutdownHandler() #6 {main} This fixes it for me: try { if (is_object($value)) $value = (string)$value; } catch (\Throwable $th) { try { $value = json_encode($value); } catch (\Throwable $th) { $value = $th->getMessage(); } } Link to comment Share on other sites More sharing options...
adrian Posted March 25, 2023 Share Posted March 25, 2023 Hey @bernhard - Is this how you have the complete block looking such that your new logic is only applied to objects, but when they are an array the behaviour isn't changed? BTW, this bit of code is a copy of PW's debug.inc file so you should let Ryan know about the needed change there as well. if(is_object($value)) { try { if (is_object($value)) $value = (string)$value; } catch (\Throwable $th) { try { $value = json_encode($value); } catch (\Throwable $th) { $value = $th->getMessage(); } } } if(is_array($value)) $value = print_r($value, true); Link to comment Share on other sites More sharing options...
bernhard Posted March 26, 2023 Author Share Posted March 26, 2023 Hey @adrian this is the whole block: // Session if (in_array('session', $panelSections)) { $session_oc = 0; $session = $this->sectionHeader(array('Key', 'Value')); foreach ($this->wire('session') as $key => $value) { if ( $key == 'tracyDumpItemsAjax' || $key == 'tracyDumpsRecorderItems' || $key == 'tracyEventItems' || $key == 'tracyMailItems' || $key == 'tracyIncludedFiles' || $key == 'tracyPostData' || $key == 'tracyGetData' || $key == 'tracyWhitelistData' || $key == 'tracyLoginUrl' ) continue; $session_oc++; try { if (is_object($value)) $value = (string)$value; } catch (\Throwable $th) { try { $value = json_encode($value); } catch (\Throwable $th) { $value = $th->getMessage(); } } if (is_array($value)) $value = print_r($value, true); $session .= "<tr><td>" . $this->wire('sanitizer')->entities($key) . "</td><td><pre>" . $this->wire('sanitizer')->entities($value) . "</pre></td></tr>"; } $session .= $sectionEnd; } 15 hours ago, adrian said: BTW, this bit of code is a copy of PW's debug.inc file so you should let Ryan know about the needed change there as well. Not sure about this and when that code is used. But I think we can ignore this request. I've changed my code to save values as plain array in the session. The session is not meant to store any type of object, so it's ok if it breaks I guess?! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now