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

Allow multiple root paths for FileSystemLoader #851

Merged
merged 1 commit into from
Jan 20, 2017

Conversation

robfrawley
Copy link
Collaborator

@robfrawley robfrawley commented Jan 13, 2017

Allow multiple data roots for file system loader as a possible approach to resolve #846. Includes beforeNormalization step in configuration tree-builder to allow prior string values for data_root bundle configuration to be seamlessly converted into an array. For example, both of the following are now valid configurations:

liip_imagine:
  loaders:
    default:
      filesystem:
        data_root: "/your/data/root"
liip_imagine:
  loaders:
    default:
      filesystem:
        data_root: 
          - "/your/data/root/a"
          - "/your/data/root/b"

This also adds a "feature" in that we can look in multiple locations using the same file system loader now, which I suspect could be beneficial for some use-cases. Most importantly, though, this implementation doesn't break any prior unit tests (but it does add a few unit tests to cover the new cases introduced).

@robfrawley robfrawley added the Level: Enhancement ✨ This item involves an enhancement to existing functionality. label Jan 13, 2017
@robfrawley robfrawley self-assigned this Jan 13, 2017
@lsmith77 lsmith77 added the State: Reviewing This item is being reviewed to determine if it should be accepted. label Jan 13, 2017
@robfrawley robfrawley added the Level: New Feature 🆕 This item involves the introduction of new functionality. label Jan 13, 2017
@robfrawley robfrawley force-pushed the bugfix-issue-846 branch 3 times, most recently from 8c84f62 to dfa45d8 Compare January 13, 2017 23:34
@robfrawley
Copy link
Collaborator Author

robfrawley commented Jan 13, 2017

Amended PR to support PHP 5.3 ($this closure calling context isn't properly implemented in 5.3).

@robfrawley
Copy link
Collaborator Author

robfrawley commented Jan 14, 2017

@antoligy @cedricziel How do you guys feel about this feature, as both a ligament new feature (regardless of symbolic links) and a possible fix for those attempting to use multiple symbolic links that point outside a single path (see #846).

@robfrawley
Copy link
Collaborator Author

robfrawley commented Jan 14, 2017

Amended PR to add a test case that ensures configuration data_root string is correctly normalized to an array by the configuration tree processor.

@alexwilson
Copy link
Collaborator

Nice, with that latest addition this should be fully backwards compatible with the latest release! 🙂

I'm very happy with this approach, not least of all as it addresses the "real" issue, but also as it adds more thorough tests.
I still think that it is worth amending the documentation to better detail this behaviour, however that's something which we can address later. For the meantime, no objections from me, but I will take a more in-depth look first before hitting approve.

@robfrawley robfrawley force-pushed the bugfix-issue-846 branch 2 times, most recently from c691b34 to 4a0be3c Compare January 14, 2017 01:00
Copy link
Collaborator

@alexwilson alexwilson left a comment

Choose a reason for hiding this comment

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

Looks good!

Wondering if it's worth standardising how we format the display of multiple paths in the future (I rather like /whatever/:/foo/bar/, but I'm not sure if this is defined).

@robfrawley
Copy link
Collaborator Author

@antoligy I too like the format /foo/bar:/bar/foo, but no, I do not believe such is well-defined elsewhere. I do agree we should standardize on something. Perhaps we should investigate and see where similar usage might be appropriate. Also, docs PR will be incoming shortly that details this behavior, as well as provides some concrete information for commonly encountered errors.

@robfrawley
Copy link
Collaborator Author

robfrawley commented Jan 14, 2017

So, I'm pretty positive this doesn't result in any BC breaks: the configuration value for data_root continues to support a scalar alongside the newly supported type of scalar[] (an array of scalars); the loader class FileSystemLoader continues to support a scalar alongside the newly supported type of scalar[] for the $dataRoots parameter; etc. In short, the API hasn't changed and continues to operate as expected using either the old or new data types. But, with that said...

A possible BC break exists for someone extending the FileSystemLoader class: anyone relying on the protected rootPath member, which has been renamed to rootPaths (plural), may be affected. IMHO, this is better than leaving it as a singularly named property and changing the type, which would cause other (less easily identified) issues. Do we have a BC policy as it applies to extending our classes and protected properties/methods?

Which brings us to one of the most pressing issues for v2.0 (in my opinion): we need to make everything private that doesn't serve as an API entry point, a move many projects have been making as of late, including Symfony itself. In my opinion, most properties and methods should be either private or public, unless we have an internal need to enable inheritance and set something as protected.

Thoughts?

@robfrawley robfrawley added this to the v1.7.1 milestone Jan 15, 2017
@robfrawley robfrawley removed the request for review from cedricziel January 15, 2017 07:35
@robfrawley robfrawley requested a review from cedricziel January 15, 2017 07:35
@robfrawley
Copy link
Collaborator Author

So, @antoligy: we want to merge this?

@alexwilson
Copy link
Collaborator

Sorry for the delay, and yes I think we should be good to merge this! Can we can warn about the potential BC breakage in the changelog? (I doubt that this bit of the API is actually used though, and I agree that in 2.0 we should reduce the surface area exposed by the API - As we're looking to decouple business logic from controllers the API definition would be greatly improved anyway!)

@robfrawley
Copy link
Collaborator Author

Agreed (re decoupling and reduction of surface area). Ok; I'll merge this and release 1.7.1 later today, which will include an updated changelog. Are there any other pressing issues I'm not aware of that need to be part of this patch release?

@alexwilson
Copy link
Collaborator

Nothing as far as I'm aware

@robfrawley robfrawley merged commit 8efc475 into liip:1.0 Jan 20, 2017
@lsmith77 lsmith77 removed the State: Reviewing This item is being reviewed to determine if it should be accepted. label Jan 20, 2017
@alexwilson
Copy link
Collaborator

🎉

@robfrawley
Copy link
Collaborator Author

Still need to cherry pick for master and 2.0 branches, but 1.7.1 release is now live! ;-)

@robfrawley
Copy link
Collaborator Author

robfrawley commented Jan 20, 2017

Comment about the BC break for those extending FileSystemLoader is in the UPGRADE.md file in the respective line about the changes to that class. I'll be pushed updated docs shortly which will cause the online documentation to be re-rendered, as well, with information about the ability to configure multiple data roots.

@robfrawley robfrawley deleted the bugfix-issue-846 branch January 28, 2017 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Level: Enhancement ✨ This item involves an enhancement to existing functionality. Level: New Feature 🆕 This item involves the introduction of new functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants