E
E
Evgeny Musonov2020-01-21 06:56:00
Yii
Evgeny Musonov, 2020-01-21 06:56:00

How to resolve unserialize(): Error at offset when loading PDF?

I upload a PDF file with Cyrillic, then it comes out

PHP Notice yii\base\ErrorException with message unserialize(): Error at offset 5527 of 7876608 bytes in /var/www/www-root/data/www/2fraz.vadimtest.ru/vendor/yiisoft/yii2-debug/src/controllers/DefaultController.php:185

then 400 bad request.
Deleted the debug folder, didn't help.
The method referenced by the error
public function loadData($tag, $maxRetry = 0)
    {
        // retry loading debug data because the debug data is logged in shutdown function
        // which may be delayed in some environment if xdebug is enabled.
        // See: https://github.com/yiisoft/yii2/issues/1504
        for ($retry = 0; $retry <= $maxRetry; ++$retry) {
            $manifest = $this->getManifest($retry > 0);
            if (isset($manifest[$tag])) {
                $dataFile = $this->module->dataPath . "/$tag.data";
                $data = unserialize(file_get_contents($dataFile)); <----
                $exceptions = $data['exceptions'];
                foreach ($this->module->panels as $id => $panel) {
                    if (isset($data[$id])) {
                        $panel->tag = $tag;
                        $panel->load(unserialize($data[$id]));
                    }
                    if (isset($exceptions[$id])) {
                        $panel->setError($exceptions[$id]);
                    }
                }
                $this->summary = $data['summary'];

                return;
            }
            sleep(1);
        }

        throw new NotFoundHttpException("Unable to find debug data tagged with '$tag'.");
    }

Regular PDFs with images load fine.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2020-01-25
@webinar

$data = unserialize(file_get_contents($dataFile));
and then
you want to anserialize the anserialized? Steal what was stolen? Drink drunk?
But the error is rather unrelated to the pdf. 400 error is probably no csrf token.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question