Compability issue with BEF 8.x-5.0, BEF 6.0.3, BEF 7.0

Created on 27 July 2020, over 4 years ago
Updated 23 August 2024, 3 months ago

Problem/Motivation

In the Exposed Form options for a view, it's impossible to select Better Exposed Filters (with layout) as it throws the following PHP error:

ArgumentCountError: Too few arguments to function Drupal\better_exposed_filters\Plugin\views\exposed_form\BetterExposedFilters::__construct(), 6 passed in /var/www/modules/contrib/vefl/modules/vefl_bef/src/Plugin/views/exposed_form/VeflBef.php on line 78 and exactly 7 expected in Drupal\better_exposed_filters\Plugin\views\exposed_form\BetterExposedFilters->__construct() (line 74 of /var/www/modules/contrib/better_exposed_filters/src/Plugin/views/exposed_form/BetterExposedFilters.php)

It is due to a change in the newest relases of the Better Exposed Filters module (better_exposed_filters 8.x-5.0-beta1, better_exposed_filters 8.x-4.0-beta2).

In the latest release of BEF, class BetterExposedFilters implemented Drupal's ModuleHandlerInterface as a 7th argument, which break VeflBef.

Steps to reproduce

Install module VEFL (8.x-3.0) with module BetterExposedFilters (8.x-5.0-beta1).
Create a view that uses an exposed form and select "Better Exposed Filters (with layout)" as the exposed form style.

🐛 Bug report
Status

Needs review

Version

3.1

Component

Code

Created by

🇨🇦Canada emixaam

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

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

  • 🇨🇦Canada dshields

    Patch #2 works!

  • First commit to issue fork.
  • Merge request !1Resolve #3161777 "Vefl" → (Open) created by urvashi_vora
  • 🇷🇸Serbia krug

    Drupal Version: 8.9.20
    Better Exposed Filters better_exposed_filters 8.x-5.2
    Views exposed form layout vefl_bef 8.x-3.0
    Patch #2 works for me.
    @emixaam, thanks.

  • 🇺🇸United States crutch

    Unable to install vefl because requirement "Better Exposed Filters (>=8.x-4.x) (incompatible with version * ? *)"

    D 9.5.9
    BEF 6.0.3
    VEFL 8.x-3.0

  • 🇦🇹Austria maxilein

    This error also happens on

    D 10.2.3
    BEF 6.0.3
    VEFL 8.x-3.1

    Does the patch also work with BEF 6?

  • 🇦🇹Austria maxilein

    Changed because the patch works for BEF 6.0.3 also.

  • 🇷🇸Serbia krug

    Drupal Version: 10.2.2
    VEFL: 8.x-3.1
    BEF: 6.0.3
    Patch #2 works for me.
    @emixaam, thanks.

  • 🇹🇷Turkey orkut murat yılmaz Istanbul

    Drupal Version: 10.2.2
    VEFL: 8.x-3.1
    BEF: 6.0.3
    DB: PostgreSQL 15.6

    Patch #2 works for me as well:)

    Any chance for merge?

  • 🇵🇹Portugal jrochate

    What about this issue 🐛 Compability issue with BEF 6.0.3 Needs review ? The patch it's similar but a few more instructions.

  • 🇨🇳China jungle Chongqing, China

    Every time the BEF module changes the signature of __construct(), this module breaks. So I would suggest keeping __construct() untouched. And inject the vefl.layout service in create(), see the code snippet below, with this approach, 🐛 Compability issue with BEF 6.0.3 Needs review is a duplicate to me.

      /**
       * The vefl layout helper.
       *
       * @var \Drupal\vefl\Vefl
       */
      protected $vefl;
    
      /**
       * {@inheritdoc}
       */
      public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
        $instance = parent::create($container, $configuration, $plugin_id, $plugin_definition);
        $instance->vefl = $container->get('vefl.layout');
        return $instance;
      }
    
  • Status changed to Needs work 7 months ago
  • 🇨🇳China jungle Chongqing, China
  • Status changed to Needs review 7 months ago
  • 🇦🇹Austria maxilein

    #23 fixed it for me.
    D10.2.5
    php8.1

    I had the following recent error. #2 did not work any longer.

    ArgumentCountError: Too few arguments to function Drupal\better_exposed_filters\Plugin\views\exposed_form\BetterExposedFilters::__construct(), 7 passed in /.../web/modules/contrib/vefl/modules/vefl_bef/src/Plugin/views/exposed_form/VeflBef.php on line 89 and exactly 8 expected in Drupal\better_exposed_filters\Plugin\views\exposed_form\BetterExposedFilters->__construct() (line 84 of /.../web/modules/contrib/better_exposed_filters/src/Plugin/views/exposed_form/BetterExposedFilters.php).

  • 🇺🇸United States castella

    #23 fixed it for me as well.
    Attached is a patch file to use in the meantime.

  • 🇩🇪Germany NWOM

    #23 and #25 both wouldn't apply for me. Here is a new patch that works against 8x-3.1

  • Status changed to RTBC 6 months ago
  • 🇹🇷Turkey orkut murat yılmaz Istanbul

    I'm changing the status as RTBC. Thanks for the patch.

  • 🇦🇹Austria maxilein

    It is not working with the latest BEF 7.0, although the patch applies.

    It just gives a WSOD.
    Apache error log:

    PHP Fatal error: Type of Drupal\\vefl_bef\\Plugin\\views\\exposed_form\\VeflBef::$filterWidgetManager must be Drupal\\better_exposed_filters\\Plugin\\BetterExposedFiltersWidgetManager (as in class Drupal\\better_exposed_filters\\Plugin\\views\\exposed_form\\BetterExposedFilters) in /var/www/modules/contrib/vefl/modules/vefl_bef/src/Plugin/views/exposed_form/VeflBef.php on line 22, referer: https://testsite/admin/people?user=gab&status=All&role=All&permission=All

  • First commit to issue fork.
  • Merge request !5Resolve #3161777 "Bef 7.0" → (Open) created by fskreuz
  • Status changed to Needs review 3 months ago
  • 🇺🇸United States fskreuz

    Added a separate MR for BEF 7.0. Wasn't sure if adding the additional changes to the existing MR would affect anyone referencing the MR directly in some way.

  • 🇦🇹Austria maxilein

    @fskreuz.
    Thank you. the 7.0 patch works.

  • First commit to issue fork.
  • 🇺🇸United States euk

    Same issue with BEF v6.0.6.

    This will be always an issue if BEF is going to keep changing their create() and __construct() signatures all the time. Additionally, VeflTrait has a very obscure dependency on the Vefl service, which doesn't really exist in Vefl trait, but rather is expected to be added in the "treated" class.

    The way to decouple from this is to provide Vefl service along with the trait, as a getter for example. There are a few traits in the core that use this approach, so we can call this an acceptable practice.

    Another confusing thing is when an inherited member from a base class is overridden by a member inserted by a Trait, but this is a different story.

    I am adding another merge request to help with the service dependency.

Production build 0.71.5 2024