Forum Replies Created
-
AuthorPosts
-
February 14, 2025 at 12:10 pm in reply to: Compatibility Issues with Enfold Builder on PHP 8.2 and WordPress 6.7 #1477120
Hello Gunter,
I hope you’re doing well.
After updating the Enfold theme to versions 6.0.8 and 6.0.9, I encountered a fatal error when attempting to save a post type. The error message is as follows:Fatal error: Uncaught TypeError: Cannot access offset of type string on string in /wp-content/themes/enfold/config-templatebuilder/avia-template-builder/php/class-meta-box.php on line 311
This issue seems to occur because $default_box[‘page’] is being treated as a string instead of an array. This results in in_array() failing, as it expects an array as its second argument.
Suggested Fix
To prevent this error and ensure compatibility, I recommend adding a safeguard to check whether $default_box[‘page’] is an array before using in_array().
Here’s a suggested fix for the issue:if ( isset($default_box['page']) && is_array($default_box['page']) && in_array($data['post_type'], $default_box['page']) ) {
Would it be possible to include this fix in the next theme update? Please let me know if you need any additional details to reproduce the issue.
Thank you for your time and support!
December 2, 2024 at 10:44 am in reply to: Compatibility Issues with Enfold Builder on PHP 8.2 and WordPress 6.7 #1472693After updating my PHP version from 7.3 to 8.2, I encountered a couple of issues with the theme due to type-related incompatibilities. These errors seem to arise from stricter type handling introduced in PHP 8.2 and primarily involve missing checks for variable types and proper initialization.
Errors Encountered
In class-template-builder.php at line 2604, within the apply_editor_wrap() method:Fatal Error:
Fatal error: Uncaught TypeError: Cannot access offset of type string on stringif( $box['id'] == $slug )
Suggested Fix:
if ( is_array( $box ) && isset( $box['id'] ) && $box['id'] == $slug )
In class-meta-box.php:
Fatal Error: Attempting to access an offset of type string on a string variable.
Warnings: Trying to access array offsets on a boolean value.
These issues occur due to uninitialized or improperly set variables. For example, the following line is problematic:if( in_array( $_POST['post_type'], $default_box['page'] ) )
Suggested Fixes:
if ( isset( $_POST['post_type'] ) && isset( $default_box['page'] ) && is_array( $default_box['page'] ) ) { if ( in_array( sanitize_text_field( $_POST['post_type'] ), $default_box['page'] ) ) { $must_check = true; } }
These changes involve adding type checks and sanitizing inputs, ensuring compatibility with PHP 8.2 while maintaining the theme’s functionality. They are straightforward adjustments that enhance the theme’s robustness across PHP versions.
If you’d like, I can share the exact code changes I made to resolve these issues. Could you kindly incorporate these fixes into the next update to ensure compatibility for all users?
Thank you for your continued support, and please let me know if you need any additional details.
November 29, 2024 at 12:42 pm in reply to: Compatibility Issues with Enfold Builder on PHP 8.2 and WordPress 6.7 #1472575This reply has been marked as private.November 28, 2024 at 3:52 pm in reply to: Compatibility Issues with Enfold Builder on PHP 8.2 and WordPress 6.7 #1472513This reply has been marked as private.November 22, 2024 at 4:38 pm in reply to: Compatibility Issues with Enfold Builder on PHP 8.2 and WordPress 6.7 #1471957Theme Version is 6.0.6
-
AuthorPosts