Score:0

unserialize(): Error at offset 0 of 18 bytes

in flag

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 flag
By any change you have logger around that function call ?
mark newton avatar
in flag
I am going to need to read up on it I think. This is going to take me some time though, since I am not full time. I will have a look at doing this on Thursday. Sounds like I need to enable X-debug or something similar...Thanks for the idea though.
apaderno avatar
us flag
The notice is show in the first line (*Notice: unserialize(): Error at offset 0 of 18 bytes in Drupal\Core\Entity\Sql\SqlContentEntityStorage->loadFromDedicatedTables()*). It doesn't involve any template file, since `SqlContentEntityStorage::loadFromDedicatedTables()` doesn't load any template file. As for troubleshooting the issue, you need to install a debugger. Apart suggesting that, there isn't much we can say. We cannot debug a site to which we don't have access.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.