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

CommentFileSizeAuthor
file-ereg-preg-5.3.patch714 bytespounard

Comments

damien tournoud’s picture

Status: Active » Closed (duplicate)

Drupal 6 does support PHP 5.3. This looks like a duplicate of #360605: PHP 5.3 Compatibility.

pounard’s picture

If you had read what I said, you'd have seen that:

I know that D6 core does not supports PHP 5.3

I put this patch here only in case individuals want to apply it at their own risk.

damien tournoud’s picture

I read what you wrote, and I can state it again: Drupal 6 *does* support PHP 5.3.

pounard’s picture

Yes you're right my error!

pounard’s picture

Status: Closed (duplicate) » Closed (fixed)

Closing the issue.

vectoroc’s picture

why has'nt it still been fixed nor for 6.20, nor for 6.x-dev?

redndahead’s picture

Version: 6.17 » 6.x-dev
Status: Closed (fixed) » Needs review

I 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

redndahead’s picture

Title: Remove deprecated ereg() warnings in file.inc line 926 » Remove deprecated ereg() warnings in file.inc
heine’s picture

Status: Needs review » Closed (won't fix)

See #360605: PHP 5.3 Compatibility, specifically #68

kingandy’s picture

I 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); to error_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.

kingandy’s picture

Status: Closed (won't fix) » Closed (duplicate)
Issue tags: +ereg deprecation

Scratch 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...