Quantcast
Viewing all articles
Browse latest Browse all 296290

Fix ereg in core

ereg functions where not replaced in core D6 though they were deprecated, and now removed.
The reason was that this would break theAPI file_scan_directory() called from other modules.

Thhe proposed fix is here
https://www.drupal.org/node/360605#comment-1399150

In file.inc, function they propose this:

function file_scan_directory($dir, $mask, $nomask = array('.', '..', 'CVS'), $callback = 0, $recurse = TRUE, $key = 'filename', $min_depth = 0, $depth = 0) {
...
- elseif ($depth >= $min_depth && ereg($mask, $file)) {
+ elseif ($depth >= $min_depth && preg_match($mask, $file)) {

which actually break all calls to this function, having to add "/" delimiters. Example:
function drupal_clear_js_cache() {
- file_scan_directory(file_create_path('js'), '.*', array('.', '..', 'CVS'), 'file_delete', TRUE);
+ file_scan_directory(file_create_path('js'), '/.*/', array('.', '..', 'CVS'), 'file_delete', TRUE);
variable_set('javascript_parsed', array());
}

I just change that to

elseif ($depth >= $min_depth && preg_match('#' . $mask . '#' , $file)) {

Which is all compatible.
(note the "#" instead of "/" which causes a log error "Warning: preg_match(): Compilation failed: a numbered reference must not be zero at offset 1 in file_scan_directory()" when the string includes a "/")


Viewing all articles
Browse latest Browse all 296290


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>