Bug Report: TypeError in td_util.php During Search Queries

Posted in: Newspaper
Post count: 22

Issue Summary
A fatal TypeError occurs in TagDiv Composer’s td_util.php file when performing search queries on sites using the Newspaper theme. The error prevents pages from loading and disrupts user experience.

Error Details
Perform a search query (e.g., /?s=term).
Error triggers during template loading.

Root Cause
In the get_template_id method, the code assumes td_cpt option is always an array:


$td_cpt = td_util::get_option('td_cpt');
if ( !empty( $td_cpt[$post_type]['search_tpl'] ) ) {
// ...
}

However, get_option may return a string in some cases, causing the TypeError when using array syntax.

Suggested Fix
Add an array type check before access:


$td_cpt = td_util::get_option('td_cpt');
if ( is_array($td_cpt) && !empty( $td_cpt[$post_type]['search_tpl'] ) ) {
$cpt_search_template_id = $td_cpt[$post_type]['search_tpl'];
}

This affects sites with CPT searches, leading to broken search functionality. We recommend implementing this fix in future plugin updates to ensure compatibility and stability.

Post count: 35449

Hi,

Thank you for taking the time to share with us a possible fix for this problem.
Our developer has this bug on their fix list and should be resolved in the coming theme update.

Thank you!

Viewing 2 posts - 1 through 2 (of 2 total)
The forum ‘Newspaper’ is closed to new topics and replies.