• Resolved K. M.

    (@blarney27)


    I’m getting these error messages, do you know what the issue is and how to fix it?

    2023/02/22 03:27:28 [error] 123236#123236: *261645 FastCGI sent in stderr: “PHP message: PHP Warning: Undefined array key “name” in /www/XXXXXXXXX/public/wp-content/plugins/code-snippets/php/snippet-ops.php(505) : eval()’d code on line 3″ while reading response header from upstream, client: 35.236.17.54, server: http://www.XXXXXX.com, request: “HEAD /XXXXXXXXXX/ HTTP/1.1”, upstream: “fastcgi://unix:/var/run/php8.0-fpm-XXXXXXX.sock:”, host: “XXXXXXXXX”, referrer: “https://XXXXXXXXXXX”

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Shea Bunge

    (@bungeshea)

    Hi @blarney27,

    This is an error coming from one of your snippets. You have an array and are trying to access the ['name'] key, but that key does not exist.

    Unfortunately, it’s not something I can fix in the plugin, but if you’re able to find the snippet causing the error and post the code here, I’m happy to help debug. Searching for name @line:3 might help.

    Thread Starter K. M.

    (@blarney27)

    Thank you for the follow up, much appreciated. I only have one snippet; here it is:

    function remove_page_from_query_string($query_string)
    {
    if ($query_string[‘name’] == ‘page’ && isset($query_string[‘page’])) {
    unset($query_string[‘name’]);
    $query_string[‘paged’] = $query_string[‘page’];
    }
    return $query_string;
    }
    add_filter(‘request’, ‘remove_page_from_query_string’);

    Plugin Author Shea Bunge

    (@bungeshea)

    Hi Kevin,

    Here’s how you could rewrite that snippet to prevent errors:

    add_filter( 'request', function ( $query_string ) {
    	if ( isset( $query_string['page'], $query_string['name'] ) && 'page' === $query_string['name'] ) {
    		unset( $query_string['name'] );
    		$query_string['paged'] = $query_string['page'];
    	}
    	return $query_string;
    } );
    Thread Starter K. M.

    (@blarney27)

    Great! Thank you for your help, it’s very much appreciated!

    Plugin Author Shea Bunge

    (@bungeshea)

    No worries! Glad to help.

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

The topic ‘PHP – Syntax’ is closed to new replies.