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
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | better-taxonomy-null-search-parameter.patch | 702 bytes | gurkawal |
Issue fork better_taxonomy-3624280
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
msankhala commentedComment #3
msankhala commentedComment #4
gurkawal commentedHi @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
Comment #6
emasclans commentedThe fix has been verified and published in the new release v1.0.5. Thanks everyone for the contribution!
Comment #9
emasclans commentedJust closing de issue