Always the same, wrong Error Code: "Oops, an error occurred! Class '2' not found" - typo3

I am setting up a homepage with typo3 9.5.5, flux/fluidpages and vhs. Now always when i have some code error (syntax error for example) the Frontent show the Error "Oops, an error occurred! Class '2' not found", even when its obvious that it has nothing to do with a class 2.
I have no Classes-Folder in my custom Extension and no idea where it want a Class 2..
The full Error Code is "Core: Exception handler (WEB): Uncaught TYPO3 Exception: Class '2' not found | Error thrown in file /home/staff/typo3/typo3_src-9.5.5/typo3/sysext/core/Classes/Utility/GeneralUtility.php in line 3667."
The big Problem is, this Error always show up when an error happen, even when the typo3 is almost fresh and it doesnt matter what error it is. Tried to up/downgrade flux and fluidpages.
Can someone help me with this please?
When someone need some code for helping me, just say it.

Related

Flash Messages TYPO3 6 to 7 update

I used the following syntax in an TYPO3 6 exbase extension before migrating to 7:
$this->flashMessageContainer->flush();
$this->flashMessageContainer->getAllMessagesAndFlush();
$this->flashMessageContainer->add(Tx_Extbase_Utility_Localization::translate('undefined error', $this->extensionName));
In my new code I would use:
$this->addFlashMessage(\TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('undefined error', $this->extensionName));
But I always get this error:
Fatal error: Call to a member function getFlashMessageQueue() on a
non-object in /srv/www/typo3_src-7.6.32/typo3/sysext/extbase/Classes/Mvc/Controller/AbstractController.php on line 190
Any ideas about this behaviour?
Thanks and best regards,
Chris
(Disclaimer: TYPO3 v7.6 reached end-of-life and is not maintained anymore)
In order to understand what's going on, let's have a look into the source code (referring to the error message you posted, checking AbstractController.php)
$this->controllerContext->getFlashMessageQueue()->enqueue($flashMessage);
https://github.com/TYPO3/TYPO3.CMS/blob/TYPO3_7-6/typo3/sysext/extbase/Classes/Mvc/Controller/AbstractController.php#L190
$this->controllerContext = $this->buildControllerContext();
https://github.com/TYPO3/TYPO3.CMS/blob/TYPO3_7-6/typo3/sysext/extbase/Classes/Mvc/Controller/AbstractController.php#L238
Thus, my assumption(!) is, that you override public function processRequest(...) in your application specific controller without invoking parent::processRequest(...) leading to the situation that $this->controllerContext is not initialized.

Exception - Call to undefined function course_overviewfiles_options()

I am using a Moodle(3.2.2 the newest one) site created by php7.0 and mysql5.7,but when i try to add a new course as administrator, an error called :Exception - Call to undefined function course_overviewfiles_options(). What can i do to fix it?
I did 'Purge all caches' from Development,so the problem above disappeared,but
when users login, another error occurred: Exception - Call to undefined function core_login_get_return_url().
I did 'Purge all caches'again, the problem no.2 disappeared and the no.1 occurred again.
did you include the correct library resource file?
require_once($CFG->libdir. '/coursecatlib.php'); (I think)
HTH

TYPO3 - Ext cal - PHP Catchable Fatal Error

I use the Ext "cal", when I add an Image to an Event, i got this Error:
PHP Catchable Fatal Error: Object of class
TYPO3\CMS\Core\Resource\FileReference could not be converted to string
in typo3/sysext/core/Classes/Resource/ResourceFactory.php line 430 .
When I disable the Image everything is fine. Any Solutions for that?
TYPO3-Version: 6.2.27
Show your code or the error didn't happen. ;-)
Educated guess: you use a file reference in your view helper instead of using treatIdAsReference = "1"

"Oops, an error occurred! Code: 201601301501048.." in TYPO3 7.6

I installed the TYPO3 version 7.6 and after adding extension to my page I got the error:
"Oops, an error occurred! Code: 201512031647523f4d731f"
I am not getting meaning of this error and I also enable 'displayErrors' => 1, in local configuration but still not get meaningful error.
You need to switch off the "Content Object Exception Handler", which is an exception handler in new versions. If a content element/plugin throws an exception, it does no longer take down the whole site, but only itself. To disable it, set
config.contentObjectExceptionHandler = 0
Reference
Don't forget to re-enable the exception handler when going live, and in your live system, you can find the exception trace in your log files. Basically what Viktor Livakivskyi says in the other answer.
Basically it is date + hash, which makes each of such errors unique.
For development environment you may turn it off, as #Jost suggested.
But for production this is crucial to let it be turned on, so if some of your plugins or TS libs fails, it will not break the complete output and show "Oops an error occurred" without any info, but the message, you see now with a code.
The real user of a website can then report this code to you, and you can search for this code in your TYPO3 error log, which is by default located under typo3temp/logs/, unless you configured it different.
So, this feature really easies your life to find out user-generated errors.
You can open the file ./typo3/sysext/frontend/Classes/ContentObject/Exception/ProductionExceptionHandler.php
Search for the string Oops, an error occurred!.
Add a debug line directly after the function declaration.
/**
* Handles exceptions thrown during rendering of content objects
* The handler can decide whether to re-throw the exception or
* return a nice error message for production context.
*
* #param \Exception $exception
* #param AbstractContentObject $contentObject
* #param array $contentObjectConfiguration
* #return string
* #throws \Exception
*/
public function handle(\Exception $exception, AbstractContentObject $contentObject = null, $contentObjectConfiguration = array())
{
debug ($exception, 'handle $exception');
Then you use a debug extension, e.g. fh_debug.
This will give you an output like this. It shows you the backtrace of the call which lead to this error. The backtraces are shown in 2 formats. You can add more debug lines at the positions before the places from the backtraces, in order to have more information about the error.
<table><tbody><tr><td>index.php</td><td>34</td><td>call_user_func</td></tr><tr><td>index.php</td><td>33</td><td>run</td></tr><tr><td>Application.php</td><td>78</td><td>handleRequest</td></tr><tr><td>Bootstrap.php</td><td>302</td><td>handleRequest</td></tr><tr><td>RequestHandler.php</td><td>232</td><td>INTincScript</td></tr><tr><td>TypoScriptFrontendController.php</td><td>3478</td><td>recursivelyReplaceIntPlaceholdersInContent</td></tr><tr><td>TypoScriptFrontendController.php</td><td>3512</td><td>INTincScript_process</td></tr><tr><td>TypoScriptFrontendController.php</td><td>3564</td><td>cObjGetSingle</td></tr><tr><td>ContentObjectRenderer.php</td><td>859</td><td>render</td></tr><tr><td>ContentObjectRenderer.php</td><td>943</td><td>render</td></tr><tr><td>ContentObjectArrayContentObject.php</td><td>41</td><td>cObjGet</td></tr><tr><td>ContentObjectRenderer.php</td><td>805</td><td>cObjGetSingle</td></tr><tr><td>ContentObjectRenderer.php</td><td>859</td><td>render</td></tr><tr><td>ContentObjectRenderer.php</td><td>953</td><td>handle</td></tr><tr><td>ProductionExceptionHandler.php</td><td>53</td><td>debug</td></tr></tbody></table><br><table><tbody><tr><th>Object TYPO3\CMS\Core\Error\Exception</th></tr><tr><td>message</td><td class="el">PHP Catchable Fatal Error: Argument 1 passed to TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::render() must be an instance of TYPO3\CMS\Frontend\ContentObject\AbstractContentObject, null given, called in /home/myuser/public_html/neu/typo3_src-7.6.10/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php on line 1359 and defined in /home/myuser/public_html/neu/typo3_src-7.6.10/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php line 927</td></tr>
<tr><td>code</td><td class="el"><table><tbody><tr><th>Integer</th></tr><tr><td>1</td></tr></tbody></table></td></tr>
<tr><td>file</td><td class="el">/home/myuser/public_html/neu/typo3_src-7.6.10/typo3/sysext/core/Classes/Error/ErrorHandler.php</td></tr>
<tr><td>line</td><td class="el"><table><tbody><tr><th>Integer</th></tr><tr><td>111</td></tr></tbody></table></td></tr>
</tbody></table>
<h3>handle $exception</h3><hr>
Text, added later: In the meantime it is not necessary any more to edit the PHP file ProductionExceptionHandler.php of TYPO3. You just install and configure the extension fh_debug which now does the necessary step automatically.

How to Have a Detailed Trace of a Slim Application Error

I have 10000 lines of code outlining routes of my API implemented using the Slim Framework. However, I got an error message preg_match(): Compilation failed: two named subpatterns have the same name at offset 89. The problem is, I got the stack trace referring to this statement preg_match('/cost-centers...', '/overview/funds...', NULL) at the Slim Route.php. Now that my URLs are lengthy, I can't pinpoint which of the URLs have the same name.
Is there any way to have a more detailed stack trace instead of displaying these shortened format?
Thanks to mgansler for this tip.
I just used a custom error handler with PHP Exception::getTrace() function. I also turned the Slim's default debugging off to ensure that the custom error handler is invoked.
Code goes like this:
$app = new \Slim\Slim(array(
'debug' => false
));
$app->error(function (\Exception $e) use ($app) {
//enter manipulation of $e->getTrace()
//or just var_dump($e->getTrace()) but the format would be chaotic
});