• Resolved ioria04

    (@ioria04)


    I have thousands of those warnings my error_log, generated multiple each day.

    That’s the error.

    [14-Jan-2024 14:32:50 UTC] PHP Warning:  Undefined array key "HTTP_REFERER" in /home/gialloec/public_html/wp-content/plugins/code-snippets/php/snippet-ops.php(582) : eval()'d code on line 16
    

    Now, searching on line 582 of file snippet-ops.php, I find this statement

        $result = eval( $code );

    just to give more context, this is the function. Can somebody help me?

    Regards.

    Mario

    /**
     * Execute a snippet.
     * Execute operation.
     *
     * Code must NOT be escaped, as it will be executed directly.
     *
     * @param string  $code  Snippet code to execute.
     * @param integer $id    Snippet ID.
     * @param boolean $force Force snippet execution, even if save mode is active.
     *
     * @return ParseError|mixed Code error if encountered during execution, or result of snippet execution otherwise.
     *
     * @since 2.0.0
     */
    function execute_snippet( string $code, int $id = 0, bool $force = false ) {
    	if ( empty( $code ) || ! $force && defined( 'CODE_SNIPPETS_SAFE_MODE' ) && CODE_SNIPPETS_SAFE_MODE ) {
    		return false;
    	}
    
    	ob_start();
    
    	try {
    		$result = eval( $code );
    	} catch ( ParseError $parse_error ) {
    		$result = $parse_error;
    	}
    
    	ob_end_clean();
    
    	do_action( 'code_snippets/after_execute_snippet', $code, $id, $result );
    	return $result;
    }

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter ioria04

    (@ioria04)

    Need to add that at line 16 there is no attempt to access array using key “HTTP_REFERER”.

    Plugin Author Shea Bunge

    (@bungeshea)

    This error is coming from one of your snippets, not from the plugin – the message is a little confusing.

    You should be able to identify which snippet it is with a search for HTTP_REFERER @line:16

    Thread Starter ioria04

    (@ioria04)

    Thank you @bungeshea. I think I have found the snippet, disabled, let’s see what happens now.

    Have another question… who is generating the error in error_log? is wordpress? I do not find it in internet.

    Regards.

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

The topic ‘PHP Warning: Undefined array key “HTTP_REFERER”’ is closed to new replies.