Update 28.4.3 bug
Subject: Bug Report: PHP Fatal Error in Betheme 28.4.3 — Null Term Object in theme-functions.php
Hi Betheme / Muffin Group Team,
I wanted to report a PHP fatal error we encountered after updating to Betheme 28.4.3 on two of our WordPress sites running WPML (multilingual).
---
BUG DESCRIPTION
After updating to version 28.4.3, the WordPress site editor became inaccessible and the following PHP warnings appeared repeatedly in the error log, causing a critical site error:
PHP Warning: Attempt to read property "term_id" on false in /wp-content/themes/betheme/functions/theme-functions.php on line 3865
PHP Warning: Attempt to read property "slug" on false in /wp-content/themes/betheme/functions/theme-functions.php on line 3866
---
ROOT CAUSE
The issue is in the foreach loop in theme-functions.php around line 3860. The function get_term_by() can return false when a taxonomy term doesn't exist or has been deleted. The code immediately tries to access ->term_id on the false return value without checking first:
$term = get_term_by('slug', $slug, $type);
$term = apply_filters('wpml_object_id', $term->term_id, $type, true); // Fatal if $term is false
$slug = get_term_by('term_id', $term, $type)->slug; // Fatal if result is false
This is particularly triggered on sites using WPML where some taxonomy terms may exist in one language but not in another.
---
TEMPORARY FIX APPLIED
We resolved the issue by adding null checks inside the foreach loop:
$term = get_term_by('slug', $slug, $type);
if ( ! $term ) { continue; } // Skip if term not found
$term = apply_filters('wpml_object_id', $term->term_id, $type, true);
$term_obj = get_term_by('term_id', $term, $type);
if ( ! $term_obj ) { continue; } // Skip if term object not found
$slug = $term_obj->slug;
This fix prevents the fatal error and allows the site to function normally.
---
ENVIRONMENT
- Betheme version: 28.4.3
- WordPress version: 6.9.4
- PHP version: 8.3.31
- WPML version: 4.9.4 (multilingual site with EN/ES languages)
- File affected: /wp-content/themes/betheme/functions/theme-functions.php, lines 3860-3870
---
I hope this helps identify and fix the issue in the next release. Please let me know if you need any additional information or debug data.
Best regards
Hernan
Comments
Hi,
I have passed it on to the dev team, and we will correct that in the upcoming update.
Thank you for reporting this.
Best regards