Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.0] Return sensible default from 'FileSystem - Local' plugin. #34364

Closed
wants to merge 7 commits into from
Closed

[4.0] Return sensible default from 'FileSystem - Local' plugin. #34364

wants to merge 7 commits into from

Conversation

pjdevries
Copy link
Contributor

@pjdevries pjdevries commented Jun 2, 2021

Pull Request for Issue #34358 .

Summary of Changes

Changed the way directory settings are obtained in the FileSystem - Local plugin. If mo directory has been explicitly chosen yet, return Media Manager's 'Path to 'Path to Files Folder' setting.

Testing Instructions

Make sure you have a fresh Joomla! 4.0 installation, or at least one with an unaltered FileSystem - Local plugin configuration.

Change both path's of the Media Manager configuration, i.e. 'Path to Files Folder' and 'Path to Images Folder'.

Open Media Manager.

Beware of caching when fiddling with the Media Manager and its path settings! (see also #34239)

Actual result BEFORE applying this Pull Request

The result depends on proper configuration of the FileSystem - Local plugin. If no directory is chosen, which is the default, the plugin returns [{"directory": "images"}] and the Media Manager shows nothing.

Expected result AFTER applying this Pull Request

A list of files in folder 'Path to Files Folder', if there are any, or an empty folder otherwise.

Documentation Changes Required

It's probably a good thing to document this somewhere, preventing (new) users to get confused.

…dir_fix' into filesystem_local_plugin_default_dir_fix

# Conflicts:
#	plugins/filesystem/local/local.php
@Fedik
Copy link
Member

Fedik commented Jun 2, 2021

If mo directory has been explicitly chosen yet, return Media Manager's 'Path to 'Path to Files Folder' setting.

I am doubt here, the plugin should use own options. There may be another filesystem plugins.

If no directory is chosen, which is the default, the plugin returns [{"directory": "images"}] and the Media Manager shows nothing.

I not checked how it connected, but probably the folder should come from filesystem plugins only.

The path option in the new Media Manager configuration seems does not make sense anymore.

@pjdevries
Copy link
Contributor Author

If mo directory has been explicitly chosen yet, return Media Manager's 'Path to 'Path to Files Folder' setting.

I am doubt here, the plugin should use own options. There may be another filesystem plugins.

If I understand it correctly:

  • The Local plugin supports local files.
  • The Media Manager also supports local files.

So I think it makes sense to use Media Manager's path setting as a default for the Local plugin,

If no directory is chosen, which is the default, the plugin returns [{"directory": "images"}] and the Media Manager shows nothing.

I not checked how it connected, but probably the folder should come from filesystem plugins only.

I did check. After changing paths in the Media Manager, it did not work anymore until I selected the proper directory in the Local plugin.

The path option in the new Media Manager configuration seems does not make sense anymore.

That may well be, but it is there and can be used. As long as that's the case, I think it must behave in a predictable manner.

@Fedik
Copy link
Member

Fedik commented Jun 2, 2021

If I understand it correctly:
The Local plugin supports local files.
The Media Manager also supports local files.

The thing that Media Manager supports depend from enabled FileSystem plugins.
On its own it does not support anything.

@richard67
Copy link
Member

I agree with @Fedik . You can install a filesystem plugin e.g. for using Dropbox, and then you can set paths to files and images folders in the media manager options. With the change which is suggested here, the local filesystem plug-in would use the path to a folder on Dropbox as directory, and that would be wrong.

@pjdevries
Copy link
Contributor Author

@Fedik @richard67 I'm not sure I understand. Is it possible to have multiple active filesystem plugins? If so, how does the Media Manager distinguish between them, i.e. know which one to use?

@richard67
Copy link
Member

@pjdevries Yes, the media manager can use multiple different filesystems. Each one is a base folder in the media manager. See the testing instructions in this PR: #33724 . In media manager you see 2 parent folders where you can navigate to children, the local "Images" and the "Dropbox" folder when doing as described in that PR.

@richard67
Copy link
Member

P.S.: Same when e.g. inserting an image into an article: You can use images from the local filesystem as well as from Dropbox when using that dropbox plugin (which is not ready yet and was developed just for testing, but I'm sure sooner or later you will find more such plugins in the extensions directoy).

*
* @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @license GNU General Public License version 2 or later; see
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please revert this change

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please revert this change

Not so hasty. The issue still exists. If this isn't the right solution, let's think of a better one.

But first some thoughts.

Thanks to @richard67 explanation, I now have a better understanding. I also better understand whu @Fedik says the path option in the new Media Manager configuration is obsolete. I not only tend to agree, but it makes things confusing. Maybe remove them, in which case the original 'images' as the default return value from the Local filesystem plugin makes much more sense.

On the other hand, as long as those paths in the Media Manager configration are there, why not use them the way I proposed. Is it that much different than the original code, returning 'images' as a default? After all, it's just a default. On a fresh Joomla! 4 installation, only the Local filesystem plugin is enabled by default but not yet explicitly configured. Only under those circumstances will the default be returned and returning the Media Manager path seems just as good (or bad) as 'images' :)

But I'm happy to change the default to something more sensible. Any suggestions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not so hasty. The issue still exists. If this isn't the right solution, let's think of a better one.

Apologies to @brianteeman for not looking more closely what he was referring to.

@Fedik
Copy link
Member

Fedik commented Jun 3, 2021

I think we need to consider removing file_path and image_path from Media config.
I do not see a reason why we need them, but I may be wrong.

@pjdevries
Copy link
Contributor Author

I think we need to consider removing file_path and image_path from Media config.
I do not see a reason why we need them, but I may be wrong.

From what I understand from @richard67's explanation, I think you are right. If Media Manager no longer uses those paths but only the adapter settings, the issue that resulted in this PR vanishes automatically. A default return value of 'images' from the Local filesystem plugin, also makes sense then, making this PR unnecessary and @brianteeman a happy dude :)

@pjdevries
Copy link
Contributor Author

@richard67

See the testing instructions in this PR: #33724

Seemed like a good idea to play a bit with multiple adapters, but I get this known error: 'Call to undefined method GuzzleHttp\Utils::chooseHandler()'.

@richard67
Copy link
Member

Seemed like a good idea to play a bit with multiple adapters, but I get this known error: 'Call to undefined method GuzzleHttp\Utils::chooseHandler()'.

@pjdevries That's an issue with that plugin which was a quick made thing just for testing. You can find the solution here: #33724 (comment)

@pjdevries
Copy link
Contributor Author

That's an issue with that plugin which was a quick made thing just for testing. You can find the solution here: #33724 (comment)

Yes, works! Cool!

@chmst chmst changed the base branch from 4.0-dev to 4.1-dev January 31, 2022 15:45
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants