Problem/Motivation

Line 332 in color.module does
$paths['color'] = 'public://color';

However, Drupal allows me to only enter a private file path in my file system settings, and leaving the public files directory empty. Drupal works fine, until I try to change the colors of my theme. Then Drupal generates some bugs as

The file permissions could not be set on public://color.

and

File temporary://fileCUgZxH could not be copied, because the destination directory is not configured correctly.

Is it possible to use the private file system, if the user prefers that? Of if not, just check if the public file directory is set?

This issue was committed to 8.x and reverted.

Steps to reproduce

TBA

Proposed resolution

TBD

Remaining tasks

TBS

User interface changes

API changes

Data model changes

Release notes snippet

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Jeff Burnz’s picture

Subscribe.

BarisW’s picture

On a side note, I discovered this while fixing a bug in my Google Fonts module (#1103884: system/files/google_fonts/google_fonts.css page not found). It seems that /system/files/name_of_my_css_file.css resolves in a 404, so maybe that's why the color module hardcoded public:// in it?

tim.plunkett’s picture

Version: 7.x-dev » 8.x-dev
Status: Active » Needs review
Issue tags: +Needs backport to D7
FileSize
622 bytes

Is this all that is needed? Using file_default_scheme() instead?

valthebald’s picture

Status: Needs review » Needs work

Patch from #3 failed for me in both 8.x and 7.x installations. Steps to reproduce:

  1. Install standard installation profile
  2. Apply patch - patch -p1 < ~/tmp/drupal-1106160-3.patch
  3. In admin menu, choose 'Configuration' > 'Media' > 'File system'
  4. Clear value from the Public file system path field
  5. Put 'sites/default/files' in the Private file system path field
  6. Press Save
  7. Choose Private local files served by Drupal as default download method
  8. Press Save
  9. In admin menu, choose 'Appearance' > 'Bartik' > 'Settings'
  10. Choose any color set except default and press save
  11. Several warnings appear:
    Warning: file_put_contents(public:///.htaccess): failed to open stream: "DrupalPublicStreamWrapper::stream_open" call failed in file_save_htaccess() (line 505 of /home/valeryl/work/d8/includes/file.inc).
        Warning: file_put_contents(public:///.htaccess): failed to open stream: "DrupalPublicStreamWrapper::stream_open" call failed in file_save_htaccess() (line 505 of /home/valeryl/work/d8  /includes/file.inc).
  12. Go to the front page - CSS is broken
  13. Steps 2-12 repeated for both d8.loc and d7.loc, with the same result
markhalliwell’s picture

Issue tags: +Issue needs confirmation, +Needs manual testing, +Needs reroll

Once a new patch has been re-rolled, we should probably test against simplytest.me (which should help clarify if this is a server/local file permissions issue or an actual bug in the code).

BarisW’s picture

Status: Needs work » Needs review
FileSize
642 bytes

Here's a re-roll.

-enzo-’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
138.22 KB

I tested the patch #1106160-6: Color module uses the public file system but doesn't check if it is set successfully as you can see in the following image.

color-with-default-public-stream.png

To test this change you must change the settings for any theme like Bartik in URL http://example.com/admin/appearance/settings/bartik and any change create a new folder in public stream folder color.

If you want to review the public stream, you need to go to URL http://example.com/admin/config/media/file-system, as you can read in instructions if you want to change the public stream you must to change in setting.php as you can see in the following code.

/**
 * Public file path:
 *
 * A local file system path where public files will be stored. This directory
 * must exist and be writable by Drupal. This directory must be relative to
 * the Drupal installation directory and be accessible over the web.
 */
# $settings['file_public_path'] = 'sites/default/files';
markhalliwell’s picture

Issue tags: -Issue needs confirmation, -Needs manual testing, -Needs reroll

Looks good to me, RTBC.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed cef318b and pushed to 8.x. Thanks!

alexpott’s picture

Version: 8.x-dev » 7.x-dev
Status: Fixed » Patch (to be ported)

And now for D7

dcam’s picture

Issue summary: View changes
Status: Patch (to be ported) » Needs review
FileSize
622 bytes

Backported #6 to D7.

markhalliwell’s picture

Status: Needs review » Reviewed & tested by the community

Comparing #6 and #11 side by side the only thing that has changed is the path of the color.module file. Looks good to me.

David_Rothstein’s picture

Title: Color module uses the public file system but doesn't check if it is set » [Regression: Color module broken on sites that use private files by default] Color module uses the public file system but doesn't check if it is set
Version: 7.x-dev » 8.x-dev
Priority: Normal » Critical
Status: Reviewed & tested by the community » Needs work

I tested this and it completely broke the Color module on a site that uses private files as the default download method. The theme doesn't work at all, since the files generated by the Color module are not displayed.

The reason is that Drupal doesn't know about these files so when they are put in the private files directory, it falls back on the default behavior of file_download() which is not to serve them to the browser.

I do not have a working Drupal 8 setup right now, but given @valthebald's test results in #4 (which report basically the exact same thing) as well as reading the code in FileDownloadController::download() I'm pretty convinced the same thing happens there (or if not, then there's likely a critical security issue in Drupal 8 regarding this, because it's what should happen for a random file in the private files directory that Drupal doesn't recognize).

I think this should be rolled back... and perhaps the correct fix is to stop Drupal from allowing you to try running a site without a public files directory in the first place? (Then you wouldn't ever be able to get in this situation.)

Jeff Burnz’s picture

I think this should be rolled back... and perhaps the correct fix is to stop Drupal from allowing you to try running a site without a public files directory in the first place? (Then you wouldn't ever be able to get in this situation.)

If this is considered viable I would be in favour of this approach. Right now I have to check if the public files directory exists and is configured etc because my themes and module frequently make use of it, because they're serving those files to the browser, so in general I personally would be in favour of requiring a public files directory for these unmanaged files that are served to the browser.

catch’s picture

Priority: Critical » Normal

Reverted for now.

  • Commit 46e2561 on 8.x by catch:
    Revert "Issue #1106160 by tim.plunkett, BarisW: Fixed Color module uses...
catch’s picture

Title: [Regression: Color module broken on sites that use private files by default] Color module uses the public file system but doesn't check if it is set » Color module uses the public file system but doesn't check if it is set

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

  • alexpott committed cef318b on 8.3.x
    Issue #1106160 by tim.plunkett, BarisW: Fixed Color module uses the...
  • catch committed 46e2561 on 8.3.x
    Revert "Issue #1106160 by tim.plunkett, BarisW: Fixed Color module uses...

  • alexpott committed cef318b on 8.3.x
    Issue #1106160 by tim.plunkett, BarisW: Fixed Color module uses the...
  • catch committed 46e2561 on 8.3.x
    Revert "Issue #1106160 by tim.plunkett, BarisW: Fixed Color module uses...

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

  • alexpott committed cef318b on 8.4.x
    Issue #1106160 by tim.plunkett, BarisW: Fixed Color module uses the...
  • catch committed 46e2561 on 8.4.x
    Revert "Issue #1106160 by tim.plunkett, BarisW: Fixed Color module uses...

  • alexpott committed cef318b on 8.4.x
    Issue #1106160 by tim.plunkett, BarisW: Fixed Color module uses the...
  • catch committed 46e2561 on 8.4.x
    Revert "Issue #1106160 by tim.plunkett, BarisW: Fixed Color module uses...

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

bradjones1’s picture

quietone’s picture

Version: 8.9.x-dev » 9.3.x-dev
Issue summary: View changes
Issue tags: +Bug Smash Initiative, +Needs steps to reproduce

It is no longer possible to follow the steps to reproduce that are in #4. I did play around though on drupal 9.3.x, standard install. I set the download method to private and the set public directory to '' and the private one to sites/default/files and then got "The website encountered an unexpected error. Please try again later." when going to admin/appearance/settings/bartik.

I wonder if this should be a child of #2724963: Make the public file system an optional configuration?

bradjones1’s picture

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Project: Drupal core » Color backport
Version: 9.5.x-dev » 2.x-dev
Component: color.module » Code

Color has been removed from core, #3270899: Remove Color module from core.