Problem/Motivation

When using a Drupal Installation Profile or a distribution that provides the ImagesLoaded or Masonry libraries, this module is currently unable to find them because it isn't looking for them there. Additionally, the module's requirement check is made right before the files directory is created, so that requirements check fails when installing the module from a profile as well.

Proposed resolution

If the module is being installed as part of a Profile installation, we should check the profile's libraries directory manually, as the libraries module is not yet configured. We should also skip the file directory check, as that won't yet be set up.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mikeegoulding created an issue. See original summary.

mikeegoulding’s picture

StatusFileSize
new2.42 KB
samuel.mortenson’s picture

@mikeegoulding Are you using the Libraries module? That should auto-detect libraries in any /libraries folder, and I think it supports profiles.

mikeegoulding’s picture

@samuel.mortenson This is for an installation profile I'm working on that does include the libraries module. It doesn't seem to be picking up either of the required libraries without moving them or making code changes like in this patch.

mikeegoulding’s picture

Looks like the reason this isn't working on install is that the moduleExists function returns false during install because the libraries module is not yet installed at the time it is checking requirements. None of the modules are. It seems that many modules get around this by only making these checks during runtime and not during the install phase. I'm open to that change if you are.

Something like:

  if ($phase != 'runtime') {
    return [];
  }
samuel.mortenson’s picture

Looks like this might be a very old Libraries issue: #2575167: Library not loaded during installation of installation profile.

It'd be great if we could detect that the phase was the profile (Drupal) installing, not just file_browser. With your suggested change I think that the requirements check would never be made when installing file_browser, so to know the library is missing users would have to install it then visit the admin report page. Thanks for digging in so far.

mikeegoulding’s picture

Correct. It seems like a few other modules opt to skip the warning about the required libraries on install to avoid this problem while others do a direct check of the profiles directory when the library module is not found like I'm doing in #2. I think if we want to have the requirements check preserved on install we have to check the profile directory when the libraries module is not found.

mikeegoulding’s picture

StatusFileSize
new3.04 KB

Adding a patch that checks the InstallerKernel to see if we are in the install environment and only checking requirements if we are not there. Not sure this is perfect, but maybe a direction to explore?

mikeegoulding’s picture

StatusFileSize
new3.15 KB

Actually, after talking to @mike.lutz for a bit about it I think we can just check for

if (!\Drupal::service('kernel') instanceof InstallerKernel)

before checking the libraries. Still would confirm that the public directory is writable regardless as that is a requirement we can't skip during install I think.

mikelutz’s picture

Title: Required libraries not found when supplied by a Profile » Module is not installable as part of a profile installation
Issue summary: View changes
Status: Active » Needs work
StatusFileSize
new2.88 KB

Here's a test file showing the issue.

mikelutz’s picture

StatusFileSize
new2.91 KB
new521 bytes

oops. :-)

mikelutz’s picture

Status: Needs work » Needs review
StatusFileSize
new5.67 KB
new2.76 KB

And here's a slight tweak on the original fix, which should pass that test.

mikelutz’s picture

Status: Needs review » Needs work

Oops, forgot to hide the test profile.

samuel.mortenson’s picture

+++ b/file_browser.install
@@ -78,7 +87,7 @@ https://github.com/desandro/masonry/releases and place it in /libraries'
+  if (!\Drupal::isConfigSyncing() && (!\Drupal::service('kernel') instanceof InstallerKernel) && !is_writable($public_path)) {

I'm not sure how this check relates to the issue summary - shouldn't we check that the files directory is writeable even if it's a profile install?

mikelutz’s picture

Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new5.68 KB
new615 bytes

We should also skip the file directory check, as that won't yet be set up.

was in the proposed resolution, but I'll move it up in the IS.

@samuel.mortenson See https://git.drupalcode.org/project/drupal/blob/8.8.x/core/includes/install.core.inc#L2057. Unfortunately the installer creates the files directory immediately after checking the profile requirements (which includes checking the requirements of the modules the profile is trying to install). Which I found out from my test because I wasn't even looking for that problem. So we skip the files directory test if we are in the middle of a Drupal install.

samuel.mortenson’s picture

Yikes, thanks for the info @mikelutz. In general I don't think this is something File Browser is responsible for, but since there's no clear path forward in another issue I'll likely move forward with this patch. Just need some time to think (and am not working on the module today).

mikeegoulding’s picture

In the meantime, #2 will serve my case fine. Thanks for looking into this gents.

berdir’s picture

My recommendation would be to simply make this a runtime-only requirement, that's how blazy.module and select2.module do it for example. At least until these issues are resolved.

dropzonejs.module is a counter-example that does check the install profile similar to the patch here I guess.

jacob.herrera’s picture

Just adding in a note here that #2 works with a basic install profile but throws an issue with a distribution - looks like as a profile isn't selected when installing a distribution the call to \Drupal::installProfile() is returning null. Will update if I have a chance to debug this, am proceeding with a basic install profile for now.

Farrout’s picture

I want to disable file browser when non admin user is looking at their profile. Can that be done?

ccjjmartin’s picture

StatusFileSize
new2.66 KB

Rerolled #15 to work with the latest dev branch.

Status: Needs review » Needs work

The last submitted patch, 21: 3089470.21.patch, failed testing. View results

d.fisher’s picture

Version: 8.x-1.x-dev » 2.x-dev
Status: Needs work » Postponed (maintainer needs more info)

No activity here for 5 years. I've just become a maintainer and I'm looking to clean up the issue queue. Can anyone confirm if this issue persists against 2.x as there have been many changes to the module. Thank you!

mikelutz’s picture

Let's find out. :-)

d.fisher’s picture

Status: Postponed (maintainer needs more info) » Active

Setting this to active as it is currently being worked on and no longer postponed.

d.fisher’s picture

Status: Active » Needs work
d.fisher’s picture

I believe this may have been fixed by the latest tagged release and on the dev branch. Can anyone confirm? If not the latest changes to the module's dev branch have caused conflicts with this issues merge request which will need to be resolved. Please look closely at the incoming change as this was a fix for another issue which I believe may have inadvertently contributed towards this one?

d.fisher’s picture

Status: Needs work » Postponed (maintainer needs more info)
d.fisher’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.