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

[2.x] Lazy loaded MediaFile metadata properties #1933

Merged

Conversation

caendesilva
Copy link
Member

@caendesilva caendesilva commented Aug 5, 2024

Abstract

Changes

  • Makes the public readonly metadata properties protected and only accessible via getter methods
  • Lazy loads metadata properties using a boot system, which constructs all metadata properties when one is accessed (and when instance is serialized to array), and then caches them for future access
  • No longer validates file existence in the constructor, but instead on boot, making it possible to create memory based file objects which opens up the API for more use cases, at the cost of inconsistent places where the file existence is checked but still having a robust system in place for when trying to get filesystem information for a non-existent file

Copy link

codecov bot commented Aug 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.93%. Comparing base (5ba193a) to head (0fbbf2d).

Additional details and impacted files
@@                      Coverage Diff                      @@
##             normalize-the-asset-api    #1933      +/-   ##
=============================================================
- Coverage                      99.97%   99.93%   -0.05%     
- Complexity                      1883     1887       +4     
=============================================================
  Files                            193      193              
  Lines                           4971     4978       +7     
=============================================================
+ Hits                            4970     4975       +5     
- Misses                             1        3       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@caendesilva caendesilva force-pushed the bring-media-assets-into-the-hyde-kernel branch from 3fb3f11 to b61d957 Compare August 5, 2024 14:06
if (! isset($this->length)) {
$this->boot();
}
$this->ensureInstanceIsBooted('length');
Copy link
Member Author

Choose a reason for hiding this comment

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

Technically we could do something like $this->getBootedProperty() but I think this is much more readable and understandable.

@caendesilva caendesilva mentioned this pull request Aug 5, 2024
21 tasks
@caendesilva caendesilva marked this pull request as ready for review August 5, 2024 17:17
@caendesilva caendesilva merged commit 6cf60bf into normalize-the-asset-api Aug 5, 2024
6 checks passed
@caendesilva caendesilva deleted the bring-media-assets-into-the-hyde-kernel branch August 5, 2024 17:17
caendesilva added a commit that referenced this pull request Aug 7, 2024
…e-kernel

[2.x] Lazy loaded MediaFile metadata properties
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.

1 participant