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

Inconsistencies with files #491

Open
GuySartorelli opened this issue Nov 14, 2022 · 0 comments
Open

Inconsistencies with files #491

GuySartorelli opened this issue Nov 14, 2022 · 0 comments

Comments

@GuySartorelli
Copy link
Member

GuySartorelli commented Nov 14, 2022

  1. When uploading a new file, the logic in FileSubsites::onAfterUpload() doesn't do what it seems to say it does
    • The if ($this->owner->Parent()) check will always return true, because even if the file has no actual parent (i.e. no ParentID), the ORM will give us an empty File object, which passes this vague condition.
    • This check should say if ($this->owner->Parent()->exists()) (or ->Parent()->isInDB() or simply ->ParentID)
    • However, the current behaviour (although clearly not what was originally intended) is actually good! The file only gets the subsite ID if it is uploaded to a parent folder which also has a subsite ID. It doesn't just get the ID of whatever subsite you happen to be on. This means files, by default, are available to all subsites. I think this is good default behaviour
    • Basically, this condition just needs to be refactored so that it says it does what it already actually does, lest someone notice this inconsistency and break the current behaviour by "fixing" it.
  2. When changing the subsite for a folder, files in the folder are not updated (#333)
    • This is already its own separate issue, but it's part of this overarching theme of file inconsistencies so I'm noting it here.
    • This can lead to files being inaccessible in the CMS - if I am viewing a Folder assigned to subsite B, I can't swap to another subsite without backing out of this folder. If files in this folder are still assigned to subsite A, I won't be able to view them because I can't swap to that subsite.
  3. If I upload a file in the root (so it doesn't have a SubsiteID) and then move it into a folder which does have a subsite assigned, the file will not inherit the SubsiteID of its new parent folder. This is inconsistent with files which are uploaded directly into this folder, which will inherit the SubsiteID.
    • There is no way to change the SubsiteID of a file from the CMS UI, so the only way to resolve this is to run some bespoke task to update SubsiteIDs to match their parent folders.
    • This is related to the issue above, though it is technically a separate issue.

Proposed solution

  • Files should always inherit their SubsiteID from the parent folder.
  • The onBeforeWrite() method in the FileSubsites extension should set the SubsiteID of a file to match its parent folder
    • This excludes folders in the root
    • This does not exclude folders which are children of other folders
      • Folders which are children of other folders should not have a dropdown to select their subsite, unless the parent folder is set to the "main site" (i.e. no subsite)
    • The root is considered to be a folder with SubsiteID of 0
    • If moving a folder outside another folder into the root, it should retain its current SubsiteID
    • If moving any other file outside a folder into the root, its SubsiteID should be 0
  • If the SubsiteID of a folder is changed, it will need to propogate this change down to its children

This would ensure that files always have a subsite ID which matches the parent folder, leading to a much more consistent and predictable experience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant