Using Drupal core with PHP 5.3, I have this recurrent error:
Unknown error: Function ereg() is deprecated in file_scan_directory() (line 926 of /var/www/pcf/www/includes/file.inc).
I know that D6 core does not supports PHP 5.3, but I made a patch that avoid this error to fill the watchdog over and over again by replacing the ereg() function using preg_match().
There are some differencies between ereg() and preg_*() regex, but not that much, most modules should not use that complex regular expressions. Plus, the preg_* functions are a lot faster than ereg() one, that's one of the reasons why it goes deprecated in PHP 5.3.
So, if you are like me, and if Drupal core fill your watchdog with this error, you can apply my patch safely, tested on a site which contains something like 30 contrib modules and 10 custom modules, and still have no weird behavior.
In case I experience something weird because of this, I'll tell in this issue.
For curious people, refer to:
http://php.net/manual/en/function.ereg.php
http://www.php.net/manual/en/reference.pcre.pattern.posix.php
| Comment | File | Size | Author |
|---|---|---|---|
| file-ereg-preg-5.3.patch | 714 bytes | pounard |
Comments
Comment #1
damien tournoud commentedDrupal 6 does support PHP 5.3. This looks like a duplicate of #360605: PHP 5.3 Compatibility.
Comment #2
pounardIf you had read what I said, you'd have seen that:
I put this patch here only in case individuals want to apply it at their own risk.
Comment #3
damien tournoud commentedI read what you wrote, and I can state it again: Drupal 6 *does* support PHP 5.3.
Comment #4
pounardYes you're right my error!
Comment #5
pounardClosing the issue.
Comment #6
vectoroc commentedwhy has'nt it still been fixed nor for 6.20, nor for 6.x-dev?
Comment #7
redndahead commentedI ran into this today also. With deprecated messages turned on you can see the messages on the modules page.
Since the other issue is closed I'm reopening this one. I tested this patch and it fixes the issue. I manually applied it though so I'm not sure if it needs a re-roll
Comment #8
redndahead commentedComment #9
heine commentedSee #360605: PHP 5.3 Compatibility, specifically #68
Comment #10
kingandyI realise the approved fix is to suppress the E_DEPRECATED messages rather than change the function from ereg() to preg_match(), but these messages are appearing for me in 6.20. This is long after the fixes in #360605: PHP 5.3 Compatibility were applied (#233, committed in #296). From where I'm standing, that issue should be re-opened.
Having checked my bootstrap.inc against that patch, the logic appears to have changed from
error_reporting(error_reporting() ^ E_DEPRECATED);toerror_reporting(error_reporting() & ~E_DEPRECATED);... any chance this is related?Failing that, some indication as to how to disable E_DEPRECATED / error reporting in general (as recommended in #288) would be useful.
Comment #11
kingandyScratch that - patch on #883038: PHP warning: Function ereg() is deprecated in includes/file.inc seems to be working (or at least working to resolve the issue).
Marking this issue as a duplicate of that...