Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Restrict scanning for composer.json in themes to certain directory depth (optional)#9013

Merged
pamil merged 2 commits into
Sylius:1.1from
stefandoorn:1.0-restrict-theme-directory-scan
Jan 5, 2018
Merged

Restrict scanning for composer.json in themes to certain directory depth (optional)#9013
pamil merged 2 commits into
Sylius:1.1from
stefandoorn:1.0-restrict-theme-directory-scan

Conversation

@stefandoorn
Copy link
Copy Markdown
Contributor

@stefandoorn stefandoorn commented Dec 7, 2017

Q A
Branch? 1.1
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Related tickets mentioned in #9008
License MIT

@stefandoorn stefandoorn changed the title Restrict scanning for composer.json in themes to root of themes Restrict scanning for composer.json in themes to root of theme folders Dec 7, 2017
Comment thread UPGRADE-1.0.md Outdated
@@ -1,3 +1,7 @@
# UPGRADE FROM 1.0.5 to 1.0.6

* Scanning for `composer.json` file inside themes used to be recursive. This is now limited to the root of each theme. This has always been the intended location for this file.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is now limited to the root of each theme. This has always been the intended location for this file.

That's true. What has not been said is that themes root have to be not more than one level below app/themes. Some people might have set up themes like app/themes/vendor/package-name/composer.json and some like app/themes/FooBarTheme/composer.json so for the first ones it would result in a BC break.

We might add an option to FilesystemConfigurationSourceFactory named depth, which defaults to null (being the current behaviour with no limit) and then setting it to 1 would restrict the depth in the recursive file locator.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just only one allow app/themes/vendor/package-name/composer.json.

@pamil pamil added Potential Bug Potential bugs or bugfixes, that needs to be reproduced. Enhancement Minor issues and PRs improving the current solutions (optimizations, typo fixes, etc.). and removed Potential Bug Potential bugs or bugfixes, that needs to be reproduced. labels Dec 8, 2017
@pamil pamil added this to the 1.0 milestone Dec 8, 2017
@stefandoorn stefandoorn force-pushed the 1.0-restrict-theme-directory-scan branch 2 times, most recently from f0c817d to 4211b7e Compare January 3, 2018 20:54
@stefandoorn
Copy link
Copy Markdown
Contributor Author

@pamil Can you have a check again?

I've restricted the configuration now to a single integer (optional, default = null). The depth method call inside the recursive file locator can also be called multiple times, allowing users to define e.g. >1 & < 4, but I'm not sure we need something like that. In that rare case user can maybe create their own solution. I think with this change we cover the biggest performance issue (e.g. scanning a node_modules folder).

@stefandoorn
Copy link
Copy Markdown
Contributor Author

P.S. Do you also want more tests (functional / phpunit) etc? ThemeBundle has quite some I see.

@lchrusciel
Copy link
Copy Markdown
Contributor

@stefandoorn but we need to make current configuration tests green again

@stefandoorn
Copy link
Copy Markdown
Contributor Author

Hm damn I thought they would pass yesterday. Will look again into it then.

@stefandoorn stefandoorn changed the title Restrict scanning for composer.json in themes to root of theme folders Restrict scanning for composer.json in themes to certain directory depth (optional) Jan 4, 2018
@pamil
Copy link
Copy Markdown
Contributor

pamil commented Jan 4, 2018

@stefandoorn looks all right! Some functional tests would be great (and an another one for configuration actually). For example, you might add scan_depth option in Tests/Functional/app/config/config.yml, create another theme in Tests/Fixtures/themes with YetAnother/TestTheme/composer.json path and check that it is not found.

Btw. can you rebase it to 1.1? It feels more like a new feature (restricting scanning depth) and the release is less than a month away anyway :)

@stefandoorn stefandoorn force-pushed the 1.0-restrict-theme-directory-scan branch from f4a3466 to daada35 Compare January 4, 2018 13:50
@stefandoorn stefandoorn changed the base branch from 1.0 to 1.1 January 4, 2018 13:51
@stefandoorn stefandoorn force-pushed the 1.0-restrict-theme-directory-scan branch from daada35 to 56b001c Compare January 4, 2018 14:13
@stefandoorn
Copy link
Copy Markdown
Contributor Author

@pamil @lchrusciel Ready to be checked again. Rebased against 1.1 and added functional test / configuration checks.

@pamil pamil modified the milestones: 1.0, 1.1 Jan 5, 2018
@pamil pamil merged commit ceabd15 into Sylius:1.1 Jan 5, 2018
@pamil
Copy link
Copy Markdown
Contributor

pamil commented Jan 5, 2018

Thanks Stefan, themes will be lightning fast right now 🥇

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

Labels

Enhancement Minor issues and PRs improving the current solutions (optimizations, typo fixes, etc.).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants