Really old code and reference errors (not notices)

Hi all,

I have some old (really old) code that was transferred to a different host. The old code was using an framework I wrote in PHP4 that unfortunately used a lot of references (terrible, I know). Anyway, of course I am getting a ton of the return by reference and pass by reference errors, that are choking the server logs.

The code really should be fixed, but that will take a great deal of time and effort. So for now I wanted to disable the errors in the logs, but, that’s just the thing - they are errors in the logs, and not notices. I was under the impression that these were supposed to be notices, not errors? So in other words, the php.ini currently has:

error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED

…but the errors are still being logged by the hundreds, e.g. they appear like this in the error log:

PHP Error: Only variable references should be returned by reference in xxx
PHP Error: Only variables should be passed by reference in xxx

Shouldn’t they be notices? :shifty:

If it helps, the server is running PHP Version 5.3.3 on Apache/2.2.16, Debian. What’s the best method of hiding these?

Cheers,

{R}

To fix the code and until then, use grep to strip them out?

Yes ideally the plan is to fix the code, but it will take some time. Grep them out, seriously? :goof: I’m just keen to know why PHP is logging them as errors and not notices in the first place. If I can turn them off at the source, that’s a better albeit temporary course of action, don’t you think?

With the more recent version of PHP 5.3, that error that you’re getting is now a deprecated behaviour, whereas in the earlier version of PHP it was still acceptable but frowned upon.

That is why it’s changed from a notice to an actual error.

Yes, it’s a “deprecated error” or E_DEPRECATED, to be precise. But Paul, that still doesn’t explain why:

error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED

…is not removing these errors from the logs now is it? If they are E_DEPRECATED errors, then they shouldn’t be logging at all.

It looks like you have Kalle Sommer Nielsen to blame for that.
Request for Comments: Removal of deprecated features

He’s providing code-base patches to remove many deprecated features, as a part of a build-up towards the next version of PHP.

Ah ok, so they’re not going away because they don’t want them to. Guess that means code-fixing time, hooray! :sick: