I'm trying to bootstrap Drupal from an external script, and to pass a string containing page content to drupal_render_page(). The external script lives in a subfolder of my Drupal install dir.
All is going quite well, except that the page renderer is failing to output any CSS includes in the HTML head. After much hunting, I discovered that the cause was a file_exists() check in drupal_pre_render_styles() that's not prepending DRUPAL_ROOT to the file path.
Attached patch fixes this. After applying, CSS outputs normally, the $styles variable once again gets populated and outputted in html.tpl.php.
Comments
Comment #2
Jaza commentedhmmm... seems that stylesheet paths can also be passed in stream wrapper form (e.g. color modules passes them in 'public://' form). Prepending DRUPAL_ROOT to such paths doesn't work.
Updated patch attached - doesn't prepend DRUPAL_ROOT if the stylesheet path is in the form 'anystreampath://'. Otherwise unchanged.
Comment #3
marcingy commentedYou should use
You might also want to call file_stream_wrapper_valid_scheme.
Comment #4
marcingy commentedAlso should be fixed in d8 first.
Comment #5
Jaza commentedActually, this bug is not applicable to D8, as this
file_exists()check was removed in (see for explanation).So, this is just a D7 bug - and in my opinion, it is a bug fix and not a new feature or a compatibility-breaker. So, should be committed as a D7 maintenance fix.
Attached patch uses
file_uri_scheme()instead of a regex check (per @marcingy in #3), against latest D7.Comment #6
Jaza commentedSorry, lost some formatting in my last post. Meant to say:
Actually, this bug is not applicable to D8, as this file_exists() check was removed in http://drupalcode.org/project/drupal.git/commit/68395ee (see http://drupal.org/node/575298#comment-6774212 for explanation).
Comment #7
tim.plunkettThat makes this not major. Still a bug though.
Comment #8
Jaza commentedNew meta-issue for wider discussion of this issue: #1928072: Bootstrapping Drupal from outside the Drupal root directory