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

Sign In or Register to comment.
This website uses cookies

We use cookies to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners who may combine it with other information that you’ve provided to them or that they’ve collected from your use of their services.

Cookies are small text files that can be used by websites to make a user's experience more efficient.

The law states that we can store cookies on your device if they are strictly necessary for the operation of this site. For all other types of cookies we need your permission. This means that cookies which are categorized as necessary, are processed based on GDPR Art. 6 (1) (f). All other cookies, meaning those from the categories preferences and marketing, are processed based on GDPR Art. 6 (1) (a) GDPR.

This site uses different types of cookies. Some cookies are placed by third party services that appear on our pages.

You can at any time change or withdraw your consent from the Cookie Declaration on our website.

Learn more about who we are, how you can contact us and how we process personal data in our Privacy Policy.

Please state your consent ID and date when you contact us regarding your consent.