Where is Magento session serialized? - php

I am getting this fatal error:
PHP Fatal error:
Uncaught exception 'Exception' with message
'Serialization of 'Mage_Core_Model_Config_Element' is not allowed'
in [no active file]:0 Stack trace: #0 {main}
thrown in [no active file] on line 0
I understand it is trying to serialize Mage_Core_Model_Config_Element and failing, yet I have never used getNode(), it's always getStoreConfig() for me.
I am happy to debug this, if I could just find WHERE it is being generated. Where is the Magento session being serialized?
Note: trying to echo the serialization in footer (like one thread suggested) does not work in this case. The session is not being set (cause of this error) and so there is no error when it gets to the footer...

I have found the error that caused this. However was interested in finding out where is the place to debug this, but as there is no proper answer to this, no reason to wait longer.
Anyways, the problem is adding a model object to session, which obviously then is a no-no. At one point or another it must contain that class of an element.

Related

Fatal error: Uncaught Error: Class 'Spyc' not found in app/code/DeviceDetector/Yaml/Spyc.php

I am facing the issue with order placing on Magento ver. 2.2.2. After complete the payment when I will redirect to website https://domainname/paypal/express/placeOrder/ page and error display on that page.
Please check the error below,
Fatal error: Uncaught Error: Class 'Spyc' not found in
/public_html/app/code/DeviceDetector/Yaml/Spyc.php:17 Stack trace: #0
/public_html/app/code/DeviceDetector/Parser/ParserAbstract.php(155):
DeviceDetector\Yaml\Spyc->parseFile('/p...') #1
/public_html/app/code/DeviceDetector/Parser/ParserAbstract.php(243):
DeviceDetector\Parser\ParserAbstract->getRegexes() #2
/public_html/app/code/DeviceDetector/Parser/Bot.php(53):
DeviceDetector\Parser\ParserAbstract->preMatchOverall() #3
/public_html/app/code/DeviceDetector/DeviceDetector.php(623):
DeviceDetector\Parser\Bot->parse() #4
/public_html/app/code/DeviceDetector/DeviceDetector.php(587):
DeviceDetector\DeviceDetector->parseBot() #5
/public_html/app/code/MageWorx/OrdersBase/Observer/OrderPlaced.php(107):
DeviceDetector\DeviceDetector->parse() #6
/public_html/vendor/magento/framework/Event/Invoker/InvokerDefault.php(72):
MageWorx\OrdersBase\Observer\OrderPlaced- in
/public_html/app/code/DeviceDetector/Yaml/Spyc.php on line 17
The error is seems related to the DeviceDetector plugin but I don’t know why this issue happen & I have check the particular lines mentioned in error but no solution found.
Please let me know how to resolve this issue. Thanks in Advance!
Can you add more details here, after what action this error start appear?
If you inject this class somewhere in constructor then I suggest you to run rm -rf generated/* because M2 dont update generated folder automatically if you change class that already generated in generation.
If its not work please share some context.

PHP Fatal error: Uncaught exception 'Exception'

I'm playing around with exceptions in PHP. For example, I have a script that reads a $_GET request and loads a file; If the file doesn't exists, an new exception should be thrown:
if ( file_exists( $_SERVER['DOCUMENT_ROOT'] .'/'.$_GET['image'] ) ) {
// Something real amazing happens here.
}
else {
throw new Exception("The requested file does not exists.");
}
The problem is that, when I try to supply an non existent file for the test, I got a 500 error instead of the exception message. The server log is the following:
[09-Jul-2013 18:26:16 UTC] PHP Fatal error: Uncaught exception 'Exception' with message 'The requested file does not exists.' in C:\sites\wonderfulproject\script.php:40
Stack trace:
#0 {main}
thrown in C:\sites\wonderfulproject\script.php on line 40
I wonder if I'm missing something real obvious here.
I've checked this question PHP fatal error: Uncaught exception 'Exception' with message but it's not quite like my issue, and have no concise answer.
Help, please?
* EDIT *
It seems this is something related to the throw keyword. If I use echo for example, I got the message printed on the screen, like this:
exception 'Exception' with message 'The file does not exists.' in C:\sites\wonderfulproject\script.php:183 Stack trace: #0 {main}
Why is that?
** EDIT 2 **
Thanks to #Orangepill, I got a better understanding about how to handle exceptions. And I found a superb tut from nettuts that helped a lot. The link: http://net.tutsplus.com/tutorials/php/the-ins-and-outs-of-php-exceptions/
This is expected behavior for an uncaught exception with display_errors off.
Your options here are to turn on display_errors via php or in the ini file or catch and output the exception.
ini_set("display_errors", 1);
or
try{
// code that may throw an exception
} catch(Exception $e){
echo $e->getMessage();
}
If you are throwing exceptions, the intention is that somewhere further down the line something will catch and deal with it. If not it is a server error (500).
Another option for you would be to use set_exception_handler to set a default error handler for your script.
function default_exception_handler(Exception $e){
// show something to the user letting them know we fell down
echo "<h2>Something Bad Happened</h2>";
echo "<p>We fill find the person responsible and have them shot</p>";
// do some logging for the exception and call the kill_programmer function.
}
set_exception_handler("default_exception_handler");
Just adding a bit of extra information here in case someone has the same issue as me.
I use namespaces in my code and I had a class with a function that throws an Exception.
However my try/catch code in another class file was completely ignored and the normal PHP error for an uncatched exception was thrown.
Turned out I forgot to add "use \Exception;" at the top, adding that solved the error.
For
throw new Exception('test exception');
I got 500 (but didn't see anything in the browser), until I put
php_flag display_errors on
in my .htaccess (just for a subfolder).
There are also more detailed settings,
see Enabling error display in php via htaccess only

Facebook PHP SDK Throwing an Uncatchable OAuthException

I'm attempting to post an open graph action to the Facebook Graph API but receiving an OAuth Exception (#3501) User is already associated to the <object>. That's all well and good, I expect Facebook to throw that exception. I get some other exceptions regarding authenticating a user (maybe with old/stale sessions, whatever).
My question is, has anyone else experienced that this exception is uncatchable in php? In this specific example (of posting graph actions) I am absolutely wrapping the call to the api in a try/catch statement; but I still get the fatal error.
<?php
try {
//publishing to open graph
$this->fb->api('/me/app:action', 'POST', array(
'object' => 'http://www.domain.com/path/to/graph/object',
));
}
catch (Exception $e)
{
/*
We may get here if the user has already posted this action before...
or if our session somehow went sour
or bc facebook is down...
or one of any other 1000 reasons the graph api is currently
sucking...
in any case it doesn't much matter, this is not a mission critical
thing to worry about; if we don't post the graph action - we don't
post the graph action..nbd.
*/
}
The above code is the snippet the publishes the graph action (generalized, because the content of it isn't important to this example).
I realize that the Exception that the Facebook PHP SDK is throwing is a FacebookApiException but that class extends Exception. I can't for the life of me figure out why in the name of all things logical, I can't catch my exception like this.
Has anyone experienced this issue? Is this a bug in the FB PHP SDK? Am I missing something else here? Thanks for your help!
Also, for reference, the relevant parts of the FB PHP SDK are here:
FacebookAPIException Definition (base_facebook.php line 30)
Throwing OAuthException (base_facebook.php line 1105
Edit 5/1/12
After some more investigation, it turns out that this "Exception" isn't really being treated like an exception at all. Typical Exceptions print out a stack trace back to the method call which resulted in throwing the exception. These "OAuthExceptions" do not. Also, typical exceptions pring out their error string a bit differently, for example:
PHP Fatal error: Uncaught exception 'Exception' with message 'foo' /path/to/file.php:10
or
PHP Fatal error: Uncaught exception 'MyException' with message 'stupid php' /path/to/file:10
#0 /path/to/file.php(17): doTest()
#1 {main}
thrown in /path/to/file.php on line 10
In this particular case, we don't get any of that, and it looks much more like a typical fatal error:
PHP Fatal error: Uncaught OAuthException: (#3501) User is already associated \
to the <object> object on a unique action type <action>. Original Action ID: \
123123123
thrown in /path/to/app/libs/fb/base_facebook.php on line 1107, \
referer: http://www.domain.com/path/to/page
I can't make any sense of why this forsaken "Exception" is so weird/uncatchable.
The Solution:
I figured out the answer to my own question; I've added it below - it's developer error, not a bug. The answer is below.
Also, this very well could be part of a bug, if you wanted to say that being able to reference a class definition as a type-hint to the catch definition which didn't exist (or wasn't available in the current namespace) is a bug.
So, something that's not outline above is that I'm utilizing PHP namespaces. This is a big gotchta since namespaces are relatively new to php, it's super easily overlooked I feel. Regardless, it's a pretty silly oversight/error.
If you're in a defined namespace (that is, not the root (\) namespace) you don't have direct access to the Exception class. Instead of php throwing a warning about not knowing what that class is, it just ignores the fact that it doesn't know what it is - and doesn't catch the exception.
Solution 1:
import the exception class:
<?php
use \Exception;
// ...codes
try {
//...codes
}
catch (Exception $e)
{
//...codes
}
Solution 2:
provide the full path to the exception class:
<?php
try {
//.....
}
catch (\Exception $e)
{
// voila.
}

How to make Zend Framework error page to look more clearly and beautifully?

By default error page in ZF looks like this:
Fatal error: Uncaught exception 'Zend_Form_Exception' with message 'Method setDeault does not exist' in /usr/home/.../library/Zend/Form.php:2838
Stack trace:
#0 [internal function]: Zend_Form->__call('setDeault', Array)
#1 /usr/home/.../application/admin/controllers/TagsController.php(40): Web_Form_Admintags->setDeault('tagstext', '....')
#2 /usr/home/.../library/Zend/
Is there any ways to change this messy error description to more clearly form (something like Django error page)?
This is not an error page but a standard PHP output for uncaught exceptions. As far as I know there is no default error page in Zend Framework -- you will have to create your own by creating an appropriate view for the ErrorController.
AFAICR this is using the Error controller right? That message is basically the dump of the exception object. You can split this up by calling different parts individually rather than dumping the whole lot as a string. See the manual page I linked to.
Make sure you're only providing exception information when the APPLICATION_ENVIRONMENT is set to development as well.
The exception is formatted using new lines, which are however not transformed to in html.
You have several options...
Wrap the error with <pre></pre> tags
Create custom exception handler
function exception_handler($exception) {
echo "Uncaught exception: " , $exception->getMessage(), "\n";
}
set_exception_handler('exception_handler');

Zend Framework - ErrorHandler does not seem to be working as expected

This is my first experience using the Zend Framework. I am attempting to follow the Quick Start tutorial. Everything was working as expected until I reached the section on the Error Controller and View. When I navigate to a page that does not exist, instead of receiving the error page I get the Fatal Error screen dump (in all it's glory):
Fatal error: Uncaught exception 'Zend_Controller_Dispatcher_Exception'
with message 'Invalid controller specified (error)' in
/home/.fantasia/bcnewman/foo.com/library/Zend/Controller/Dispatcher/Standard.php:249
Stack trace: #0
/home/.fantasia/bcnewman/foo.com/library/Zend/Controller/Front.php(946):
Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http),
Object(Zend_Controller_Response_Http)) #1
/home/.fantasia/bcnewman/foo.com/public/index.php(42):
Zend_Controller_Front->dispatch() #2 {main} thrown in
/home/.fantasia/bcnewman/foo.com/library/Zend/Controller/Dispatcher/Standard.php
on line 249
I do not believe this is caused by a syntax error on my part (a copied and pasted the example file's content from the tutorial) and I believe I have the application directory structure correct:
./application
./application/controllers
./application/controllers/IndexController.php
./application/controllers/ErrorHandler.php
./application/views
./application/views/scripts
./application/views/scripts/index
./application/views/scripts/index/index.phtml
./application/views/scripts/error
./application/views/scripts/error/error.phtml
./application/bootstrap.php
./public
./public/index.php
And finally, the IndexController and index.phtml view does work.
You have ErrorHandler.php. It should be ErrorController.php. Controllers all need to be named following the format of NameController.php. Since you don't have it named properly the dispatcher cannot find it.
Assuming that you have the ErrorController plugin loaded into your front controller, make sure that in your bootstrap that you do not have the following set:
$frontController->throwExceptions(true);
If this is set then Exceptions will always be thrown, regardless of whether or not you have an error controller set.

Categories