Рейтинг:0

unserialize(): Error at offset 0 of 18 bytes

флаг in

I am doing a migration from Drupal 7 to Drupal 8. Its using a MYSQL database (Server version: 8.0.26-0ubuntu0.20.04.2 (Ubuntu)). With this one particular node type when I drush cr and then reload the page I am given the following error.

Notice: unserialize(): Error at offset 0 of 18 bytes in Drupal\Core\Entity\Sql\SqlContentEntityStorage->loadFromDedicatedTables() (line 1288 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

Drupal\Core\Entity\Sql\SqlContentEntityStorage->loadFromDedicatedTables(Array, ) (Line: 524)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->mapFromStorageRecords(Array) (Line: 449)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->getFromStorage(Array) (Line: 415)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->doLoadMultiple(Array) (Line: 300)
Drupal\Core\Entity\EntityStorageBase->loadMultiple(Array) (Line: 139)
Drupal\Core\Field\Plugin\Field\FieldFormatter\EntityReferenceFormatterBase->prepareView(Array) (Line: 245)
Drupal\Core\Entity\Entity\EntityViewDisplay->buildMultiple(Array) (Line: 351)
Drupal\Core\Entity\EntityViewBuilder->buildComponents(Array, Array, Array, 'full') (Line: 24)
Drupal\node\NodeViewBuilder->buildComponents(Array, Array, Array, 'full') (Line: 293)
Drupal\Core\Entity\EntityViewBuilder->buildMultiple(Array) (Line: 250)
Drupal\Core\Entity\EntityViewBuilder->build(Array) call_user_func_array(Array, Array) (Line: 100)
Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was %s. Support for this callback implementation is deprecated in 8.8.0 and will be removed in Drupal 9.0.0. See https://www.drupal.org/node/2966725', 'silenced_deprecation', 'Drupal\Core\Render\Element\RenderCallbackInterface') (Line: 781)
Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array) (Line: 372)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 200)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 226)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent{closure}() (Line: 573)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 227)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 117)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object) call_user_func(Array, Object, 'kernel.view', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object) (Line: 156)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 708)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

I can see it's caused by an entity reference field. I am using the Bootstrap 4 theme and I have a template override, which is the following one.

{% if content.field_business.0%}
  <div class="dimension col-xs-12 col-md-4 col-lg-2 text-break">
    <p>Retailer: {{ content.field_business.0 }}</p>
  </div>
{% endif %}

Looking at the database table with desc node__field_business for the particular node and the rest of them I can't see any junk data.

+------------------------------+--------------+------+-----+---------+-------+
    | Field                    | Type         | Null | Key | Default | Extra |
+------------------------------+--------------+------+-----+---------+-------+
    | bundle                   | varchar(128) | NO   | MUL |         |       |
    | deleted                  | tinyint      | NO   | PRI | 0       |       |
    | entity_id                | int unsigned | NO   | PRI | NULL    |       |
    | revision_id              | int unsigned | NO   | MUL | NULL    |       |
    | langcode                 | varchar(32)  | NO   | PRI |         |       |
    | delta                    | int unsigned | NO   | PRI | NULL    |       |
    | field_business_target_id | int unsigned | NO   | MUL | NULL    |       |
+------------------------------+--------------+------+-----+---------+-------+
    7 rows in set (0.01 sec)

select entity_id, field_business_target_id from node__field_business where entity_id="429" shows the following output.

+-----------+--------------------------+
| entity_id | field_business_target_id |
+-----------+--------------------------+
|       429 |                      267 |
+-----------+--------------------------+
    1 row in set (0.00 sec)

There also does not seem to be anything in the apache2 error.log too.

[Sun Oct 03 00:00:21.635998 2021] [mpm_prefork:notice] [pid 1757] AH00163: Apache/2.4.41 (Ubuntu) configured -- resuming normal operations
[Sun Oct 03 00:00:21.636036 2021] [core:notice] [pid 1757] AH00094: Command line: '/usr/sbin/apache2'
[Sun Oct 03 01:19:18.993276 2021] [mpm_prefork:notice] [pid 1757] AH00169: caught SIGTERM, shutting down
[Sun Oct 03 10:13:42.699740 2021] [mpm_prefork:notice] [pid 1666] AH00163: Apache/2.4.41 (Ubuntu) configured -- resuming normal operations
[Sun Oct 03 10:13:42.709982 2021] [core:notice] [pid 1666] AH00094: Command line: '/usr/sbin/apache2'
[Sun Oct 03 13:23:39.109602 2021] [mpm_prefork:notice] [pid 1666] AH00169: caught SIGTERM, shutting down
[Sun Oct 03 19:14:05.151979 2021] [mpm_prefork:notice] [pid 1678] AH00163: Apache/2.4.41 (Ubuntu) configured -- resuming normal operations
[Sun Oct 03 19:14:05.152317 2021] [core:notice] [pid 1678] AH00094: Command line: '/usr/sbin/apache2'

Does anyone have any idea on how I could troubleshoot this? I am pretty sure its not the theme template to cause the issue, since I renames the template (so its not used), clear the cache and the error is still there when I refresh the page. As far as I can see the data in table in looks OK to me.

miststudent2011 avatar
флаг fr
Каким-либо изменением у вас есть регистратор вокруг этого вызова функции?
mark newton avatar
флаг in
Думаю, мне нужно будет прочитать об этом. Это займет у меня некоторое время, так как я не полный рабочий день. Я посмотрю, как это сделать в четверг. Похоже, мне нужно включить X-debug или что-то подобное... Спасибо за идею.
apaderno avatar
флаг us
Уведомление отображается в первой строке (*Notice: unserialize(): Error at offset 0 of 18 bytes in Drupal\Core\Entity\Sql\SqlContentEntityStorage->loadFromDedicatedTables()*). Он не использует какой-либо файл шаблона, поскольку `SqlContentEntityStorage::loadFromDedicatedTables()` не загружает какой-либо файл шаблона. Что касается устранения проблемы, вам необходимо установить отладчик. Кроме того, что мы можем сказать немногое. Мы не можем отлаживать сайт, к которому у нас нет доступа.

Ответить или комментировать

Большинство людей не понимают, что склонность к познанию нового открывает путь к обучению и улучшает межличностные связи. В исследованиях Элисон, например, хотя люди могли точно вспомнить, сколько вопросов было задано в их разговорах, они не чувствовали интуитивно связи между вопросами и симпатиями. В четырех исследованиях, в которых участники сами участвовали в разговорах или читали стенограммы чужих разговоров, люди, как правило, не осознавали, что задаваемый вопрос повлияет — или повлиял — на уровень дружбы между собеседниками.