• Resolved sybilrondeau

    (@sybilrondeau)


    Hi,
    I have this php error (not a visible problem on wp)
    File Error: wordfence/lib/wordfenceClass.php (Line: 2141)
    Message :
    unlink(relative/path/to/wp-content/wflogs/template.0415525001615141240.tmp): No such file or directory

    What is it ?
    Regards
    Sybil.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support wfpeter

    (@wfpeter)

    Hi @sybilrondeau, thanks for getting in touch.

    To me, it looks like you’re using a custom PHP error handler. We suppress these warnings with @, so it’s not logged in normal error logs, but custom error handlers can choose to ignore @.

    The reason the warning is intended to be suppressed is because the file isn’t supposed to exist at the time anyway, and we want to remove/replace it if it does exist.

    Thanks,

    Peter.

    Thread Starter sybilrondeau

    (@sybilrondeau)

    Ok thank you !

    Regards

    Sybil.

    Thread Starter sybilrondeau

    (@sybilrondeau)

    Can’t you just check if the file exist with a conditional so this error doesn’t pop up ?

    • This reply was modified 3 years, 8 months ago by sybilrondeau.
    • This reply was modified 3 years, 8 months ago by sybilrondeau.
    Plugin Support wfpeter

    (@wfpeter)

    Hi @sybilrondeau,

    I have spoken to our development team about this, and they have explained that if the file doesn’t exist yet, it would actually be subject to a race condition. If we check whether it’s deleted, and don’t find it, then a parallel operation creates the file after the check, it will exist before you try to create it. Fewer file checks and just deleting it if it’s there, but ignoring it if it’s not is the more efficient option and less likely to cause problems.

    Thanks again,

    Peter.

    Thread Starter sybilrondeau

    (@sybilrondeau)

    Ok thank you for your response.

    Regards
    Sybil.

    I use a plugin to report errors to my email, so that while developing plugins etc if I miss something I am alerted to the issue ASAP.

    This is the message I get:
    Error Level: E_WARNING
    Message: unlink(/path/to/wflogs/template.0336158001618457926.tmp): No such file or directory
    File: /path/to/plugins/wordfence/lib/wordfenceClass.php
    Line: 2165

    I have fixed this annoying warning in an otherwise awesome plugin by wrapping @unlink( $tmpTemplate ); on line 2165 in a file check condition, like so.

    if ( file_exists( $tmpTemplate ) ) { @unlink( $tmpTemplate ); }

    This is not going to affect efficiency and is much clearer then just trying to suppress the error you know is going to happen even if only on rare occasions. No need to attempt to delete the file if it doesn’t exist anyways.

    • This reply was modified 3 years, 7 months ago by TheNerdCave.
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘E_warning error’ is closed to new replies.