• Resolved amslps

    (@amslps)


    WordPress version 6.1.2
    Active theme: Astra Child Theme (version 1.0)
    PHP version 8.1.19

    FastCGI sent in stderr: “PHP message: PHP Warning:  Array to string conversion in /usr/share/nginx/wordpress/wp-content/plugins/seo-by-rank-math/includes/opengraph/class-image.php on line 606PHP message: PHP Warning:  Array to string conversion in /usr/share/nginx/wordpress/wp-content/plugins/seo-by-rank-math/includes/opengraph/class-image.php on line 606” while reading response header from upstream,

    Can you fix on this?

Viewing 15 replies - 1 through 15 (of 22 total)
  • Thread Starter amslps

    (@amslps)

    Where is the support???? The error continue to promote. Can you fix on the next release????

    Plugin Support Rank Math Support

    (@rankmathteam)

    Hello @amslps,

    Thank you for contacting us, and sorry for any inconvenience that might have been caused due to that.

    From the error code, this happens when the shop or archive page is not able to fetch the image from the first post/product of that archive to set it as the og:image.

    Please make sure that all the custom post types on the website have a fallback thumbnail for Facebook under WordPress Dashboard > Rank Math > Titles & Meta Settings to get rid of this warning.

    Also, please note that this is simply a warning, so it won’t cause any issues with the normal functionality of the website, but it won’t include the metadata property.

    Moreover, please check your wp-config.php file to see if the debug log is set to display the error. If so, you can disable it so the error will not be displayed on your shop page:
    https://wordpress.org/support/article/debugging-in-wordpress/

    Looking forward to helping you.

    Thread Starter amslps

    (@amslps)

    Hello,

    Can you elaborate the point – ‘Please make sure that all the custom post types on the website have a fallback thumbnail for Facebook under WordPress Dashboard > Rank Math > Titles & Meta Settings to get rid of this warning.’

    I went to Titles & Meta that seems nowhere to set the a fallback thumbnail for Facebook?

    Can you help me on this??

    Plugin Support Rank Math Support

    (@rankmathteam)

    Hello @amslps,

    You should see something similar to this on the path of the setting we mentioned previously: https://i.rankmath.com/i/3GllkU

    Hope this helps solve your issues.

    Don’t hesitate to get in touch if you have any other questions.

    Thread Starter amslps

    (@amslps)

    Hi, I had upload facebook opengraph thumbnail image as fallback according to your guide, but I still got the error

    FastCGI sent in stderr: “PHP message: PHP Warning:  Array to string conversion in /usr/share/nginx/wordpress/wp-content/plugins/seo-by-rank-math/includes/opengraph/class-image.php on line 606PHP message: PHP Warning:  Array to string conversion in /usr/share/nginx/wordpress/wp-content/plugins/seo-by-rank-math/includes/opengraph/class-image.php on line 606

    Plugin Support Rank Math Support

    (@rankmathteam)

    Hello @amslps,

    The solution worked for many of our users. Since it’s not working yet for you, please try clearing your site, plugin, or any server-level cache to see if that works for you.

    If the issue persists, then assuming you are using the latest version of all the plugins and the themes (please update if not yet), it would seem like a conflict with one of the plugins or themes you are using.

    To determine that, please follow this troubleshooting guide:
    https://rankmath.com/kb/check-plugin-conflicts/

    Here is a video you can follow as well:
    https://www.youtube.com/watch?v=FcIWRhcUP2c&ab_channel=RankMathSEO

    Only the site admin would know, and your users won’t be affected by this troubleshooting.

    We really look forward to helping you.

    This tips is not working..

    Plugin Support Rank Math Support

    (@rankmathteam)

    Hello @dealmega,

    Can you please share a screenshot of the error message you see from your end?

    Preferably, please share your debugging log with the timestamp included so we can check when the last time the error message was recorded.

    Lastly, please head over to your WordPress Dashboard > Rank Math > Status & Tools > Database Tools and click on the button “Remove Transients” and see if that improves the situation.

    Looking forward to helping you.

    I’ve installed the plugin and this errors showed in archive page of a CPT.
    Doing debug the exception is due to this scenario

    // in /plugins/seo-by-rank-math/includes/opengraph/class-image.php 
    // line  602
    
    /**
       * Check if archive has an image and add this image.
       */
      private function set_archive_image() {
    
       // NOTE: 
       // request url: "my-site.com/my-cpt"
       // this url is the post archive page of "my-cpt"
    
        $post_type = get_query_var('post_type');
        
        // In my case, and i don't know why the returned value 
        // of "get_query_var" is not a string but an array of string 
        // $post_type = [ "my-cpt" ]
        // 
    
        // because of this in the next line (👇)
        // string interpolation  will fail
        // and trigger the exception "array to string conversion..." 
        //
        $image_id  = Helper::get_settings("titles.pt_{$post_type}_facebook_image_id");
        $this->add_image_by_id($image_id);
      }

    I modified the code like this and it works

    private function set_archive_image() {
        $post_type = get_query_var('post_type');
        
        // sometimes "post_type" returns array of string 
        // instead of string
        if (is_array($post_type)) $post_type = $post_type[0];
    
        $image_id  = Helper::get_settings("titles.pt_{$post_type}_facebook_image_id");
        $this->add_image_by_id($image_id);
      }

    But until you don’t include the same in the plugin code i cannot update it

    Plugin Support Rank Math Support

    (@rankmathteam)

    Hello @tresorama,

    The get_query_var function should not return the post_type in array format. Please check if a plugin conflict is causing the issue: https://rankmath.com/kb/check-plugin-conflicts/

    If the issue persists, please share the register_post_type function for the CPT showing this error.

    Looking forward to helping you.

    I used ACF to register CPT.

    this is the JSON

    {
        "key": "post_type_64dea13278e29",
        "title": "Experiences",
        "menu_order": 0,
        "active": true,
        "post_type": "bookable-tour",
        "advanced_configuration": true,
        "import_source": "",
        "import_date": "",
        "labels": {
            "name": "Experiences",
            "singular_name": "Experience",
            "menu_name": "Experiences",
            "all_items": "All Experiences",
            "edit_item": "Edit Experience",
            "view_item": "View Experience",
            "view_items": "View Experiences",
            "add_new_item": "Add New Experience",
            "add_new": "",
            "new_item": "New Experience",
            "parent_item_colon": "Parent Experience:",
            "search_items": "Search Experiences",
            "not_found": "No experiences found",
            "not_found_in_trash": "No experiences found in Trash",
            "archives": "Experience Archives",
            "attributes": "Experience Attributes",
            "featured_image": "",
            "set_featured_image": "",
            "remove_featured_image": "",
            "use_featured_image": "",
            "insert_into_item": "Insert into experience",
            "uploaded_to_this_item": "Uploaded to this experience",
            "filter_items_list": "Filter experiences list",
            "filter_by_date": "Filter experiences by date",
            "items_list_navigation": "Experiences list navigation",
            "items_list": "Experiences list",
            "item_published": "Experience published.",
            "item_published_privately": "Experience published privately.",
            "item_reverted_to_draft": "Experience reverted to draft.",
            "item_scheduled": "Experience scheduled.",
            "item_updated": "Experience updated.",
            "item_link": "Experience Link",
            "item_link_description": "A link to a experience."
        },
        "description": "",
        "public": true,
        "hierarchical": false,
        "exclude_from_search": false,
        "publicly_queryable": true,
        "show_ui": true,
        "show_in_menu": true,
        "admin_menu_parent": "",
        "show_in_admin_bar": true,
        "show_in_nav_menus": true,
        "show_in_rest": true,
        "rest_base": "",
        "rest_namespace": "wp\/v2",
        "rest_controller_class": "WP_REST_Posts_Controller",
        "menu_position": "",
        "menu_icon": "",
        "rename_capabilities": false,
        "singular_capability_name": "post",
        "plural_capability_name": "posts",
        "supports": [
            "title",
            "excerpt",
            "revisions",
            "thumbnail"
        ],
        "taxonomies": "",
        "has_archive": true,
        "has_archive_slug": "",
        "rewrite": {
            "permalink_rewrite": "post_type_key",
            "with_front": "1",
            "feeds": "0",
            "pages": "1"
        },
        "query_var": "post_type_key",
        "query_var_name": "",
        "can_export": true,
        "delete_with_user": false,
        "register_meta_box_cb": "",
        "modified": 1695644506
    }
    Plugin Support Rank Math Support

    (@rankmathteam)

    Hello @tresorama,

    We tried to reproduce the issue on our setup with the JSON you shared but we are still getting the value from the get_query_var in string format.

    What we would ask is that you make a conflict test with only Rank Math, ACF, and a default theme and test the same.

    If that doesn’t help pinpoint the culprit please open a ticket in our forums so we can evaluate this further. To open a ticket you can follow the procedure here: https://rankmath.com/kb/getting-support/

    Thank you.

    Sylvester

    (@sylwesterpresta)

    Quick-fix in wp-config.php

    The easiest way to hide those warnings and notices is to disable error reporting in the wp-config.php file:

    ini_set('display_errors','Off');
    ini_set('error_reporting', E_ALL );
    define('WP_DEBUG', false);
    define('WP_DEBUG_DISPLAY', false);
    Plugin Support Rank Math Support

    (@rankmathsupport)

    Hello @sylwesterpresta,

    Thank you for reaching out to our support.

    We appreciate your suggestion with regard to hiding the warning.

    Don’t hesitate to get in touch with us if you have any other questions.

    @rankmathsupport I get the same error on the custom posts search page. An example is this page where get_query_var returns an array as a result:

    ["guide"]=> string(5) "guide"

    The solution indicated by @tresorama was only partially correct (the array also uses the custom post type slug as an index and does not use a numeric value). To resolve the warning you need to add the following code before line 606:

    if ( is_array($post_type) ) $post_type = reset( $post_type );

    which extracts the custom post type slug.

Viewing 15 replies - 1 through 15 (of 22 total)

The topic ‘php error’ is closed to new replies.