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

Warnings in ACP->Config->Plugins (Warning [2] Illegal string offset) #82

Open
mateuszfigas opened this issue Apr 19, 2023 · 1 comment

Comments

@mateuszfigas
Copy link

I have some issues with this plugin and can't find resulution for this

Warning [2] Illegal string offset 'database' - Line: 110 - File: inc/plugins/google_seo/plugin.php PHP 5.6.40 (Linux)

File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/google_seo/plugin.php 110 errorHandler->error_callback
/inc/plugins/google_seo/plugin.php 68 google_seo_plugin_status
/inc/plugins/google_seo.php 56 google_seo_plugin_info
/inc/class_plugins.php 225 google_seo_info
/admin/modules/config/plugins.php 644 pluginSystem->is_compatible
/admin/modules/config/plugins.php 564 build_plugin_list
/admin/index.php 830 require

Warning [2] Illegal string offset 'encoding' - Line: 110 - File: inc/plugins/google_seo/plugin.php PHP 5.6.40 (Linux)

File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/google_seo/plugin.php 110 errorHandler->error_callback
/inc/plugins/google_seo/plugin.php 68 google_seo_plugin_status
/inc/plugins/google_seo.php 56 google_seo_plugin_info
/inc/class_plugins.php 225 google_seo_info
/admin/modules/config/plugins.php 644 pluginSystem->is_compatible
/admin/modules/config/plugins.php 564 build_plugin_list
/admin/index.php 830 require

Warning [2] Illegal string offset 'database' - Line: 113 - File: inc/plugins/google_seo/plugin.php PHP 5.6.40 (Linux)

File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/google_seo/plugin.php 113 errorHandler->error_callback
/inc/plugins/google_seo/plugin.php 68 google_seo_plugin_status
/inc/plugins/google_seo.php 56 google_seo_plugin_info
/inc/class_plugins.php 225 google_seo_info
/admin/modules/config/plugins.php 644 pluginSystem->is_compatible
/admin/modules/config/plugins.php 564 build_plugin_list
/admin/index.php 830 require

Warning [2] Illegal string offset 'encoding' - Line: 113 - File: inc/plugins/google_seo/plugin.php PHP 5.6.40 (Linux)

File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/google_seo/plugin.php 113 errorHandler->error_callback
/inc/plugins/google_seo/plugin.php 68 google_seo_plugin_status
/inc/plugins/google_seo.php 56 google_seo_plugin_info
/inc/class_plugins.php 225 google_seo_info
/admin/modules/config/plugins.php 644 pluginSystem->is_compatible
/admin/modules/config/plugins.php 564 build_plugin_list
/admin/index.php 830 require

Warning [2] Illegal string offset 'admin_dir' - Line: 153 - File: inc/plugins/google_seo/plugin.php PHP 5.6.40 (Linux)

File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/google_seo/plugin.php 153 errorHandler->error_callback
/inc/plugins/google_seo/plugin.php 68 google_seo_plugin_status
/inc/plugins/google_seo.php 56 google_seo_plugin_info
/inc/class_plugins.php 225 google_seo_info
/admin/modules/config/plugins.php 644 pluginSystem->is_compatible
/admin/modules/config/plugins.php 564 build_plugin_list
/admin/index.php 830 require

image

@mateuszfigas
Copy link
Author

mateuszfigas commented Apr 25, 2023

I seem to have a solution to this problem. The errors are gone, but it would be useful if someone else verified the operation of this code.

In inc/plugins/google_seo/plugin.php Change this:

if($mybb->config['database']['encoding'] != 'utf8mb4')
    {
        $warning[] = $lang->sprintf($lang->googleseo_plugin_warn_encoding,
                                    $mybb->config['database']['encoding']);
    }

For:

if (isset($mybb->config['database']) && is_array($mybb->config['database']) &&
    isset($mybb->config['database']['encoding']) && $mybb->config['database']['encoding'] != 'utf8mb4')
{
    $warning[] = $lang->sprintf($lang->googleseo_plugin_warn_encoding, $mybb->config['database']['encoding']);
}

And change this:

if($settings['google_seo_redirect'])
    {
        $success[] = $lang->googleseo_plugin_redirect;

        if(!$settings['google_seo_url'])
        {
            $warning[] = $lang->googleseo_plugin_redirect_warn_url;
        }

        $current_url = google_seo_redirect_current_url();
        $pos = my_strpos($current_url, "/{$config['admin_dir']}/index.php");

        if($pos)
        {
            $current_url = my_substr($current_url, 0, $pos);
        }


        if(!$settings['bburl'] || $settings['bburl'] != $current_url)
        {
            $warning[] = $lang->sprintf($lang->googleseo_plugin_redirect_warn_bburl,
                                        htmlspecialchars($settings['bburl'], ENT_COMPAT, "UTF-8"),
                                        htmlspecialchars($current_url), ENT_COMPAT, "UTF-8");
        }
    }

    else
    {
        $error[] = $lang->googleseo_plugin_redirect;
    }

For this:

if(isset($settings['google_seo_redirect']) && is_array($settings['google_seo_redirect']))
{
    if($settings['google_seo_redirect'])
    {
        $success[] = $lang->googleseo_plugin_redirect;

        if(isset($settings['google_seo_url']) && !$settings['google_seo_url'])
        {
            $warning[] = $lang->googleseo_plugin_redirect_warn_url;
        }

        $current_url = google_seo_redirect_current_url();
        $pos = my_strpos($current_url, "/{$config['admin_dir']}/index.php");

        if($pos !== false)
        {
            $current_url = my_substr($current_url, 0, $pos);
        }

        if(isset($settings['bburl']) && (!$settings['bburl'] || $settings['bburl'] != $current_url))
        {
            $warning[] = $lang->sprintf($lang->googleseo_plugin_redirect_warn_bburl,
                                        htmlspecialchars($settings['bburl'], ENT_COMPAT, "UTF-8"),
                                        htmlspecialchars($current_url), ENT_COMPAT, "UTF-8");
        }
    }

    else
    {
        $error[] = $lang->googleseo_plugin_redirect;
    }
}

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

No branches or pull requests

1 participant