[4.0] refactor the media adapters#34069
Hidden character warning
Conversation
…-media-adapters-4.0-dev
2592ca4 to
2f80acf
Compare
2f80acf to
d4f173c
Compare
|
@dgrammatiko The linter is still a bit unhappy: https://ci.joomla.org/joomla/joomla-cms/44184/1/21 : |
That was an easy fix but this PR is breaking B/C. (Anyways I was asked if I could help to transition from the index-based naming to this new name-based, so I guess this is already justified) |
Not index based so won’t break
administrator/components/com_media/src/Controller/ApiController.php
Outdated
Show resolved
Hide resolved
|
looks good, if it works ;) I not remember where exactly, in past I seen places where second part of the adapter is cast to integer, |
A quick search returned no casting |
Maybe I mixed something, thanks for checking |
plugins/filesystem/local/local.php
Outdated
| $directoryPath = JPATH_ROOT . '/' . $directoryEntity->directory; | ||
| $directoryPath = rtrim($directoryPath) . '/'; | ||
| $adapters[] = new \Joomla\Plugin\Filesystem\Local\Adapter\LocalAdapter($directoryPath, $directoryEntity->directory); | ||
| $adapters[$directoryEntity->directory] = new \Joomla\Plugin\Filesystem\Local\Adapter\LocalAdapter( |
There was a problem hiding this comment.
Almost there. To make it works well (hard to explain), we will have to change this block of code to:
foreach ($directories as $directoryEntity)
{
if ($directoryEntity->directory)
{
$directoryPath = JPATH_ROOT . '/' . $directoryEntity->directory;
$directoryPath = rtrim($directoryPath) . '/';
$adapter = new \Joomla\Plugin\Filesystem\Local\Adapter\LocalAdapter(
$directoryPath, $directoryEntity->directory
);
$adapters[$adapter->getAdapterName()] = $adapter;
}
}Now, the name of the adapters have this format: local-images, local-sampledata
images, sampledata is returned by $adapter->getAdapterName() method, so later, to allow the system to find the right adapter from path in the request, we will have to use $adapter->getAdapterName() as key name of the item.
There was a problem hiding this comment.
I hope this is understandable. Hard to explain but it is still not clear, I will try to find a better way to explain. I only see this problem while checking to see why dropbox adapter does not work after this change.
| * | ||
| * @return {Array} | ||
| */ | ||
| const getDrives = (adapterNames, adapterName) => { |
There was a problem hiding this comment.
The parameters name of function here is a bit confusing. How about changing it to const getDrives = (adapterNames, provider). In the server side, we call local, dropbox as providers, so I think we should make the same change here to make it consistent.
There was a problem hiding this comment.
Ok, done, arguments renamed
|
Thanks @dgrammatiko. All good. I will now run a final test. |
|
Sorry. Could you please do a final change https://github.com/joomla/joomla-cms/blob/4.0-dev/layouts/joomla/form/field/media.php#L107 ? Change Later it will be changed anyway. But this is to avoid when your PR merged, people use nightly build won't get error while trying to select an image for article. |
|
I have tested this item ✅ successfully on 04fa696 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/34069. |
|
RTC This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/34069. |
|
Thanks! |
This comment was marked as abuse.
This comment was marked as abuse.
This comment was marked as abuse.
This comment was marked as abuse.
|
There's a sessionStorage entry, so unless you do some update without killing the session then this shouldn't be a problem |
This comment was marked as abuse.
This comment was marked as abuse.
This comment was marked as abuse.
This comment was marked as abuse.
This comment was marked as abuse.
This comment was marked as abuse.
This comment was marked as abuse.
This comment was marked as abuse.
|
Yeah, but I think it's highly unlikely to hit all these requirements at once... |
This comment was marked as abuse.
This comment was marked as abuse.
|
Highly unlikely as in two people already did |
|
Is there anything we can do against it? |
We could empty the sessionStorage key before the update, but it won't cover all the updade paths |
|
But we can ask people to log out after the update and re-login (in case they used com_media right before the update). No code needed |


Pull Request for Issue #26750 (comment).
Summary of Changes
This is a proposal to change the adapters from ie:
local-0to ie:local-imagesas sated #26750 (comment).Probably if this is ok (I think the second part would be better if it's
md5($name)) would be merged to #33724 for easier testing?@joomdonation @Fedik @bembelimen your thoughts here?
Testing Instructions
Goto:
administrator/index.php?option=com_plugins&view=plugins&filters=[type=filesystem]Edit
FileSystem - Localplugin by adding a new path, eginstallationCheck the media manager
Re-edit the previous plugin by changing the order of the folders (first installation, second images)
Check again the media manager still operates fine
Also, edit any article (or create a new one):
Actual result BEFORE applying this Pull Request
Expected result AFTER applying this Pull Request
There shouldn't be any difference for end-users. This PR just ensures that the adapters are not index related.
Documentation Changes Required