• Resolved nursyfqh

    (@nursyfqh)


    Hi,

    WPForms cannot activate because of this error:

    Fatal error: Uncaught TypeError: Cannot access offset of type string on string in /../../public_html/wp-content/plugins/wpforms-lite/includes/class-install.php:188 Stack trace: #0 /../../public_html/wp-content/plugins/wpforms-lite/includes/class-install.php(82): WPForms_Install->run() #1 /../../public_html/wp-includes/class-wp-hook.php(287): WPForms_Install->install(”) #2 /../../public_html/wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters(”, Array) #3 /../../public_html/wp-includes/plugin.php(484): WP_Hook->do_action(Array) #4 /../../public_html/wp-admin/plugins.php(193): do_action(‘activate_wpform…’) #5 {main} thrown in /../../public_html/wp-content/plugins/wpforms-lite/includes/class-install.php on line 188

    and i also tried to update to latest version ( old version 1.6.6 ), but the plugin also cannot activate and show the same error. How can i fix this?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Support Ralden Souza

    (@rsouzaam)

    Hi @nursyfqh,

    Thanks for reaching out, and I’m sorry to hear about the issue you’re experiencing.

    When you get a chance, please share the details from WPForms > Tools > System Info (screenshot). This information may help us better understand the issue and provide further information.

    Thanks!

    ArrayIterator

    (@arrayiterator)

    Hello @rsouzaam this looks like your code direct load the integration before after_setup_theme

    Looks like your code is invalid on integration, eg: (divi or default themes)


    /**
    * This is array<string>
    * @var array<string>
    */
    $allow_themes = [ 'Divi', 'Extra' ]; // string[]
    $theme = wp_get_theme();
    $theme_name = $theme->get_template(); // string (OK)
    $theme_parent = $theme->parent(); // but this is \WP_Theme
    // invalid comparation cause using __tostring() / stringable theme object
    return (bool) array_intersect( [ $theme_name, $theme_parent ], $allow_themes );

    When you use it for comparation it will call __tostring() method, the stringable also call the display() method on WP_Theme.

    Please follow the github source of WP_Theme , that mean the display method will call the method of load_textdomain() even the init/setup theme not yet called.

    // ref: https://github.com/WordPress/wordpress-develop/blob/d088e31c73456179502c9bd5354fc43c6267bd7a/src/wp-includes/class-wp-theme.php#L811
    public function display( $header, $markup = true, $translate = true ) {
    $value = $this->get( $header );
    if ( false === $value ) {
    return false;
    }

    // this is the problem
    if ( $translate && ( empty( $value ) || ! $this->load_textdomain() ) ) {
    $translate = false;
    }

    if ( $translate ) {
    $value = $this->translate_header( $header, $value );
    }

    if ( $markup ) {
    $value = $this->markup_header( $header, $value, $translate );
    }

    return $value;
    }

    I prefer to change array_intersect with this code: (divi)

    /**
    * This is array<string>
    * @var array<string>
    */
    $allow_themes = [ 'Divi', 'Extra' ];
    $theme = wp_get_theme();
    $theme_name = $theme->get_template();
    $theme_parent = $theme->parent(); // \WP_Theme
    $theme_list = [
    $theme_name
    ];
    if ($theme_parent instanceof \WP_Theme) {
    $theme_list[] = $theme_parent->get_template();
    }
    // using comparison with real string[]
    return (bool) array_intersect( $theme_list, $allow_themes );

    • This reply was modified 7 months ago by ArrayIterator. Reason: change description
    Plugin Support Amjad Ali

    (@amjadali688)

    Hey @arrayiterator,

    Thank you for chiming in and sharing your detailed findings on this topic and your suggested fix.

    We have created a report for this issue internally, and our team is currently investigating. I’ll make sure to follow up with you as soon as we have an update or a resolution to share.

    Thank you so much for your patience.

    Plugin Support Kenneth Macharia

    (@kmacharia)

    Hey @arrayiterator and @nursyfqh,

    I wanted to share an update and let you know that our team has fixed the issue internally and the fix will be going out in the next update. We don’t have a release date but I can say that it will be sometime soon. I’ll share another update as soon as the fix goes out!

    Thank you again for reporting this.

    Thank you?
    Truly is also my fault 😅

    cause I’ve been in wrong topic & replies. I was writing about textdomain.

    Plugin Support Kenneth Macharia

    (@kmacharia)

    Hi @arrayiterator

    No worries at all! We’ll be addressing the Fatal error: Uncaught TypeError: Cannot access offset of type string on string error in this update.

    Thank you!

    Plugin Support Kenneth Macharia

    (@kmacharia)

    Hey @nursyfqh and @arrayiterator,

    I wanted to let you know that we have release version 1.9.2.3 of WPForms that contains a fix for this issue. Would you mind updating to this version is you have not done so already?

    Thank you!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Plugin could not be activated because it triggered a fatal error’ is closed to new replies.