Bug Server Error

Status
Not open for further replies.

noble_man

Customer
Hello i seem to be getting this error when DB mail is enabled, did some reading on XF with others having the same issue but did not see a fix?

Code:
Server error log

    LogicException: Instances of XF\Db\AbstractAdapter cannot be serialized or unserialized src/XF/Db/AbstractAdapter.php:682

    Generated by: Unknown account Dec 9, 2021 at 12:10 AM

Stack trace

#0 [internal function]: XF\Db\AbstractAdapter->__sleep()
#1 src/XF/Job/Manager.php(221): serialize(Array)
#2 src/XF/Job/Manager.php(86): XF\Job\Manager->runJobEntry(Array, 8)
#3 job.php(43): XF\Job\Manager->runQueue(false, 8)
#4 {main}

Request state

array(4) {
  ["url"] => string(8) "/job.php"
  ["referrer"] => string(23) "https://chatbanter.com/"
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(0) {
  }
}
 
What version of XenForo are you running? There was an issue with an older version of XenForo 2.2 that could cause this error, but thus far I've been unable to replicate it on the latest version.
 
Okay, it's good that you're reliably getting the error, that means we can try to get to the bottom of this.

Can you please open src/XF/Job/Manager.php and find the following block of code:
PHP:
            $update = [
                'execute_data' => serialize($result->data),
                'trigger_date' => $result->continueDate ? intval($result->continueDate) : $job['trigger_date'],
                'last_run_date' => time()
            ];
(I believe there should only be one instance of this block, at or around line 220)

Add directly above:
PHP:
            try
            {
                $serialized = serialize($result->data);
            }
            catch (\LogicException $e)
            {
                \XF::logError("Job with class {$job['execute_class']} has invalid result data.");
            }

It should look like this:
1639149489199.png

Then wait for the error to be replicated. You should have a new error message directly above the LogicException error in your server error log that will tell us which job class is causing the error.
 
Code:
I get this
ParseError: syntax error, unexpected 'public' (T_PUBLIC) in src/XF/Job/Manager.php at line 245

    Composer\Autoload\includeFile() in src/vendor/composer/ClassLoader.php at line 346
    Composer\Autoload\ClassLoader->loadClass()
    spl_autoload_call()
    class_exists() in src/XF/Extension.php at line 130
    XF\Extension->extendClass() in src/XF/App.php at line 2857
    XF\App->extendClass() in src/XF/App.php at line 1519
    XF\App->XF\{closure}() in src/XF/Container.php at line 30
    XF\Container->offsetGet() in src/XF/App.php at line 2821
    XF\App->jobManager() in src/XF/Admin/Controller/Index.php at line 102
    XF\Admin\Controller\Index->actionIndex() in src/XF/Mvc/Dispatcher.php at line 352
    XF\Mvc\Dispatcher->dispatchClass() in src/XF/Mvc/Dispatcher.php at line 259
    XF\Mvc\Dispatcher->dispatchFromMatch() in src/XF/Mvc/Dispatcher.php at line 115
    XF\Mvc\Dispatcher->dispatchLoop() in src/XF/Mvc/Dispatcher.php at line 57
    XF\Mvc\Dispatcher->run() in src/XF/App.php at line 2345
    XF\App->run() in src/XF.php at line 512
    XF::runApp() in admin.php at line 13

i also see this

mail.png
 
Code:
    ParseError: syntax error, unexpected 'public' (T_PUBLIC) src/XF/Job/Manager.php:245

    Generated by: Unknown account Dec 10, 2021 at 4:33 PM

Stack trace

#0 src/vendor/composer/ClassLoader.php(346): Composer\Autoload\includeFile('/home/chatbante...')
#1 [internal function]: Composer\Autoload\ClassLoader->loadClass('XF\\Job\\Manager')
#2 [internal function]: spl_autoload_call('XF\\Job\\Manager')
#3 src/XF/Extension.php(130): class_exists('XF\\Job\\Manager')
#4 src/XF/App.php(2857): XF\Extension->extendClass('XF\\Job\\Manager', NULL)
#5 src/XF/App.php(1519): XF\App->extendClass('XF\\Job\\Manager')
#6 src/XF/Container.php(30): XF\App->XF\{closure}(Object(XF\Container))
#7 src/XF/App.php(2821): XF\Container->offsetGet('job.manager')
#8 job.php(13): XF\App->jobManager()
#9 {main}

Request state

array(4) {
  ["url"] => string(8) "/job.php"
  ["referrer"] => string(32) "https://chatbanter.com/admin.php"
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(0) {
  }
}
 
Code:
I get this
ParseError: syntax error, unexpected 'public' (T_PUBLIC) in src/XF/Job/Manager.php at line 245

    Composer\Autoload\includeFile() in src/vendor/composer/ClassLoader.php at line 346
    Composer\Autoload\ClassLoader->loadClass()
    spl_autoload_call()
    class_exists() in src/XF/Extension.php at line 130
    XF\Extension->extendClass() in src/XF/App.php at line 2857
    XF\App->extendClass() in src/XF/App.php at line 1519
    XF\App->XF\{closure}() in src/XF/Container.php at line 30
    XF\Container->offsetGet() in src/XF/App.php at line 2821
    XF\App->jobManager() in src/XF/Admin/Controller/Index.php at line 102
    XF\Admin\Controller\Index->actionIndex() in src/XF/Mvc/Dispatcher.php at line 352
    XF\Mvc\Dispatcher->dispatchClass() in src/XF/Mvc/Dispatcher.php at line 259
    XF\Mvc\Dispatcher->dispatchFromMatch() in src/XF/Mvc/Dispatcher.php at line 115
    XF\Mvc\Dispatcher->dispatchLoop() in src/XF/Mvc/Dispatcher.php at line 57
    XF\Mvc\Dispatcher->run() in src/XF/App.php at line 2345
    XF\App->run() in src/XF.php at line 512
    XF::runApp() in admin.php at line 13

i also see this

View attachment 10013
I'm assuming you resolved this? The code wasn't copied correctly.
 
here are the new ones

Code:
Server error log

    ErrorException: Job with class DBTech\Mail:DigestEmail has invalid result data. src/XF/Error.php:77

    Generated by: Unknown account Dec 13, 2021 at 12:17 AM

Stack trace

#0 src/XF.php(218): XF\Error->logError('Job with class ...', false)
#1 src/XF/Job/Manager.php(226): XF::logError('Job with class ...')
#2 src/XF/Job/Manager.php(86): XF\Job\Manager->runJobEntry(Array, 7.99858)
#3 job.php(43): XF\Job\Manager->runQueue(false, 8)
#4 {main}

Request state

array(4) {
  ["url"] => string(8) "/job.php"
  ["referrer"] => string(23) "https://chatbanter.com/"
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(0) {
  }
}

Code:
Server error log

    LogicException: Instances of XF\Db\AbstractAdapter cannot be serialized or unserialized src/XF/Db/AbstractAdapter.php:682

    Generated by: Unknown account Dec 13, 2021 at 12:17 AM

Stack trace

#0 [internal function]: XF\Db\AbstractAdapter->__sleep()
#1 src/XF/Job/Manager.php(229): serialize(Array)
#2 src/XF/Job/Manager.php(86): XF\Job\Manager->runJobEntry(Array, 7.99858)
#3 job.php(43): XF\Job\Manager->runQueue(false, 8)
#4 {main}

Request state

array(4) {
  ["url"] => string(8) "/job.php"
  ["referrer"] => string(23) "https://chatbanter.com/"
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(0) {
  }
}
 
Alright, I'll try to replicate it myself so I can look into why specifically this is happening. Thank you for your help :)
 
I'm unable to replicate this locally. Are you able to trigger the error if you go to admin.php?dbtech-mail/digests/newsletter.1/send-test and send a test digest, or does it only happen during the daily run?
 
I'm not able to figure this out even with that additional information, so I have one other thing I'd like you to try, please.

Can you please open src/XF/Job/Manager.php and find the following block of code:
PHP:
            $update = [
                'execute_data' => serialize($result->data),
                'trigger_date' => $result->continueDate ? intval($result->continueDate) : $job['trigger_date'],
                'last_run_date' => time()
            ];
(Same location as last time)

Add directly above:
PHP:
            if ($job['execute_class'] == 'DBTech\Mail:DigestEmail')
            {
                foreach ($result->data as $key => $value)
                {
                    try
                    {
                        \serialize($value);
                    }
                    catch (\LogicException $e)
                    {
                        \XF::logError("Value {$key} cannot be serialized.");
                    }
                }
            }
 
Status
Not open for further replies.

DragonByte Mail

XenForo 1.5.3+ XenForo 2.0.x XenForo 2.1.x XenForo 2.2.x
Seller
DragonByte Technologies
Release date
Last update
Total downloads
1,220
Customer rating
0.00 star(s) 0 ratings
Back
Top