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;


    try {
        $result = eval( $code );
    } catch ( ParseError $parse_error ) {
        $result = $parse_error;


    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.

  • 3
    that plugin lets you put snippets of PHP code into your admin area, so it's the code in the admin area not the files you need to check. Ideally you'd remove that plugin and replace all the snippets with code in files as putting PHP code in the database and eval'ing it is a development dead end and a security risk
    – Tom J Nowell
    Feb 1 at 8:59
  • 2
    as for the error, you probably have a snippet with code that assumes the referer always exist, and when it doesn't perhaps due to privacy extensions a warning gets generated each time it tries to access it
    – Tom J Nowell
    Feb 1 at 8:59
  • Thank you. So, I understand I need to focus on references I have put in admin, leveraging on code present in snipping tool then. They are not so much... I will check it. Thanks.
    – Ioria
    Feb 1 at 12:04
  • Hi @TomJNowell, I am not able to reproduce the case. I tried to do all possible operations while I am in "tail" read for error_log. Nothing. I am nut sure what it is causing the problem. I need to find a way to detect root cause. :(
    – Ioria
    Feb 1 at 20:12
  • your error log can only ever point you to that eval statement as that's where the code snippets are evaluated, it can't point you to a file and a code location as the code snippets don't exist in files. At a minimum you should be able to search for HTTP_REFERER in your code snippets, but ideally you would convert those snippets to normal standard PHP code and remove that plugin, then you could use normal standard debugging steps. Otherwise you're probably going to need Code Snippet specific help. Since nobody can see these snippets nobody can help you
    – Tom J Nowell
    Feb 1 at 20:17


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.