Problem/Motivation
Wanted to use with better exposed form
Getting this error after enabling the module
ypeError: Unsupported operand types: string - int in Drupal\views_ef_fieldset\Plugin\views\display_extender\ViewsEFFieldset->buildOptionsForm() (line 201 of /var/www/web/modules/contrib/views_ef_fieldset/src/Plugin/views/display_extender/ViewsEFFieldset.php)
#0 /var/www/web/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php(1871): Drupal\views_ef_fieldset\Plugin\views\display_extender\ViewsEFFieldset->buildOptionsForm(Array, Object(Drupal\Core\Form\FormState))
#1 /var/www/web/core/modules/views/src/Plugin/views/display/PathPluginBase.php(440): Drupal\views\Plugin\views\display\DisplayPluginBase->buildOptionsForm(Array, Object(Drupal\Core\Form\FormState))
#2 /var/www/web/core/modules/views/src/Plugin/views/display/Page.php(257): Drupal\views\Plugin\views\display\PathPluginBase->buildOptionsForm(Array, Object(Drupal\Core\Form\FormState))
#3 /var/www/web/core/modules/views_ui/src/Form/Ajax/Display.php(74): Drupal\views\Plugin\views\display\Page->buildOptionsForm(Array, Object(Drupal\Core\Form\FormState))
#4 [internal function]: Drupal\views_ui\Form\Ajax\Display->buildForm(Array, Object(Drupal\Core\Form\FormState))
#5 /var/www/web/core/lib/Drupal/Core/Form/FormBuilder.php(531): call_user_func_array(Array, Array)
#6 /var/www/web/core/lib/Drupal/Core/Form/FormBuilder.php(278): Drupal\Core\Form\FormBuilder->retrieveForm('views_ui_edit_d...', Object(Drupal\Core\Form\FormState))
#7 /var/www/web/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php(215): Drupal\Core\Form\FormBuilder->buildForm('Drupal\\views_ui...', Object(Drupal\Core\Form\FormState))
#8 /var/www/web/core/lib/Drupal/Core/Render/Renderer.php(564): Drupal\views_ui\Form\Ajax\ViewsFormBase->Drupal\views_ui\Form\Ajax\{closure}()
#9 /var/www/web/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php(217): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#10 /var/www/web/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php(127): Drupal\views_ui\Form\Ajax\ViewsFormBase->ajaxFormWrapper('Drupal\\views_ui...', Object(Drupal\Core\Form\FormState))
#11 /var/www/web/core/modules/views_ui/src/Form/Ajax/Display.php(46): Drupal\views_ui\Form\Ajax\ViewsFormBase->getForm(Object(Drupal\views_ui\ViewUI), 'application_lis...', 'ajax')
#12 [internal function]: Drupal\views_ui\Form\Ajax\Display->getForm(Object(Drupal\views_ui\ViewUI), 'application_lis...', 'ajax', 'exposed_form_op...')
#13 /var/www/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#14 /var/www/web/core/lib/Drupal/Core/Render/Renderer.php(564): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#15 /var/www/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#16 /var/www/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#17 /var/www/vendor/symfony/http-kernel/HttpKernel.php(158): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#18 /var/www/vendor/symfony/http-kernel/HttpKernel.php(80): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#19 /var/www/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#20 /var/www/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#21 /var/www/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#22 /var/www/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#23 /var/www/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#24 /var/www/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#25 /var/www/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#26 /var/www/web/core/lib/Drupal/Core/DrupalKernel.php(708): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#27 /var/www/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#28 {main}Steps to reproduce
1. enable module
2. Click views exposed form setting in advanced section
Proposed resolution
N/A
Remaining tasks
fix code
User interface changes
N/A
API changes
N/A
Data model changes
N/A
| Comment | File | Size | Author |
|---|---|---|---|
| #17 | 3269083-17.patch | 2.46 KB | osopolar |
Issue fork views_ef_fieldset-3269083
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
sarbazx commentedComment #3
jlo101 commentedHi,
The problem is only associated with PHP8
In PHP v8 you are informed with a FATAL error that "Uncaught TypeError: Unsupported operand types: string + int"
Details:
https://stackoverflow.com/questions/66238017/fatal-error-uncaught-typeer...
Temporary solution:
/modules/views_ef_fieldset/src/Plugin/views/display_extender/ViewsEFFieldset.php
line 201:
$field->weight : $index - count($exposed_fields)),change to:
$field->weight : intval($index) - count($exposed_fields)),Comment #4
avpadernoComment #5
s_bhandari commentedHi,
Added the patch for the same. Please review.
Thanks.
Comment #6
polHello,
I'm not working with Drupal anymore since a couple of year, I switched to Symfony, read the story at: https://not-a-number.io/about/
Also, Drupal.org is now using the amazing Gitlab since 2018: https://about.gitlab.com/blog/2018/08/16/drupal-moves-to-gitlab/
Submitting changes through a patch file is counter productive and a waste of time.
Therefore, could you please provide a proper merge request if you want your contribution to be taken in account?
I'm doing this to reduce the amount of time I dedicate to this ecosystem.
Thanks.
Comment #7
avpadernoThe code should use the null coalescing operator.
Comment #10
attisanadded MR
Comment #11
avpadernoThe original code doesn't use
$field['admin_label'], but$field['id'].Then, the error reported in this issue is caused from the following code. (See comment #3.)
That is the code to change to fix this issue.
Comment #13
osopolarThe expressions in MR5 from #10 like
($field_options['title'] ?? '') ?: $label,look strange to me. @attisan: Why did you change this? Also, as apaderno already noticed, why should one want to show the admin label, that is something internal for views administration and is not meant to be shown to the end-user.@attisan In #7 you said:
Do you mean something like the following code?
'weight' => $field_options['weight']) ?? $field->weight ?? intval($index) - count($exposed_fields),I created a separate branch for patch #5 + feedback from #7:
Comment #15
osopolarCopy of patch from https://git.drupalcode.org/project/views_ef_fieldset/-/merge_requests/8.... attached, to be used with composer, see "Patches from drupal.org merge request URLs are dangerous?".
Comment #16
osopolarComment #17
osopolarCopy of patch from changed MR https://git.drupalcode.org/project/views_ef_fieldset/-/merge_requests/8.... attached, to be used with composer, see "Patches from drupal.org merge request URLs are dangerous?".
Comment #19
gaddman commented@Pol, updated as requested and tested OK.
Comment #20
zarpele commented#17 Works like a charm +1
Comment #23
eli-tThanks everyone!
Comment #25
jglynn commentedThis needs to be committed to the 8.x-1.6 version, it's a pretty major bug
Comment #26
eli-tWell I can't change what's in 8.x-1.6 but I can give you a shiny new 8.x-1.7 with this fix in: https://www.drupal.org/project/views_ef_fieldset/releases/8.x-1.7