Forum Replies Created

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • 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!

    After 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 string

    
    if( $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.

    This reply has been marked as private.
    This reply has been marked as private.

    Theme Version is 6.0.6

Viewing 5 posts - 1 through 5 (of 5 total)