Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi.
After changing and saving the Bartik colours, using the colour wheel, I receive the following warning:
Warning: chdir(): No such file or directory (errno 2) in drupal_load_stylesheet() (line 3318 of \includes\common.inc).
Comment | File | Size | Author |
---|---|---|---|
#59 | 927406-59-css-preprocessor-color.patch | 8.31 KB | carlos8f |
#58 | 927406-58-css-preprocessor-color.patch | 8.31 KB | carlos8f |
#56 | 927406-56-css-preprocessor-color.patch | 8.01 KB | carlos8f |
#44 | 927406-url-css-files.patch | 6.31 KB | Damien Tournoud |
#43 | 927406-url-css-files.patch | 5.18 KB | Damien Tournoud |
Comments
Comment #1
moosh101 CreditAttribution: moosh101 commentedComment #2
Jeff Burnz CreditAttribution: Jeff Burnz commentedOuch, yes, totally reproducible...
Comment #3
Jeff Burnz CreditAttribution: Jeff Burnz commentedSteps to reproduce this:
- Use any colorable theme and change the color scheme from default (Garland is good choice because this will really highlight the issue).
- Enable "Aggregate and compress CSS files into one file."
- Surf around the front end - instantly you will see the issue (warning + garland has no colorized images).
Looking at the aggregated CSS I can see the paths to Garlands images look a bit crazy:
One thinks this should be:
Bartik seems to work OK because there are no colorized images., actually no, its borked also, if you change themes while CSS aggregation is on Bartik looses all its color styles.#859616: drupal_load_stylesheet does not support streams removes the warning but not the problem.
Comment #4
Jeff Burnz CreditAttribution: Jeff Burnz commentedComment #5
bleen CreditAttribution: bleen commentedthis needs tests .. once we figure out the cause
Comment #6
jhedstromAdding stream wrapper tag, as the error itself is being caused by chdir() being called on a file uri (public://color/...) rather than a real path. However, changing the chdir command in
drupal_load_stylesheet()
to usedrupal_dirname()
anddrupal_realpath()
still doesn't resolve the missing images in garland.Comment #7
jhedstromAfter a little more digging, the file URIs are being passed into the stylesheet data array here as the $color_path variable, in
_color_html_alter()
:and then, in
drupal_build_css_cache()
, these URIs are passed to_drupal_build_css_path()
as the$base
variable, which is the reason those urls in the aggregated CSS are broken.Comment #8
jhedstromI think what's needed here is a method to pull the relative path of a stream uri. For example, given
the method would return
which would go into _color_html_alter() in place of the current $color_path variable.
There's currently a
getLocalPath()
method, but this returns the realpath, which won't work for _drupal_build_css_path().Comment #9
jhedstromAdding regression tag since CSS aggregation works with color module in previous releases.
Comment #10
EvanDonovan CreditAttribution: EvanDonovan commentedSubscribing!
Comment #11
Jeff Burnz CreditAttribution: Jeff Burnz commentedBumping to critical (cringe, sorry) to get some eyes on this (been a month with no movement), really needs to be fixed right away, maintainer can demote if deemed not an RC blocker.
Comment #12
radoeka CreditAttribution: radoeka commentedIs this bug report http://drupal.org/node/956228 (Backing up results in: Warning: is_dir(): Unable to find the wrapper "private") related?
Comment #13
mamarley CreditAttribution: mamarley commentedI worked around this issue by symlinking "www_root/sites/default/files/" to "www_root/public:". It really does need fixing, though.
Comment #14
ksenzeeI believe file_uri_target() is the API function jhedstrom is describing. Let me see if I can get a working patch put together.
Comment #15
effulgentsia CreditAttribution: effulgentsia commentedSubscribe.
Comment #17
steinmb CreditAttribution: steinmb commentedAh, seen this then testing the upgrade path but did not pay that much attention to it then I though It prob. was caused of me braking other stuff.
Comment #18
mo6Subscribe
Comment #20
mo6This change in color.module seems to fix the problem. I think it's a rather cludgy (fast) patch however, but it illustrates the problem. Could someone turn this into a real patch please?
Comment #21
amateescu CreditAttribution: amateescu commentedReal patch :)
Comment #22
effulgentsia CreditAttribution: effulgentsia commentedThanks for the patch, but as per #20, this isn't the proper fix.
Comment #23
jhedstromI think the API function ksenzee found in #14 will work. Using realpath won't work for aggregated CSS, which needs a relative path.
Comment #24
catchThis doesn't have anything to do with the cache subsystem, moving to color module.
Comment #25
mo6@jhedstrom file_uri_target() returns the part of an URI after the schema, which isn't the full local path needed. In lack of a proper API function my suggestion #20 uses realpath to create a relative path by creating an absolute path using drupal_realpath() then stripping the absolute bit by using realpath('.'). The solution works but introduces another problem which needs investigating. It really needs a proper API function and needs more testing and documentation.
Comment #26
mo6Rerolling patch
Comment #28
mo6Oops
Comment #30
ksenzeefile_uri_target() indeed does not work, which is why I haven't managed to get a patch posted. But if we're really missing an API function here, we should add it, not work around it. I believe simple API additions are still kosher. I have a couple of hours to spend on this today and will either post a patch or unassign myself.
Comment #31
Volx CreditAttribution: Volx commentedOne can actually build the path relative to the base path by getting the stream wrapper base directory with getDirectoryPath() which together with file_uri_target gives the required path. Of course this only works if we actually have a uri, I added a check with file_valid_uri before translating the path.
I also included a test, that triggers the bug without the patch.
Attached are two different patches, one introduces a new function in file.inc "file_uri_path", which returns the local path relative to the base path for a given uri. The other patch includes this inside of _color_html_alter.
Comment #32
ksenzeeComment #33
BarisW CreditAttribution: BarisW commentedI tested both patches of #31 and they are both working. I'm not sure which one is better - that's up to the cracks to decide. But the errors are gone and the images are showing with both patches. Great work!
Comment #34
mo6I prefer color-aggregate_css-927406-file_uri_path.patch, I see more uses for file_uri_path(). Patch tested and working.
Comment #35
montesq CreditAttribution: montesq commentedThe patch color-aggregate_css-927406-file_uri_path.patch fixes also correctly the issue on my side
Comment #36
effulgentsia CreditAttribution: effulgentsia commentedThanks for the test. Seems like we have a good fix as far as color.module is concerned, but I think the patches need more review from people who understand stream wrappers to make sure that API is being used as intended, especially, if we're adding a new API function for it. Therefore, moving to the "file system" component.
Comment #37
vegerta CreditAttribution: vegerta commentedComment #38
EvanDonovan CreditAttribution: EvanDonovan commentedI don't have any experience with stream wrappers, but I like the looks of the API function. Could probably be used in other places.
Comment #39
Damien Tournoud CreditAttribution: Damien Tournoud commentedThis is typically the type of API function that we don't want: it only works with local stream wrappers, and thus spread the confusion between what you can and what you cannot do with stream wrappers.
Instead of re-introducing such a mess (there was an API function like this in the past, that we purposely removed), we need to think about what's the intended behavior here.
It seems clear to me that what actually needs fixing is
drupal_build_css_cache()
that doesn't know how to properly handle CSS that references URI (or even URLs, for that matter).Comment #40
Damien Tournoud CreditAttribution: Damien Tournoud commentedI think something like this should be enough to fix the issue. I'm pretty sure our CSS aggregation tests do not cover the use of URLs, but it should be easy to add some.
Comment #41
Damien Tournoud CreditAttribution: Damien Tournoud commentedThank you, automated testing.
Comment #42
Damien Tournoud CreditAttribution: Damien Tournoud commentedI doubt this part is actually tested.
Comment #43
Damien Tournoud CreditAttribution: Damien Tournoud commentedYup. That is definitely not tested. This one actually work (but is still untested).
Comment #44
Damien Tournoud CreditAttribution: Damien Tournoud commentedFolding in the test from #31. Even if this particular bug has nothing to do with the color module in the first place, the test still makes sense.
Comment #46
carlos8f CreditAttribution: carlos8f commented#44: 927406-url-css-files.patch queued for re-testing.
Comment #48
Damien Tournoud CreditAttribution: Damien Tournoud commented#44: 927406-url-css-files.patch queued for re-testing.
Comment #49
carlos8f CreditAttribution: carlos8f commentedI am a little disturbed that my retest in #46 produced a CSS test fail while the latest retest did not. It feels like we are just rolling the dice to get a pass.
Comment #50
Damien Tournoud CreditAttribution: Damien Tournoud commentedThose fails were unrelated to the patch. It seems that Core was broken for a few hours last night.
Comment #51
carlos8f CreditAttribution: carlos8f commented#808560: Node comment statistics are only partially exposed in node_load() and are missing last_comment_uid was/is triggering random comment test fails, but I actually saw a CSS test fail when I re-tested in #46. That's why I was concerned, I don't want us to introduce another one of those pesky random fails here.
Comment #52
catchThe comment could use more detail. Invalid stylesheet sounds like one that fails css validation out of context, but we're protecting against a missing stylesheet, so just saying 'missing' or non-existent seems more straightforward here. Also why would we end up with a missing stylesheet in the first place, and want to suppress the error if there is one? I know this is just exchanged for a file_exists() but it's not clear how we'd run into this in the first place.
This probably needs a code comment to explain why it's not using drupal_static(). That'll stop someone trying to fix it later.
We're adding a lot of dancing to drupal_build_css_cache(), it's a shame there's no strrtok(). But that also removes this dance from drupal_load_stylesheet():
so that feels like a good trade-off.
Two instances of debug in the test which can be removed:
Comment #53
cosmicdreams CreditAttribution: cosmicdreams commentedcatch, carlos8f, Damien Tournoud: looks like the heavy lifting on this issue is done and the patch just needs to include catch's code comments.
I'll try to do that tonight if this isn't resolved by then, but I don't think I'll be able to properly write the comment about why you're using static and not drupal_static. Can one of you write that?
Comment #54
carlos8f CreditAttribution: carlos8f commentedWe need to update the docblock for drupal_load_stylesheet() to document $basepath. Also,
I'm agreeing with @catch, it's not clear what an "invalid stylesheet" is. If the file in question doesn't exist, it should be triggering a warning so developers can know what to fix. We already wrap processing in
if ($contents)
in this patch, so we should remove the@
and the corresponding comment about this (unless I'm just misinterpreting and this "@" is essential to the patch).@cosmicdreams, for the
static $current_basepath
comment, usually we say something like// Resetting is not necessary, so we don't use drupal_static() here.
Comment #55
carlos8f CreditAttribution: carlos8f commentedWorking on cleaning this up.
Comment #56
carlos8f CreditAttribution: carlos8f commented// These statics are not cache variables, so we don't use drupal_static().
I also logged the aggregated CSS generated from color.test to a text file, and saw that the resulting color/* image URLs are fixed with this patch. Looks good :)
Comment #58
carlos8f CreditAttribution: carlos8f commentedAh! Thanks again, automated testing.
The @ has a purpose. I document it as such:
Comment #59
carlos8f CreditAttribution: carlos8f commentedMisspelled "suppress" in the comment.
Comment #60
Stevel CreditAttribution: Stevel commentedThis patch solves the error when saving the colorable theme's settings (or clearing the cache), code looks good.
Comment #61
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD. Thanks.