admin管理员组

文章数量:1125452

I tried to read similar questions, but not easy for me to understand.

I have hundreds, maybe thousands, of those warnings my error_log, generated multiple times 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

    /**
 * 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;
}

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

Hope someone can help me with this. Thanks in advance. Regards. mario.

本文标签: errorsPHP Warning Undefined array key “HTTPREFERER”