Call to undefined function .... in options_allowed_values()

Created on 3 July 2020, almost 5 years ago
Updated 1 November 2023, over 1 year ago

The background/context of this issue is a D7 to D8 migration.

A function was defined on the D7 side to return the Allowed Values for a multi-select field.
But the function did not exist (yet) on the D8 side.
Resulting in a White Screens of Death.

A more helpful outcome would be where the code "limps on" to the next page, so that the damage can be assessed.

The attached patch establishes this.

🐛 Bug report
Status

Needs work

Version

9.5

Component
Field 

Last updated 1 day ago

Created by

🇦🇺Australia rdeboer Melbourne

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇪🇨Ecuador dmezquia UTC-5

    This error also happens when calling a function of a disabled module, patch #2 solves it, since it first validates if the function exists.

    Or is there another way to check this so that it doesn't call a function of a non-installed module?

  • 🇫🇷France toto21

    The background/context of this issue is a D7 to D10.4 migration.

    I got this error message: "Error : Call to undefined function cck_allowed_values_php() dans options_allowed_values() (ligne 89 de /var/www/html/dev10.4/web/core/modules/options/options.module)." when trying to run /admin/config/system/cron under Drupal 10.4.2 / PHP 8.2.13 / MariaDB 10.6.18-MariaDB-0ubuntu0.22.04.1.

    Applying the patch from comment #2 🐛 Call to undefined function .... in options_allowed_values() Needs work solved the problem.

    More details :
    Location : https://dev10.4.local/en/admin/config/system/cron
    Referrer : https://dev10.4.local/en/admin/config/system/cron
    Here is the backtraces for experts :

    #0 /var/www/html/dev10.4/web/core/modules/options/src/Plugin/Field/FieldType/ListItemBase.php(65): options_allowed_values()
    #1 /var/www/html/dev10.4/web/core/modules/options/src/Plugin/Field/FieldType/ListItemBase.php(48): Drupal\options\Plugin\Field\FieldType\ListItemBase->getSettableOptions()
    #2 /var/www/html/dev10.4/web/core/modules/options/src/Plugin/Field/FieldFormatter/OptionsDefaultFormatter.php(38): Drupal\options\Plugin\Field\FieldType\ListItemBase->getPossibleOptions()
    #3 /var/www/html/dev10.4/web/core/lib/Drupal/Core/Field/FormatterBase.php(91): Drupal\options\Plugin\Field\FieldFormatter\OptionsDefaultFormatter->viewElements()
    #4 /var/www/html/dev10.4/web/core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php(268): Drupal\Core\Field\FormatterBase->view()
    #5 /var/www/html/dev10.4/web/core/lib/Drupal/Core/Entity/EntityViewBuilder.php(340): Drupal\Core\Entity\Entity\EntityViewDisplay->buildMultiple()
    #6 /var/www/html/dev10.4/web/core/modules/node/src/NodeViewBuilder.php(24): Drupal\Core\Entity\EntityViewBuilder->buildComponents()
    #7 /var/www/html/dev10.4/web/core/lib/Drupal/Core/Entity/EntityViewBuilder.php(282): Drupal\node\NodeViewBuilder->buildComponents()
    #8 /var/www/html/dev10.4/web/core/lib/Drupal/Core/Entity/EntityViewBuilder.php(239): Drupal\Core\Entity\EntityViewBuilder->buildMultiple()
    #9 [internal function]: Drupal\Core\Entity\EntityViewBuilder->build()
    #10 /var/www/html/dev10.4/web/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php(113): call_user_func_array()
    #11 /var/www/html/dev10.4/web/core/lib/Drupal/Core/Render/Renderer.php(870): Drupal\Core\Render\Renderer->doTrustedCallback()
    #12 /var/www/html/dev10.4/web/core/lib/Drupal/Core/Render/Renderer.php(432): Drupal\Core\Render\Renderer->doCallback()
    #13 /var/www/html/dev10.4/web/core/lib/Drupal/Core/Render/Renderer.php(248): Drupal\Core\Render\Renderer->doRender()
    #14 /var/www/html/dev10.4/web/core/lib/Drupal/Core/Render/Renderer.php(165): Drupal\Core\Render\Renderer->render()
    #15 /var/www/html/dev10.4/web/core/lib/Drupal/Core/Render/Renderer.php(638): Drupal\Core\Render\Renderer->Drupal\Core\Render\{closure}()
    #16 /var/www/html/dev10.4/web/core/lib/Drupal/Core/Render/Renderer.php(164): Drupal\Core\Render\Renderer->executeInRenderContext()
    #17 /var/www/html/dev10.4/web/core/modules/node/src/Plugin/Search/NodeSearch.php(526): Drupal\Core\Render\Renderer->renderInIsolation()
    #18 /var/www/html/dev10.4/web/core/modules/node/src/Plugin/Search/NodeSearch.php(490): Drupal\node\Plugin\Search\NodeSearch->indexNode()
    #19 /var/www/html/dev10.4/web/core/modules/search/search.module(80): Drupal\node\Plugin\Search\NodeSearch->updateIndex()
    #20 /var/www/html/dev10.4/web/core/lib/Drupal/Core/Cron.php(337): search_cron()
    #21 /var/www/html/dev10.4/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(395): Drupal\Core\Cron->Drupal\Core\{closure}()
    #22 /var/www/html/dev10.4/web/core/lib/Drupal/Core/Cron.php(320): Drupal\Core\Extension\ModuleHandler->invokeAllWith()
    #23 /var/www/html/dev10.4/web/core/lib/Drupal/Core/Cron.php(159): Drupal\Core\Cron->invokeCronHandlers()
    #24 /var/www/html/dev10.4/web/core/lib/Drupal/Core/ProxyClass/Cron.php(75): Drupal\Core\Cron->run()
    #25 /var/www/html/dev10.4/web/core/modules/system/src/Form/CronForm.php(167): Drupal\Core\ProxyClass\Cron->run()
    #26 [internal function]: Drupal\system\Form\CronForm->runCron()
    #27 /var/www/html/dev10.4/web/core/lib/Drupal/Core/Form/FormSubmitter.php(129): call_user_func_array()
    #28 /var/www/html/dev10.4/web/core/lib/Drupal/Core/Form/FormSubmitter.php(67): Drupal\Core\Form\FormSubmitter->executeSubmitHandlers()
    #29 /var/www/html/dev10.4/web/core/lib/Drupal/Core/Form/FormBuilder.php(597): Drupal\Core\Form\FormSubmitter->doSubmitForm()
    #30 /var/www/html/dev10.4/web/core/lib/Drupal/Core/Form/FormBuilder.php(326): Drupal\Core\Form\FormBuilder->processForm()
    #31 /var/www/html/dev10.4/web/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm()
    #32 [internal function]: Drupal\Core\Controller\FormController->getContentResult()
    #33 /var/www/html/dev10.4/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()
    #34 /var/www/html/dev10.4/web/core/lib/Drupal/Core/Render/Renderer.php(638): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
    #35 /var/www/html/dev10.4/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(121): Drupal\Core\Render\Renderer->executeInRenderContext()
    #36 /var/www/html/dev10.4/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
    #37 /var/www/html/dev10.4/vendor/symfony/http-kernel/HttpKernel.php(181): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
    #38 /var/www/html/dev10.4/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
    #39 /var/www/html/dev10.4/web/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle()
    #40 /var/www/html/dev10.4/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
    #41 /var/www/html/dev10.4/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
    #42 /var/www/html/dev10.4/web/core/modules/big_pipe/src/StackMiddleware/ContentLength.php(32): Drupal\Core\StackMiddleware\ContentLength->handle()
    #43 /var/www/html/dev10.4/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(116): Drupal\big_pipe\StackMiddleware\ContentLength->handle()
    #44 /var/www/html/dev10.4/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(90): Drupal\page_cache\StackMiddleware\PageCache->pass()
    #45 /var/www/html/dev10.4/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle()
    #46 /var/www/html/dev10.4/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
    #47 /var/www/html/dev10.4/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
    #48 /var/www/html/dev10.4/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle()
    #49 /var/www/html/dev10.4/web/core/lib/Drupal/Core/DrupalKernel.php(741): Drupal\Core\StackMiddleware\StackedHttpKernel->handle()
    #50 /var/www/html/dev10.4/web/index.php(19): Drupal\Core\DrupalKernel->handle()
    #51 {main}
    
    
Production build 0.71.5 2024