I have an external PHP script that bootstraps Drupal, and that lives in a subfolder of my Drupal install dir.
After bootstrapping, this script runs some functionality that depends on file_scan_directory()
(lives in includes/file.inc
). I discovered that this function doesn't currently work if called from a script that lives outside of the Drupal root, as there are several places where it should be (but is not) prepending DRUPAL_ROOT
to the file path.
This is a similar bug to #1891802: Need DRUPAL_ROOT when rendering CSS include links
Attached patch fixes this, by doing the following:
- Appends DRUPAL_ROOT
to the directory path before calling is_dir()
and opendir()
(unless it's a stream wrapper URL, or is already an absolute file path)
- Appends DRUPAL_ROOT
to the file URI (unless it's a stream wrapper URL, or is already an absolute file path)
- Removes DRUPAL_ROOT
from the $file->uri
values that get returned by this function, in order to keep this function's return value the same as it is currently (i.e. with values relative to Drupal root).
Attachment | Size | Status | Test result | Operations |
---|---|---|---|---|
file_scan_directory_drupalroot.patch | 1.78 KB | Idle | PASSED: [[SimpleTest]]: [MySQL] 39,834 pass(es). | View details | Re-test |