Problem/Motivation

Getting TypeError when accessing /admin/structure/taxonomy/manage/state/overview after a fresh D11 installation.

TypeError: Drupal\better_taxonomy\BTFormsService::createSectionFilter(): Argument #2 ($search_parameter) must be of type string, null given, called in /var/www/html/web/modules/contrib/better_taxonomy/src/Hook/BetterTaxonomyHooks.php on line 94 in Drupal\better_taxonomy\BTFormsService->createSectionFilter() (line 115 of modules/contrib/better_taxonomy/src/BTFormsService.php).

Steps to reproduce

1. In a fresh Drupal 11.4.4 installation install drupal/better_taxonomy (1.0.4) version.
1. Enable this module and goto /admin/structure/taxonomy/manage/state/overview
and you will get the error.

Proposed resolution

--- a/src/Hook/BetterTaxonomyHooks.php
+++ b/src/Hook/BetterTaxonomyHooks.php
@@ -91,7 +91,7 @@ class BetterTaxonomyHooks {
     }

     // Create Filter section.
-    $this->betterTaxonomyFormsService->createSectionFilter($form, $search_parameter);
+    $this->betterTaxonomyFormsService->createSectionFilter($form, $search_parameter ?? '');
   }

Remaining tasks

NA

User interface changes

NA

API changes

NA

Data model changes

NA

Command icon 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:

  • 1.0.x Comparecompare

Comments

msankhala created an issue. See original summary.

msankhala’s picture

Issue summary: View changes
msankhala’s picture

Issue summary: View changes
gurkawal’s picture

StatusFileSize
new702 bytes

Hi @msankhala,

I have reproduced the issue on my drupal11
Visiting a vocabulary overview page (e.g. /admin/structure/taxonomy/manage/tags/overview) throws:

TypeError: Drupal\better_taxonomy\BTFormsService::createSectionFilter():
Argument #2 ($search_parameter) must be of type string, null given,
called in BetterTaxonomyHooks.php on line 94

This happens on first load when there is no search query parameter.

Cause
BTService::checkSearch() returns ?string and returns NULL when no search query is present.

BetterTaxonomyHooks.php passes that value directly to createSectionFilter(), which was typed as string. On PHP 8+, passing null causes a TypeError even though the parameter has a default of ''.

Fix
Update createSectionFilter() to accept ?string $search_parameter and normalize with:

$search_parameter ??= '';
This matches checkSearch()’s return type and restores the intended empty-filter behavior.

Manual testing :
Installed Better Taxonomy 1.0.4 on Drupal 11.x.
Visited /admin/structure/taxonomy/manage/tags/overview with no ?search= query.
Before: TypeError on page load.
After: Page loads; filter field renders with an empty default value.
Verified search filtering still works when ?search=term is used.

Attaching a patch for the fix, Please review once

emasclans made their first commit to this issue’s fork.

emasclans’s picture

Status: Active » Fixed

The fix has been verified and published in the new release v1.0.5. Thanks everyone for the contribution!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • emasclans committed 5af8f808 on 1.0.x
    Issue #3624280: Fixed null search parameter by gurkawal
    
emasclans’s picture

Status: Fixed » Closed (fixed)

Just closing de issue