0

I'm inspecting an open source web application. There's aproblem that it used error_get_last function as in this code

$last_error = error_get_last();
if($last_error['type'] === E_ERROR || $last_error['type'] === E_PARSE) {
  include 'error.php';
}
if (ob_get_length()) ob_end_flush();

It annoys me because it seem that it cache old error of the old code however the edited code doesn't have any error. Therefore it display old error for a while. Does anyone know how to solve this problem? Thanks for any help

Edit: I show the function __shutdown() where the code run in the end of a request

function __shutdown() {
    $logger_session = Logger::getSession();
    if (($logger_session instanceof Logger_Session) && !$logger_session->isEmpty()) {
      Logger::saveSession();
    } // if
    $last_error = error_get_last();
    if($last_error['type'] === E_ERROR || $last_error['type'] === E_PARSE) {
      include 'error.php';
    }
    if (ob_get_length()) ob_end_flush();
  } // __shutdown
8
  • Is it popular open source web application? Can we know the name of open source? Commented Feb 8, 2011 at 5:47
  • @Zerkms: If I edited the code and it generated some errors, I fixed those errors but those errors still appeared. Commented Feb 8, 2011 at 6:15
  • @Singh: projectpier.org/ Commented Feb 8, 2011 at 6:16
  • @coolkid: then they are there, obviously. Commented Feb 8, 2011 at 6:18
  • @zerkm: In the showed error, it display the error for the old code. Commented Feb 8, 2011 at 6:34

1 Answer 1

1

The function error_get_last does not cache anything, it's just a function like substr and all the others. If what you see seems to be cached, the cacheing happens at a different place. Maybe you are editing the wrong file (or you didn't really fix the error), have an opcode or output cache or whatever.

Sign up to request clarification or add additional context in comments.

6 Comments

could you please install the ProjectPier and test it by add some invalid code to see the error, after that remove the invalid code to return to stable version, then will you still see the error?
I don't need to install it. error_get_last is a builtin PHP function that reports the last error that occured. If you fix the code so that no error occurs during the processing of your request, this function returns NULL. The manual doesn't lie.
Does it mean that the last error of the last PHP script? So therefore we cannot use this method for get the error of the running PHP script at the end of the script, right? because it may return the old error of old code in development environment, right?
No, the interpreter does not know anything about the last script it executed, not even which one it was. In this terms PHP is as stateless as HTTP. If you get the same error as last time although this error is definitely fixed, you are getting a cached version of the page. This cached page could come from an output cache or could be generated by cached opcode.
You should try it by your self, you will see that error_get_last returns the last error of PHP intepreter. That means this error may belong to the last script which generated this error
|

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.