Newsmag 5.4.3.3 – Demo Import Fails on PHP 8.2/8.4 (TypeError: C…

Posted in: Newsmag
Post count: 4

Hi,

I’m running into a fatal error when trying to import a demo in Newsmag 5.4.3.3 (registered) with tagDiv Composer on a Plesk server.
The issue occurs on PHP 8.2 and PHP 8.4 during the demo import process.

Error Details
swift
Kopier
Rediger
PHP Fatal error: Uncaught TypeError: Cannot access offset of type string on string
in /wp-content/plugins/td-composer/legacy/common/wp_booster/wp-admin/panel/td_demo_util.php:2620
Stack trace:
#0 /…/td_import.php(159): td_demo_widgets::add_widget_to_sidebar()
#1 /…/td_demo_installer.php(319): require_once()

Additional warnings/notices during import:

Multiple exif_read_data(…): Incorrect APP1 Exif Identifier Code warnings

_load_textdomain_just_in_time called too early (WordPress 6.7.0 notice)

The fatal error prevents the demo from completing.

Environment
Theme: Newsmag 5.4.3.3 (registered)

tagDiv Composer: bundled version (legacy importer paths)

WordPress: 6.7.0
PHP Versions Tested: 8.2.x (FPM), 8.4.x (FPM) — both fail
Server: Plesk Obsidian, Apache2 (proxy_fcgi)

What We Found So Far
The error happens inside the legacy demo importer, specifically in td_demo_widgets::add_widget_to_sidebar() — looks like a PHP 8.1+ type handling change is breaking it.

The /legacy/… path suggests the importer code hasn’t been fully updated for PHP 8.2+.

No public changelog entries mention a fix for this specific fatal error.

There’s no pinned forum post or KB article covering it.

Rolling back to PHP 8.1 might work, but my current server doesn’t have it installed — planning to try that as a temporary workaround.

If the vendor has already patched this in a newer Composer or theme build, it’s not mentioned in docs.

Questions
Is this a known issue with the current demo importer on PHP 8.2+?

Has it been fixed in a newer release of Newsmag/tagDiv Composer (non-legacy importer)?

Is there an official workaround besides downgrading to PHP 8.1?

If I install PHP 8.1 just for the import, will that be supported, or do you recommend patching the importer code for PHP 8.2+?

Thanks in advance — happy to provide full error logs or run tests if it helps.

— Terje

Post count: 4

We ran into a reproducible issue with the Newsmag theme (tagDiv Composer) when importing a demo on PHP 8.2.

Symptoms:

tagDiv Importer stops with error:
Fatal error: Uncaught TypeError: Cannot access offset of type string on string in td_demo_util.php

Log also shows Undefined variable $sidebars_widgets and Automatic conversion of false to array is deprecated.

Root cause:
In td_demo_widgets::add_widget_to_sidebar(), the code uses $sidebars_widgets before it’s retrieved from get_option(‘sidebars_widgets’) and normalised.
PHP 8.x is stricter about this than PHP 7.x — in PHP 7 it silently converted null/false to array; in PHP 8 it throws a fatal error.

Workaround:
Patch the function to fetch and normalise $sidebars_widgets before using it. Here’s a minimal fix:

static function add_widget_to_sidebar($sidebar_id, $widget_name, $atts) {

$tmp_sidebars = td_options::get_array('sidebars');
if (empty($tmp_sidebars)) {
$tmp_sidebars = array();
}
if (!in_array('td-' . $sidebar_id, self::$hard_coded_sidebars) &&
!in_array($sidebar_id, $tmp_sidebars)
) {
self::kill(__CLASS__, __FUNCTION__,
'No sidebar with the name provided! - td-' . $sidebar_id,
array_merge(self::$hard_coded_sidebars, $tmp_sidebars)
);
}

// Normalise $atts
if (!is_array($atts)) {
if (is_string($atts)) {
$tmp = json_decode($atts, true);
$atts = is_array($tmp) ? $tmp : array();
} else {
$atts = array();
}
}

// FIX: Get and normalise $sidebars_widgets BEFORE using
$sidebars_widgets = get_option('sidebars_widgets');
if (!is_array($sidebars_widgets)) {
$sidebars_widgets = array();
}
$sb_key = 'td-' . td_util::sidebar_name_to_id($sidebar_id);
if (!isset($sidebars_widgets[$sb_key]) || !is_array($sidebars_widgets[$sb_key])) {
$sidebars_widgets[$sb_key] = array();
}

// Normalise widget instances
$opt_key = 'widget_' . $widget_name;
$widget_instances = get_option($opt_key);
if (!is_array($widget_instances)) {
$widget_instances = array();
}

// Add instance
$widget_instances[self::$last_widget_instance] = $atts;
update_option($opt_key, $widget_instances);

// Assign widget to sidebar
$sidebars_widgets[$sb_key][self::$last_sidebar_widget_position] =
$widget_name . '-' . self::$last_widget_instance;
update_option('sidebars_widgets', $sidebars_widgets);

self::$last_sidebar_widget_position++;
self::$last_widget_instance++;
}

Notes:

Tested on PHP 8.2.29 with Plesk Obsidian and Newsmag 5.4.3.3.

This patch allows the demo importer to complete successfully without downgrading PHP.

The EXIF warnings you may see in logs during import are unrelated and non-fatal.

If tagDiv devs see this — moving the $sidebars_widgets = get_option(‘sidebars_widgets’) block up in the function would resolve this for all PHP 8+ users.

Post count: 20685

Hi,

I’ll forward this to our developers and they will fix it. We are very sorry for this inconvenience. Thank you for posting a solution, it will be helpful in similar cases.

Thank you!

Post count: 312

Is it working perfectly in version 8.3? Have you tested it yet? Thanks

Post count: 35449

Hi thalesbrandao,
Yes is working – https://i.imgur.com/VXeQVoA.png
In case you are facing any problems, please let us know!
Thank you!

Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic.