Is it possible to use custom fields and filtering in asset views and filter by a range of birth dates?

I’ve replaced this line with the in_array version, but no change. I will go over the rest of the changes in the next few days to make sure there isn’t something obviously wrong somewhere else, which is about all I can think to do at the moment.

1 Like

I don’t really understand why this would be an issue only during update.php - that’s the most confusing part… :thinking:

I might just have to carve out some time to test this myself.

@jgOhYeah I was able to replicate this locally. And I can roughly see what’s happening (with the help of XDebug). Still thinking through how to solve it…

Loading update.php seems to cause this code to run: src/EntityViewsData.php · efc5ae471b40427f19fca3cfe1524f7557d0cabc · project / entity · GitLab

Basically, the Entity API module is trying to add reverse relationships for all entity reference fields so that the Views module knows how to use them. In this case, it’s trying to figure out the database table name for the asset owner field - but this is running before the field is actually created.

I’m not sure why the same thing doesn’t happen during drush updb - or why this code runs while loading update.php

Here is the stack trace that leads up to the call to getFieldTableName() that happens when loading update.php (for future reference):

DefaultTableMapping.php:391, Drupal\Core\Entity\Sql\DefaultTableMapping->getFieldTableName()
EntityViewsData.php:371, Drupal\entity\EntityViewsData->addReverseRelationships()
EntityViewsDataTaxonomyFilterTrait.php:17, Drupal\farm_entity_views\FarmEntityViewsData->addReverseRelationships()
EntityViewsData.php:79, Drupal\entity\EntityViewsData->getViewsData()
views.views.inc:180, views_views_data()
ModuleHandler.php:392, call_user_func_array:{/opt/drupal/web/core/lib/Drupal/Core/Extension/ModuleHandler.php:392}()
ModuleHandler.php:392, Drupal\Core\Extension\ModuleHandler->invoke()
ViewsData.php:237, Drupal\views\ViewsData->getData()
ViewsData.php:154, Drupal\views\ViewsData->get()
ViewsEntityRow.php:91, Drupal\views\Plugin\Derivative\ViewsEntityRow->getDerivativeDefinitions()
DerivativeDiscoveryDecorator.php:101, Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator->getDerivatives()
DerivativeDiscoveryDecorator.php:87, Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator->getDefinitions()
DefaultPluginManager.php:285, Drupal\Core\Plugin\DefaultPluginManager->findDefinitions()
DefaultPluginManager.php:175, Drupal\Core\Plugin\DefaultPluginManager->getDefinitions()
views.module:146, views_theme()
Registry.php:469, Drupal\Core\Theme\Registry->processExtension()
Registry.php:356, Drupal\Core\Theme\Registry->build()
Registry.php:255, Drupal\Core\Theme\Registry->get()
ThemeRegistry.php:88, Drupal\Core\Utility\ThemeRegistry->initializeRegistry()
ThemeRegistry.php:69, Drupal\Core\Utility\ThemeRegistry->__construct()
Registry.php:275, Drupal\Core\Theme\Registry->getRuntime()
ThemeManager.php:142, Drupal\Core\Theme\ThemeManager->render()
Renderer.php:422, Drupal\Core\Render\Renderer->doRender()
Renderer.php:201, Drupal\Core\Render\Renderer->render()
Renderer.php:145, Drupal\Core\Render\Renderer->Drupal\Core\Render\{closure:/opt/drupal/web/core/lib/Drupal/Core/Render/Renderer.php:144-146}()
Renderer.php:564, Drupal\Core\Render\Renderer->executeInRenderContext()
Renderer.php:146, Drupal\Core\Render\Renderer->renderRoot()
BareHtmlPageRenderer.php:66, Drupal\Core\Render\BareHtmlPageRenderer->renderBarePage()
BareHtmlPageRenderer.php:76, Drupal\Core\ProxyClass\Render\BareHtmlPageRenderer->renderBarePage()
DbUpdateController.php:196, Drupal\system\Controller\DbUpdateController->handle()
UpdateKernel.php:115, call_user_func_array:{/opt/drupal/web/core/lib/Drupal/Core/Update/UpdateKernel.php:115}()
UpdateKernel.php:115, Drupal\Core\Update\UpdateKernel->handleRaw()
UpdateKernel.php:76, Drupal\Core\Update\UpdateKernel->handle()
update.php:27, {main}()

This may be related to (or caused by) this patch that we are applying to the Entity API module: Provide reverse relationships for bundle plugin entity_reference fields. [#3206703] | Drupal.org

In fact, I notice that @paul121 ran into the same error during the development of that patch: Provide reverse relationships for bundle plugin entity_reference fields. [#3206703] | Drupal.org

It may be that we need to expand that patch to handle this new case you’ve identified @jgOhYeah. Perhaps update.php wasn’t tested during that patch’s development, so it slipped between the cracks…

I’ve commented on that upstream issue with details so we can investigate there: Provide reverse relationships for bundle plugin entity_reference fields. [#3206703] | Drupal.org

@jgOhYeah unfortunately that will be a blocker to including this new owner field in farmOS core. So I would say focus on getting everything working via drush updb (sounds like it is), and open a pull request for that. The Entity API patch issue will need to block merging, but at least it will be ready to go. I’m not sure when the Entity API patch issue will be fixed, unfortunately. You’re welcome to take a look at it, but it is a VERY deep dive…

1 Like

I’m not sure I understand everything that is going on here but this might be related: https://www.drupal.org/project/drupal/issues/3129179#comment-13562221

I recently wrote and update hook to add a bundle field to an asset and got the “Table information” not found error. Running the code in that comment fixed the issue. I should have taken better notes on it all, afraid I don’t have a good idea of why it is happening…

2 Likes

Thanks for looking into this and finding the cause. If only it were something simple like a missing semicolon :slight_smile:

I will create a pull request for when the update.php issue is resolved. There is no rush or panic to get this merged from my point of view.

Thanks again for the help when adapting the module.

1 Like

Thanks @jgOhYeah for the pull request!

And thanks for the link @paul121. This particular issue is with base fields, not bundle fields, so I’m not entirely sure if it’s the same (or if it’s caused by the Entity API patch we’re using).