array_fill_keys() expects parameter 1 to be array, string given

#227219
  • Resolved Alex Reina
    Rank Math free

    On PHP 7.4:
    PHP Warning: array_fill_keys() expects parameter 1 to be array, string given in /—/plugins/seo-by-rank-math/includes/admin/metabox/class-screen.php on line 253

    causes the SEO tab in Elementor to not load (can’t add nor edit any SEO data)

    On PHP 8:
    PHP Fatal error: Uncaught TypeError: array_fill_keys(): Argument #1 ($keys) must be of type array, string given in /—/plugins/seo-by-rank-math/includes/admin/metabox/class-screen.php:252

    causes a critical error when clicking on “edit with Elementor” on an affected post

Viewing 6 replies - 1 through 6 (of 6 total)
  • fix:

    
    	/**
    	 * Normalize robots.
    	 *
    	 * @param array $robots Array to normalize.
    	 *
    	 * @return array
    	 */
    	private function normalize_robots( $robots ) {
    		if ( empty( $robots ) ) {
    			$robots = Helper::get_robots_defaults();
    		}
    
    		if (! is_array( $robots ) ) {
    			$robots = array( $robots );
    		}
    
    		return array_fill_keys( $robots, true );
    	}
    

    Hello,

    Thank you for contacting Rank Math and bringing your concern to our attention. I’m sorry for any inconvenience this issue may have caused you.

    Could you please confirm if the fix you have shared already resolved this issue on your site?

    Looking forward to helping you.

    Thank you.

    Yes, the fix proposed solves the issue.

    Hello,

    Thank you so much for sharing this information.

    Would you mind asking if you have the Rank Math plugin and Elementor on their latest build? I tried replicating the issue with both PHP 7.4 and 8 and they seem to be working just fine.

    With that said, I will share this with our dev team for a quick investigation.

    Please don’t hesitate to contact us if you need our assistance with anything else.

    Hi,

    Currently running

    elementor-pro 3.3.2
    elementor 3.3.0
    seo-by-rank-math 1.0.67

    Hope that helps

    Hello,

    Thanks for sharing the info with us. We will let you know if we are able to replicate this and figure out what is causing the issue.

    Please don’t hesitate to get in touch with us if you need any further assistance.

    Thank You.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 6 replies - 1 through 6 (of 6 total)

The ticket ‘array_fill_keys() expects parameter 1 to be array, string given’ is closed to new replies.