Demo content import (and, as a side effect, opening the Brizy editor on the same request path) fails with an uncaught fatal error
# Bug report: Fatal error "Cannot call constructor" in `import/importer.php` (PHP 8.1+)
## Summary
Demo content import (and, as a side effect, opening the Brizy editor on the same request path) fails with an uncaught fatal error:
```
PHP Fatal error: Uncaught Error: Cannot call constructor in
/wp-content/plugins/brizy/import/importer.php:39
```
Root cause: `Brizy_Import_Importer::__construct()` unconditionally calls `parent::__construct()`, but the `WP_Importer` base class it extends (loaded from WordPress core's `wp-admin/includes/class-wp-importer.php`) defines **no constructor at all** — not even a legacy PHP4-style one. Calling `parent::__construct()` when no class in the inheritance chain defines that method is a fatal error in PHP on every version (this is not a PHP-8.3-specific removal); it simply hadn't been noticed because most installs don't exercise this code path, or happen to have another plugin/mu-plugin defining `WP_Importer` with a constructor before Brizy's own conditional `require`.
## Environment
- Brizy (free): **2.8.22**
- Brizy Pro: **2.8.12**
- PHP: **8.3.32** (64-bit), SAPI `apache2handler`
- Web server: Apache/2.4.52
- OS: Linux 6.8.0-136-generic x86_64
- OPcache: enabled
- Host: shared hosting (Timeweb)
- WordPress core's `wp-admin/includes/class-wp-importer.php` on this install carries the `#[AllowDynamicProperties]` attribute (added to WP core in 6.1), for reference — no constructor is defined anywhere in that file.
- Other active plugins at time of failure: Akismet, Cyr-To-Lat, Yoast SEO, WP File Manager, Yandex Metrika (no third-party plugin defines `WP_Importer` on this install, so Brizy's own `require ABSPATH . 'wp-admin/includes/class-wp-importer.php'` fallback is what runs).
## Steps to reproduce
1. Fresh/clean WordPress + Brizy + Brizy Pro install, PHP 8.3.
2. Trigger the demo content importer (`wp_ajax_brizy-import-demo` → `Brizy_Import_Main->ajaxImportDemo()`).
3. Import fails immediately with the fatal error below. The editor also errors out on the same/related pages until the import completes successfully.
## Error log
```
[PHP Deprecated] Function libxml_disable_entity_loader() is deprecated in
.../wp-content/plugins/brizy/import/parsers/simplexml.php on line 18
[PHP Deprecated] Function libxml_disable_entity_loader() is deprecated in
.../wp-content/plugins/brizy/import/parsers/simplexml.php on line 22
[PHP Fatal error] Uncaught Error: Cannot call constructor in
.../wp-content/plugins/brizy/import/importer.php:39
Stack trace:
#0 .../wp-content/plugins/brizy/import/import.php(44): Brizy_Import_Importer->__construct(Array, Object(Brizy_Import_Extractor))
#1 .../wp-content/plugins/brizy/import/main.php(121): Brizy_Import_Import->import(false)
#2 .../wp-includes/class-wp-hook.php(353): Brizy_Import_Main->ajaxImportDemo('')
#3 .../wp-includes/class-wp-hook.php(377): WP_Hook->apply_filters('', Array)
#4 .../wp-includes/plugin.php(523): WP_Hook->do_action(Array)
#5 .../wp-admin/admin-ajax.php(192): do_action('wp_ajax_brizy-i...')
#6 {main}
thrown in .../wp-content/plugins/brizy/import/importer.php on line 39
```
## Relevant source (current trunk, `import/importer.php`)
```php
if ( ! class_exists( 'WP_Importer' ) ) {
$class_wp_importer = ABSPATH . 'wp-admin/includes/class-wp-importer.php';
if ( file_exists( $class_wp_importer ) ) {
require $class_wp_importer;
}
}
class Brizy_Import_Importer extends WP_Importer {
...
public function __construct( $data, $extractor ) {
if ( ! function_exists( 'post_exists' ) ) {
require_once ABSPATH . 'wp-admin/includes/post.php';
}
parent::__construct(); // <-- line 39, fatals: WP_Importer has no __construct()
...
}
}
```
I confirmed the mechanism in isolation on plain PHP 8.4 as well — calling `parent::__construct()` when no ancestor class defines `__construct()` always throws `Error: Cannot call constructor`, independent of the PHP version. Since WP core's `WP_Importer` never defines a constructor, this line only "works" on installs where something else has already defined a different `WP_Importer` class (with a real constructor) before Brizy's own `require` runs.
## Suggested fix
Guard the call, since `WP_Importer` has nothing to construct:
```php
if ( method_exists( 'WP_Importer', '__construct' ) ) {
parent::__construct();
}
```
or simply remove the `parent::__construct();` call — it is a no-op today for the WP-core `WP_Importer`.
## Workaround applied on our end
We patched line 39 of `wp-content/plugins/brizy/import/importer.php` with the guarded version above so the client's site is unblocked. Flagging this so it can be fixed upstream — otherwise the patch will be lost on the next Brizy update, and other users hitting the demo importer on stock WordPress installs (without a third-party `WP_Importer`) will keep hitting this fatal.
Happy to provide further details (full `wp_debug.log`, `phpinfo()`, etc.) if useful.
-
Hi Timur,
Thank you for reaching out.
We’ve received similar reports from some users who are unable to import the pre-made templates. We already have a fix for this issue, but it is currently available in beta and will be rolled out in the upcoming release.
In the meantime, please use the beta version from the link below to resolve the issue. The final version will be released soon.
https://drive.google.com/drive/folders/10ovZt2GmC3aTjvUla-7AWGBApO8qp3Yv?usp=sharing
Please try this and let me know if you have any further questions.
Best regards,
Ariel H.0
Please sign in to leave a comment.
Comments
1 comment