Directory

Fatal error: Uncaught Error: Call to undefined method WP_Error::addThemeDir() · Issue #492 · WordPress/create-block-theme · GitHub
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal error: Uncaught Error: Call to undefined method WP_Error::addThemeDir() #492

Closed
oneuniverseappz opened this issue Dec 20, 2023 · 4 comments · Fixed by #609
Closed

Comments

@oneuniverseappz
Copy link

oneuniverseappz commented Dec 20, 2023

ERROR on Creating a Child Theme, OR, Cloning a Theme. Help !
Wordpress Version 6.4.2
Installed Theme - Twenty Twenty-Four Version: 1.0

Fatal error: Uncaught Error: Call to undefined method WP_Error::addThemeDir() in D:\ThemeBuilder\wp-content\plugins\create-block-theme\admin\create-theme\theme-zip.php:103 Stack trace: #0 D:\ThemeBuilder\wp-content\plugins\create-block-theme\admin\class-create-theme.php(266): Theme_Zip::add_templates_to_zip(Object(WP_Error), 'user', 'sample2024new...') #1 D:\ThemeBuilder\wp-content\plugins\create-block-theme\admin\class-create-theme.php(470): Create_Block_Theme_Admin->create_child_theme(Array, Array) #2 D:\ThemeBuilder\wp-includes\class-wp-hook.php(324): Create_Block_Theme_Admin->blockbase_save_theme('') #3 D:\ThemeBuilder\wp-includes\class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array) #4 D:\ThemeBuilder\wp-includes\plugin.php(517): WP_Hook->do_action(Array) #5 D:\ThemeBuilder\wp-admin\admin.php(175): do_action('admin_init') #6 D:\ThemeBuilder\wp-admin\themes.php(10): require_once('D:\Programs\Xam...') #7 {main} thrown in D:\ThemeBuilder\wp-content\plugins\create-block-theme\admin\create-theme\theme-zip.php on line 103

@creativecoder
Copy link
Contributor

Hi @oneuniverseappz thanks for reporting the error.

In order to export a theme zip, the site needs to have access to the Zip extension for PHP, to be able to create .zip files. My guess would be that your site doesn't currently have that extension enabled. Maybe you can check with your web host?


This does reveal that we need better error handling here, both in the code (we shouldn't be trying to call addThemeDir() on WP_Error!), and showing this error in the UI to explain why theme export doesn't work.

@creativecoder
Copy link
Contributor

Note that another user encountered this problem in #534. It seems that it's common for local dev environments that use xampp, mamp, and similar to not have the PHP zip extension enabled by default.

@t-hamano
Copy link
Contributor

Should we display some kind of error message when the ZipArchive class does not exist, like the theme export function does?

https://github.com/WordPress/wordpress-develop/blob/e9bea6d9bb27ebaf0cd4177c72fe56c79907cc23/src/wp-includes/block-template-utils.php#L1289-L1291

@creativecoder
Copy link
Contributor

Should we display some kind of error message when the ZipArchive class does not exist, like the theme export function does?

Yes, that seems appropriate!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants