Problem/Motivation
The website encountered an unexpected error. Please try again later.
Error: Call to undefined function Drupal\block_class\Service\str_contains() in Drupal\block_class\Service\BlockClassHelperService->validateDynamicClasses() (line 1001 of modules/contrib/block_class/src/Service/BlockClassHelperService.php).
Error: Call to undefined function Drupal\block_class\Service\str_contains() in Drupal\block_class\Service\BlockClassHelperService->validateDynamicClasses() (line 1001 of /home/.../public_html/modules/contrib/block_class/src/Service/BlockClassHelperService.php)
#0 /home/.../public_html/modules/contrib/block_class/src/Service/BlockClassHelperService.php(904): Drupal\block_class\Service\BlockClassHelperService->validateDynamicClasses(Array, Object(Drupal\Core\Form\FormState), Object(Drupal\Core\Config\Config))
#1 /home/.../public_html/modules/contrib/block_class/block_class.module(145): Drupal\block_class\Service\BlockClassHelperService->blockClassFormValidate(Array, Object(Drupal\Core\Form\FormState))
#2 [internal function]: block_class_form_block_form_validate(Array, Object(Drupal\Core\Form\FormState))
#3 /home/.../public_html/core/lib/Drupal/Core/Form/FormValidator.php(82): call_user_func_array('block_class_for...', Array)
#4 /home/.../public_html/core/lib/Drupal/Core/Form/FormValidator.php(273): Drupal\Core\Form\FormValidator->executeValidateHandlers(Array, Object(Drupal\Core\Form\FormState))
#5 /home/.../public_html/core/lib/Drupal/Core/Form/FormValidator.php(118): Drupal\Core\Form\FormValidator->doValidateForm(Array, Object(Drupal\Core\Form\FormState), 'block_form')
#6 /home/.../public_html/core/lib/Drupal/Core/Form/FormBuilder.php(589): Drupal\Core\Form\FormValidator->validateForm('block_form', Array, Object(Drupal\Core\Form\FormState))
#7 /home/.../public_html/core/lib/Drupal/Core/Form/FormBuilder.php(321): Drupal\Core\Form\FormBuilder->processForm('block_form', Array, Object(Drupal\Core\Form\FormState))
#8 /home/.../public_html/core/lib/Drupal/Core/Entity/EntityFormBuilder.php(61): Drupal\Core\Form\FormBuilder->buildForm(Object(Drupal\block\BlockForm), Object(Drupal\Core\Form\FormState))
#9 /home/.../public_html/core/modules/block/src/Controller/BlockAddController.php(27): Drupal\Core\Entity\EntityFormBuilder->getForm(Object(Drupal\block\Entity\Block))
#10 [internal function]: Drupal\block\Controller\BlockAddController->blockAddConfigureForm('views_exposed_f...', 'intrepidnetwork')
#11 /home/.../public_html/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#12 /home/.../public_html/core/lib/Drupal/Core/Render/Renderer.php(573): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#13 /home/.../public_html/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#14 /home/.../public_html/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#15 /home/.../public_html/vendor/symfony/http-kernel/HttpKernel.php(151): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#16 /home/.../public_html/vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#17 /home/.../public_html/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#18 /home/.../public_html/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#19 /home/.../public_html/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#20 /home/.../public_html/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#21 /home/.../public_html/core/modules/ban/src/BanMiddleware.php(50): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#22 /home/.../public_html/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\ban\BanMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#23 /home/.../public_html/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#24 /home/.../public_html/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#25 /home/.../public_html/core/lib/Drupal/Core/DrupalKernel.php(708): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#26 /home/.../public_html/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#27 {main}
Steps to reproduce
Updated from 8.x-1.3 to 2.0.0 - running Drupal 8.9.20 PHP version 7.4.30
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Issue fork block_class-3301667
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
joshuautley commentedComment #3
renatog commented@joshuautley thank you so much for reporting
Just one question, after update what do you did to reproduce that? E.g. Only open any page? Running drush updb, Editing the Block in the CMS, etc?
Just to help in the fix
Comment #4
joshuautley commentedTo reproduce I placed a block from views on (admin/structure/block). Let me know if you need more details.
Comment #5
victorml commentedI'll try to fix.
Comment #7
victorml commentedThe str_contains function works only from php 8 above, so I changed the validation to use strpos function.
I believe the logic still the same but now using a function supported by older php versions.
Comment #8
lucasbaralmI will review this.
Comment #9
lucasbaralmTested and concluding, considering the modification made, the logic of the return of the conditional that had the undefined function problem is equivalent to the previous one, but without the undefined function problem in versions earlier than PHP 8.
Before:
After:
Comment #10
renatog commentedAmazing contribution!
Thank so much @joshuautley for reporting, @victorml for the fix and @lucasbaralm for the validation
Moved to the dev branch
Comment #11
joshuautley commentedGreat to hear. Thank you!
Comment #12
renatog commentedNew version 2.0.2 released with this fix.
Have a great day
Comment #13
anybodyThis wasn't implemented correctly, I think!
if (strpos($key, 'classes_') != FALSE) {must be
if (strpos($key, 'classes_') !== FALSE) {see https://www.php.net/manual/de/function.strpos.php
Comment #14
anybodyComment #15
renatog commentedYeah, good catch @anybody you're absolutely right
Comment #18
rpayanmPlease review.
Comment #19
renatog commentedAwesome. Thanks a lot
Comment #21
renatog commentedMerged to the dev branch
Thanks everyone