Page 1 of 1

Can't reproduce error

PostPosted: 27. May 2015 09:50
by Roaziel
Hi,

I have a client who is having trouble with her PHP website which is hosted by a company called Binero. Apparently, the problem appeared after the web host upgraded the PHP version to 5.6.8, and suddenly his (the clients) website started displaying an error that looks like this:
Deprecated: Non-static method XXXX should not be called statically, assuming $this from incompatible context in XXXX on line XXXX

I thought I would try to tackle this, so I figured I would install XAMPP 5.6.8 on my windows 7 computer and try to reproduce the problem so I can debug his site. The thing is, the error doesn't appear on the site hosted on my computer. I had a look in php.ini and it is set up to display errors, but I don't get any, they only appear on the site hosted by Binero. So I'm wondering why this is, and how can I reproduce the problem so I can start debugging?

Thanks in advanced
Raz

P.S. I ran phpinfo() and it is indeed running PHP 5.6.8.

Re: Can't reproduce error

PostPosted: 27. May 2015 10:29
by JJ_Tagy
Did you force Deprecated in your local environment? Each error type can be turned on as a separate bit.

Beyond the scope of this board, but you could also either remove static from the function call or make the function static.

Re: Can't reproduce error

PostPosted: 27. May 2015 10:50
by Nobbie
Roaziel wrote:I had a look in php.ini and it is set up to display errors


Thats not sufficient, you also should set display_startup_errors to 1. I think that this kind of error is not a runtime error, but a syntactical error and is parsed on startup.

Why dont you simply look into the given filename and proceed to the given linenumber? You should see, what is wrong there (because it is not a runtime error).

Re: Can't reproduce error

PostPosted: 27. May 2015 10:59
by Roaziel
JJ_Tagy wrote:Did you force Deprecated in your local environment? Each error type can be turned on as a separate bit.

I don't know what that means. Why and how would I do that?

Nobbie wrote:
Roaziel wrote:I had a look in php.ini and it is set up to display errors


Thats not sufficient, you also should set display_startup_errors to 1. I think that this kind of error is not a runtime error, but a syntactical error and is parsed on startup.

Why dont you simply look into the given filename and proceed to the given linenumber? You should see, what is wrong there (because it is not a runtime error).

Unfortunately it's not a single occurrence, there's a ton of them, and this isn't the only problem on the site, just the only one that is currently being displayed. So I have a ton of work to do and I can't do it on the clients server, I would rather work on it locally.

and display_startup_errors was also set to On, still no errors displayed.

Re: Can't reproduce error

PostPosted: 27. May 2015 12:27
by Nobbie
Roaziel wrote:I don't know what that means. Why and how would I do that?


Look into php.ini, there is a value called "error_reporting", this is responsible for the kind and severity of errors, which should be reported. There are many predefined constants, they all look like "E_XXXXX", where XXXXX is a certain kind of error, for example "E_DEPRECATED". If you set it to "E_ALL", everything (even a notice) is reported. See php.ini

At next, there are two different ways of error reporting:

a) as plain (HTML) Text online on the screen (thats what happening at the customer); in order to enable this feature, you have to enable the option "html_errors" for that (must set to "On").

b) into a logfile, this is specified by "error_log" (you have apply a valid filename) and also by "log_errors" (which triggers the logging). Must be set to "On".


I am bit surprised that you dont know these options, how could you develop PHP without error reporting?

Re: Can't reproduce error

PostPosted: 27. May 2015 12:29
by JJ_Tagy
Nobbie beat me to it, but here is what I was writing.

The explanations are in php.ini:
Code: Select all
; Error Level Constants:
; E_ALL             - All errors and warnings (includes E_STRICT as of PHP 6.0.0)
; E_ERROR           - fatal run-time errors
; E_RECOVERABLE_ERROR  - almost fatal run-time errors
; E_WARNING         - run-time warnings (non-fatal errors)
; E_PARSE           - compile-time parse errors
; E_NOTICE          - run-time notices (these are warnings which often result
;                     from a bug in your code, but it's possible that it was
;                     intentional (e.g., using an uninitialized variable and
;                     relying on the fact it's automatically initialized to an
;                     empty string)
; E_STRICT          - run-time notices, enable to have PHP suggest changes
;                     to your code which will ensure the best interoperability
;                     and forward compatibility of your code
; E_CORE_ERROR      - fatal errors that occur during PHP's initial startup
; E_CORE_WARNING    - warnings (non-fatal errors) that occur during PHP's
;                     initial startup
; E_COMPILE_ERROR   - fatal compile-time errors
; E_COMPILE_WARNING - compile-time warnings (non-fatal errors)
; E_USER_ERROR      - user-generated error message
; E_USER_WARNING    - user-generated warning message
; E_USER_NOTICE     - user-generated notice message
; E_DEPRECATED      - warn about code that will not work in future versions
;                     of PHP
; E_USER_DEPRECATED - user-generated deprecation warnings
;
; Common Values:
;   E_ALL (Show all errors, warnings and notices including coding standards.)
;   E_ALL & ~E_NOTICE  (Show all errors, except for notices)
;   E_ALL & ~E_NOTICE & ~E_STRICT  (Show all errors, except for notices and coding standards warnings.)
;   E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR  (Show only errors)
; Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED
; Development Value: E_ALL
; Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT
; http://php.net/error-reporting

error_reporting = E_ALL & ~E_NOTICE


So in this case, I selected ALL but NOT (~) NOTICE. You could either change yours to not use "~E_DEPRECATED" if it exists or add "& E_DEPRECATED" to the end to force it on. Notice the DEFAULT value listed above.

Re: Can't reproduce error

PostPosted: 27. May 2015 13:31
by Roaziel
Nobbie wrote:
Roaziel wrote:I don't know what that means. Why and how would I do that?


Look into php.ini, there is a value called "error_reporting", this is responsible for the kind and severity of errors, which should be reported. There are many predefined constants, they all look like "E_XXXXX", where XXXXX is a certain kind of error, for example "E_DEPRECATED". If you set it to "E_ALL", everything (even a notice) is reported. See php.ini

At next, there are two different ways of error reporting:

a) as plain (HTML) Text online on the screen (thats what happening at the customer); in order to enable this feature, you have to enable the option "html_errors" for that (must set to "On").

b) into a logfile, this is specified by "error_log" (you have apply a valid filename) and also by "log_errors" (which triggers the logging). Must be set to "On".


I am bit surprised that you dont know these options, how could you develop PHP without error reporting?

Lol, sorry, I wasn't aware you were referring to error reporting. I misunderstood what you were trying to say :P


JJ_Tagy wrote:Nobbie beat me to it, but here is what I was writing.

The explanations are in php.ini:
Code: Select all
; Error Level Constants:
; E_ALL             - All errors and warnings (includes E_STRICT as of PHP 6.0.0)
; E_ERROR           - fatal run-time errors
; E_RECOVERABLE_ERROR  - almost fatal run-time errors
; E_WARNING         - run-time warnings (non-fatal errors)
; E_PARSE           - compile-time parse errors
; E_NOTICE          - run-time notices (these are warnings which often result
;                     from a bug in your code, but it's possible that it was
;                     intentional (e.g., using an uninitialized variable and
;                     relying on the fact it's automatically initialized to an
;                     empty string)
; E_STRICT          - run-time notices, enable to have PHP suggest changes
;                     to your code which will ensure the best interoperability
;                     and forward compatibility of your code
; E_CORE_ERROR      - fatal errors that occur during PHP's initial startup
; E_CORE_WARNING    - warnings (non-fatal errors) that occur during PHP's
;                     initial startup
; E_COMPILE_ERROR   - fatal compile-time errors
; E_COMPILE_WARNING - compile-time warnings (non-fatal errors)
; E_USER_ERROR      - user-generated error message
; E_USER_WARNING    - user-generated warning message
; E_USER_NOTICE     - user-generated notice message
; E_DEPRECATED      - warn about code that will not work in future versions
;                     of PHP
; E_USER_DEPRECATED - user-generated deprecation warnings
;
; Common Values:
;   E_ALL (Show all errors, warnings and notices including coding standards.)
;   E_ALL & ~E_NOTICE  (Show all errors, except for notices)
;   E_ALL & ~E_NOTICE & ~E_STRICT  (Show all errors, except for notices and coding standards warnings.)
;   E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR  (Show only errors)
; Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED
; Development Value: E_ALL
; Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT
; http://php.net/error-reporting

error_reporting = E_ALL & ~E_NOTICE


So in this case, I selected ALL but NOT (~) NOTICE. You could either change yours to not use "~E_DEPRECATED" if it exists or add "& E_DEPRECATED" to the end to force it on. Notice the DEFAULT value listed above.

i checked this as well, still no errors appearing :(. this is frustrating. i tried removing the tilde sign and it made no difference :(. what am i missing?? @_@

Re: Can't reproduce error

PostPosted: 27. May 2015 15:48
by Nobbie
Maybe you are looking into the wrong php.ini?

I am sorry, I am going out of ideas.

P.S.: DId you restart Apache after changing php.ini?

Re: Can't reproduce error

PostPosted: 27. May 2015 15:50
by Roaziel
Nobbie wrote:Maybe you are looking into the wrong php.ini?

I am sorry, I am going out of ideas.

How many php.ini file are there? I click "Config" next to Apache in the control panel and select php.ini, isn't that the one I should be using?

Re: Can't reproduce error

PostPosted: 27. May 2015 15:51
by Altrea
Hi,

maybe your application overrides the php.ini settings for error_reporting or display_errors.

right in front of the line of code which makes problems add this two lines of code:
Code: Select all
error_reporting(-1);
ini_set('display_errors', 'On');


best wishes,
Altrea

Re: Can't reproduce error

PostPosted: 27. May 2015 16:02
by Nobbie
DId you restart Apache after changing php.ini?

Is there a .htaccess which changes configuration options?