Guys I need little bit help with PHP Fatal error. Whenever a new session is getting created a PHP Fatal error occurs. This error never happens throughout the session apart from when session first starts. The error is:
Uncaught exception 'Exception' with message 'Serialization of 'SimpleXMLElement'
is not allowed' in /var/www/downloadanymp3.com/index.php:240
Stack trace:
#0 /var/www/downloadanymp3.com/index.php(240): session_commit()
#1 {main}
Next exception 'Exception' with message 'Serialization of 'SimpleXMLElement'
is not allowed' in /var/www/downloadanymp3.com/index.php:240
Stack trace:
#0 /var/www/downloadanymp3.com/index.php(0): session_commit()
#1 {main}
thrown in /var/www/downloadanymp3.com/index.php on line 240, referer:
http://dev.downloadanymp3.com/index.php?searchType=VIDEOTITLE
And one more thing, on index.php the very last line is session_commit();
You're attempting to put a SimpleXML element inside of your session -- Simple XML doesn't allow for serialization like that. If you need to, you can store the XML string in your session, then deserilize that back through SimpleXML if you need it again. Or even better, convert your XML into an array and store that... I personally don't understand why people use XML as a memory storage object anyway.
Related
WPForms Lite has caused a fatal error on my WordPress page, and I struggle with figuring out what the problem is and how to fix it.
Error Details:
An error of type E_ERROR was caused in line 106 of the file /home/pagename/public_html/wp-content/plugins/wpforms-lite/src/Helpers/Templates.php. Error message: Uncaught RuntimeException: Extraction failed: variable names are clashing with the existing ones. in /home/pagename/public_html/wp-content/plugins/wpforms-lite/src/Helpers/Templates.php:106
It seems like the function is supposed to include a template, and the error exists to "protect the scope from modification".
Stack trace:
#0 /home/pagename/public_html/wp-content/plugins/wpforms-lite/src/Helpers/Templates.php(127): WPForms\Helpers\Templates::include_html('education/admin...', Array, true)
#1 /home/pagename/public_html/wp-content/plugins/wpforms-lite/includes/functions.php(2402): WPForms\Helpers\Templates::get_html('education/admin...', Array, true)
#2 /home/pagename/public_html/wp-content/plugins/wpforms-lite/src/Lite/Admin/Education/Admin/NoticeBar.php(69): wpforms_render('education/admin...', Array, true)
#3 /home/pagename/public_html/wp-includes/class-wp-hook.php(303): WPForms\Lite\Admin\Education\Admin\NoticeBar->display('')
#4 /home/pagename/public_html/wp-includes/class-wp-hook.php(327): WP_Hook->apply_filters('', Array)
#5 /home/vpagename/public_html/wp-includes/plugin.php(470): WP_Hook->do_action(Arra
I am trying to recover the last (fatal) error message through these functions:
$last_error = error_get_last();
echo $last_error['message'];
Using the exception:
throw new Exception("Error n.1");
I would expect to get this string "Error n.1", but I get something like this (which depends on the PHP version):
Uncaught Exception: Error n.1 in C:\wamp\www\JUICE\projects\JATE\dist\jate\functions\errorHandler.php:66 Stack trace: #0 C:\wamp\www\JUICE\projects\JATE\dist\jate\functions\requirer.php(37): require_once() #1 C:\wamp\www\JUICE\projects\JATE\dist\jate\functions\requirer.php(5): jRequire('C:\\wamp\\www\\JUI...', false, 0) #2 C:\wamp\www\JUICE\projects\JATE\dist\jate\functions\requirer.php(15): requireComponent('C:\\wamp\\www\\JUI...', false) #3 C:\wamp\www\JUICE\projects\JATE\dist\jate\coreEngine.php(10): requireComponents('functions') #4 C:\wamp\www\JUICE\projects\JATE\examples\01essential\jate.php(15): require_once('C:\\wamp\\www\\JUI...') #5 C:\wamp\www\JUICE\projects\JATE\examples\01essential\index.php(2): require_once('C:\\wamp\\www\\JUI...') #6 {main} thrown
How can I get the error string and not all the things added by the system?
Your expectation is wrong. Throwing an exception doesn't cause an error by itself, so that's not what is shown in $last_error. Failing to catch an exception causes an error, but the message for that error is Uncaught Exception followed by the details of the exception, not just the exception string.
Since the specific format of that message is version-dependent, the best you can do is search it for the exception string in it:
if (preg_match('/Error n\.1/', $last_error['message']) {
echo "Error n.1";
}
I'm writing a plugin for openVBX.
I need to store some stuff in a table I made in the OpenVBX database.
OpenVBX Provides a helper method (PluginData::sqlQuery) to run queries but no way to escape them, so I decided to open a new PDO connection in my plugin page, but I'm getting this error:
Fatal error: Uncaught exception 'PDOException' with message
'SQLSTATE[HY000]: General error: 2006 MySQL server has gone away' in
/home/elitecallcenter/public_html/ivr/plugins/QPage/qpage.php:119
Stack trace: #0
/home/elitecallcenter/public_html/ivr/plugins/QPage/qpage.php(119):
PDOStatement->execute(Array) #1
/home/elitecallcenter/public_html/ivr/OpenVBX/views/page/index.php(7):
include_once('/home/elitecall...') #2
/home/elitecallcenter/public_html/ivr/system/libraries/Loader.php(677):
include('/home/elitecall...') #3
/home/elitecallcenter/public_html/ivr/system/libraries/Loader.php(307):
CI_Loader->_ci_load(Array) #4
/home/elitecallcenter/public_html/ivr/OpenVBX/libraries/Template.php(388):
CI_Loader->view('page/index', Array, true) #5
/home/elitecallcenter/public_html/ivr/OpenVBX/libraries/MY_Controller.php(455):
CI_Template->write_view('content', 'page/index', Array) #6
/home/elitecallcenter/public_html/ivr/OpenVBX/libraries/MY_Controller.php(498):
MY_Controller->template_respond('Phone Apps', 'page/index', Array, 'yu
in /home/elitecallcenter/public_html/ivr/plugins/QPage/qpage.php on
line 119
Line 119 is my execute call for a prepared statement.
How can I resolve this?
How large / heavy is the query? Generally you get MySQL server has gone away as a timeout.
You could try raising 'wait_timeout' in my.cnf to something more suitable or try raising 'max_allowed_packet' to '128M'.
I figured out that it was written in codeigniter, so I'm reading up on that to figure out the best way to do this. In the mean time, I've got a functioning workaround set up that involves making a cURL request to another script in the base directory that is able to connect to the database.
I never use PDO on my project, especially serialize and unserialize. But I got this error.
Fatal error: Class
'Symfony\Component\HttpKernel\Exception\FlattenException' not found in
/var/www/test/mikroskil/mikroweb/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php
on line 56 Fatal error: Uncaught exception 'PDOException' with message
'You cannot serialize or unserialize PDO instances' in [no active
file]:0 Stack trace: #0 [internal function]: PDO->__sleep() #1
[internal function]: session_write_close() #2 {main} thrown in [no
active file] on line 0
it's so frustrating. Anybody can help me? It appears suddenly when i refresh my page.
Note :
I have an error before.
I use a form with POST method. And then i put a session on it.
After that, i got this error.
failed to start the session: already started by php ($_session is
set).
I tried to fix that error. But suddenly the page is showing this error
Fatal error: Class
'Symfony\Component\HttpKernel\Exception\FlattenException' not found in
/var/www/test/mikroskil/mikroweb/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php
on line 56 Fatal error: Uncaught exception 'PDOException' with message
'You cannot serialize or unserialize PDO instances' in [no active
file]:0 Stack trace: #0 [internal function]: PDO->__sleep() #1
[internal function]: session_write_close() #2 {main} thrown in [no
active file] on line 0
I have recently had this issue and the problem was I was storing my model on session (which has active pdo connection inside) and when the request is done, php automatically try to serialize $_SESSION to store on tmp file.
The main problem is PDO connection can not be serialized. If you encounter this issue, you need to check where do you serialize any object that contains active pdo connection.
I have found this answer.
You just need to clear your Cookies on your browser.
Maybe the previous error has been create a cookies and cannot replace it.
i try to clear all my browser cookies and it successfull !
:)
I had the same error when using Medoo PHP Framework, I realized you cannot encode(serialize) a PDOStatement instances.
In my case I was using PHP json_encode to encode data to be sent to my appliction and part of that data contained the PDOStatement instances - data returned after executing a database operation. I just removed the PDOStatement instances from my data and everything worked okay.
I got this too but reading this question and, especially, zerkms responses helped me locate the problem in my code. Clearing one's cache is not an appropriate response to the problem! Having recently re-vamped my classes to use dependency-injection (?), storing them as session variables is no longer appropriate.
I'm using Google App Engine in combination with PHP.
After a couple request I get the following error
Fatal error: Uncaught exception 'google\net\ProtocolBufferEncodeError' with message 'Internal bug: Encoded size doesn't match predicted' in /base/data/home/runtimes/php/sdk/google/appengine/runtime/proto/ProtocolMessage.php:68
Stack trace:
#0 /base/data/home/runtimes/php/sdk/google/appengine/runtime/proto/ProtocolMessage.php(50): google\net\ProtocolMessage->serializePartialToString()
#1 /base/data/home/runtimes/php/sdk/google/appengine/runtime/RealApiProxy.php(52): google\net\ProtocolMessage->serializeToString()
#2 /base/data/home/runtimes/php/sdk/google/appengine/runtime/ApiProxy.php(42): google\appengine\runtime\RealApiProxy->makeSyncCall('taskqueue', 'BulkAdd', Object(google\appengine\TaskQueueBulkAddRequest), Object(google\appengine\TaskQueueBulkAddResponse), NULL)
#3 /base/data/home/runtimes/php/sdk/google/appengine/api/taskqueue/PushQueue.php(195): google\appengine\runtime\ApiProxy::makeSyncCall('taskqueue', 'BulkAdd', Object(google\appengine\TaskQueueBulkAddRequest), Object(google\appengine\TaskQueueBulkAddResponse in /base/data/home/runtimes/php/sdk/google/appengine/runtime/proto/ProtocolMessage.php on line 68
Fatal error: Uncaught exception 'google\net\ProtocolBufferEncodeError' with message 'Internal bug: Encoded size doesn't match predicted' in /base/data/home/runtimes/php/sdk/google/appengine/runtime/proto/ProtocolMessage.php:68
Stack trace:
#0 /base/data/home/runtimes/php/sdk/google/appengine/runtime/proto/ProtocolMessage.php(50): google\net\ProtocolMessage->serializePartialToString()
#1 /base/data/home/runtimes/php/sdk/google/appengine/runtime/RealApiProxy.php(52): google\net\ProtocolMessage->serializeToString()
#2 /base/data/home/runtimes/php/sdk/google/appengine/runtime/ApiProxy.php(42): google\appengine\runtime\RealApiProxy->makeSyncCall('taskqueue', 'BulkAdd', Object(google\appengine\TaskQueueBulkAddRequest), Object(google\appengine\TaskQueueBulkAddResponse), NULL)
#3 /base/data/home/runtimes/php/sdk/google/appengine/api/taskqueue/PushQueue.php(195): google\appengine\runtime\ApiProxy::makeSyncCall('taskqueue', 'BulkAdd', Object(google\appengine\TaskQueueBulkAddRequest), Object(google\appengine\TaskQueueBulkAddResponse in /base/data/home/runtimes/php/sdk/google/appengine/runtime/proto/ProtocolMessage.php on line 68
To solve this I shutdown all the instances and the code just loads normally. And again after a couple of request I get the same fatal error.
What can cause this Fatal error ? And how do I solve it.
The error is raised in the following file
https://chromium.googlesource.com/external/googleappengine/python/+/4523f63814037ed833b8bb55273c09a43dd69fb0/php/sdk/google/appengine/runtime/proto/ProtocolMessage.php