Skip to content

Conversation

@lukasbestle
Copy link
Member

@lukasbestle lukasbestle commented May 10, 2025

Description

Summary of changes

  • New custom $filename param for $file->mediaRoot() and $file->mediaUrl()
  • New $file->mediaDir() method (= directory where media of that file model is stored)
  • Rename mediaRoot() to mediaDir() for other model classes

Reasoning

Changelog

Enhancements

  • New $file->mediaDir() method that returns the directories where media of that file model is stored. Matching method aliases for the Page, Site and User classes are provided.
  • The $file->mediaRoot() and $file->mediaUrl() methods now accept a new optional $filename argument so they can be used to construct roots and URLs to thumbs.

Breaking changes

None

Docs

None

Ready?

  • In-code documentation (wherever needed)
  • Unit tests for fixed bug/feature
  • Tests and CI checks all pass

For review team

  • Add changes & docs to release notes draft in Notion

@lukasbestle lukasbestle added this to the 5.0.0-rc.1 milestone May 10, 2025
@lukasbestle lukasbestle requested a review from a team May 10, 2025 17:13
@lukasbestle lukasbestle self-assigned this May 10, 2025
@lukasbestle lukasbestle force-pushed the v5/feature/media-firewall-2 branch from 8ca8ef4 to 0791516 Compare May 10, 2025 17:23
@lukasbestle lukasbestle requested a review from distantnative May 10, 2025 17:25
distantnative
distantnative previously approved these changes May 10, 2025
Copy link
Member

@distantnative distantnative left a comment

Choose a reason for hiding this comment

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

To me the breaking change is worth it as the naming scheme would make a lot of sense this way.

Would be good if @bastianallgeier also has a look at this.

@bastianallgeier bastianallgeier dismissed distantnative’s stale review May 12, 2025 10:54

New solution discussed on Discord

@bastianallgeier bastianallgeier force-pushed the v5/feature/media-firewall-2 branch from 0791516 to 5221bfc Compare May 13, 2025 13:02
@bastianallgeier
Copy link
Member

bastianallgeier commented May 13, 2025

Changes

  • I've created a new ::mediaDir method for all models.
  • ::mediaRoot is now an alias for ::mediaDir in the Page, Site and User classes
  • ::mediaRoot has a new optional $filename param in the File class
  • ::mediaPath has been removed again in favor of the existing ::mediaRoot
  • All unit tests have been adapted.

@lukasbestle please check if you are happy with those changes.

@lukasbestle
Copy link
Member Author

lukasbestle commented May 13, 2025

Thank you for adapting it, looks good to me. Unfortunately I cannot approve my own PR :)

One thing I thought about is whether we want to deprecate $page/site/user->mediaRoot() with a deprecation warning. Just to clean it all up and avoid accumulating aliases that aren't really needed. Especially with our plan to introduce media subclasses (which mean we need to deprecate all those media methods in the model classes anyway).

@lukasbestle lukasbestle changed the title Media firewall 2: Differentiate between mediaRoot/mediaPath Media firewall 2: Differentiate between mediaRoot/mediaDir May 13, 2025
@lukasbestle
Copy link
Member Author

Another thought on the deprecation: We could actually introduce the media subclasses in v5.x and deprecate all old methods in one go then. This avoids having to migrate calls to the new methods twice.

Which means we can merge this as is. If we want, we could already add @deprecated tags to the old methods without deprecation warnings, but it’s not required IMO.

@bastianallgeier
Copy link
Member

@lukasbestle sounds good to me!

@bastianallgeier bastianallgeier merged commit e17d61a into v5/develop May 14, 2025
12 checks passed
@bastianallgeier bastianallgeier deleted the v5/feature/media-firewall-2 branch May 14, 2025 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants