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

Skip to content

[Finder] Deprecate adapters and related classes #15805

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

Merged
merged 1 commit into from
Sep 22, 2015

Conversation

nicolas-grekas
Copy link
Member

Q A
Bug fix? no
New feature? no
BC breaks? no
Deprecations? yes
Tests pass? yes
Fixed tickets -
License MIT
Doc PR -

@nicolas-grekas nicolas-grekas force-pushed the deprec-adapters branch 2 times, most recently from c86cf65 to 473330c Compare September 15, 2015 13:43
@@ -282,7 +284,7 @@ public function testFilter($adapter)
public function testFollowLinks($adapter)
{
if ('\\' == DIRECTORY_SEPARATOR) {
return;
$this->markTestSkipped('symlinks are not supported on Windows');
Copy link
Member

Choose a reason for hiding this comment

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

this should be done in older branches

@stof
Copy link
Member

stof commented Sep 15, 2015

I suggest doing the change of the way adapters are covered in the 2.3 branch instead:

  • this would mark tests for other adapters as skipped instead of deleting the tests entirely, which gives feedback on the fact that some tests are not running
  • this would simplify the merging of branches

Tests which don't use the adapter data providers currently should also stay in a separate FinderTest instead of running several times (once per adapter testcase)

$this->markTestSkipped(get_class($this).' is not supported.');
}

return array($adapter);
Copy link
Member

Choose a reason for hiding this comment

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

Instead of a method returning an array of adapters with a single element, and then using this to build a dataProvider providing the adapter, I suggest you to use a protected method getAdapter returning the adapter being used for tests and using it in buildFinder() (which would not need an argument anymore). It would make tests much easier to understand

@stof
Copy link
Member

stof commented Sep 15, 2015

btw, the change in the way tests for unsupported adapters are ignored is something I wanted to do after looking at the finder testsuite today while reviewing your other PR. Knowing what is running or no is hard in the current setup

@nicolas-grekas
Copy link
Member Author

@stof would you like to do the PR on 2.3 then?

@stof
Copy link
Member

stof commented Sep 15, 2015

Regarding the deprecation, should we actually deprecate it yet ? the comparison in #15802 (comment) still shows a significant difference between them, which means this introduces a potential slowdown for people using useBestAdapter when using the finder.

@stof
Copy link
Member

stof commented Sep 15, 2015

@nicolas-grekas not immediately, but I can, yes.

@fabpot
Copy link
Member

fabpot commented Sep 15, 2015

I think we should deprecate the other adapter for several reasons:

  • we now know that the PHP adapter can be fast enough;
  • the other adapters are fragile;
  • removing this code is something I wanted to do since ages :).

@stof
Copy link
Member

stof commented Sep 15, 2015

btw, the finder-benchmark has a bunch of other cases which have not been run when you compared it (they are commented in the latest commit of the finder benchmark repo but you can uncomment it). It would be great to run them too.

@fabpot we know we can optimize the PHP adapter further. but shouldn't we do it before deprecating things ? useBestAdapter will now use the php adapter all the time unless people register the deprecated adapters explicitly.

Btw, if we deprecate adapters, we should also deprecate adapter-related methods in the Finder class

@fabpot
Copy link
Member

fabpot commented Sep 15, 2015

I'm all for removing everything related to the adapters in the Finder. I wouldn't want this code in 3.0 if possible. It was a mistake back then to introduce such a complex layer.

@nicolas-grekas
Copy link
Member Author

From what I understand by reading quickly the code, the Gnu and Bsd adapters are never used by default. The only way to use them is to enabled them explicitly. Which means almost everyone uses the PhpAdapter. I'd be in favor of deprecating to have 3.0 cleaned from them.
OK for removing all the adapter layer on my side.

@stof
Copy link
Member

stof commented Sep 15, 2015

@nicolas-grekas they would be used when using useBestAdapter().

Note that I fully agree with you about the need to deprecate it and clean it. The question is whether we should work on optimization first or no.

@nicolas-grekas
Copy link
Member Author

Given that the feature freeze is in a few days, I'd be in favor of deprecating now, and optimize later

@nicolas-grekas nicolas-grekas force-pushed the deprec-adapters branch 2 times, most recently from f758dd8 to 0163796 Compare September 15, 2015 16:19
@nicolas-grekas
Copy link
Member Author

Status: needs work
To be rebased on top of #15808

@stof
Copy link
Member

stof commented Sep 15, 2015

should we reopen #5951 until more optimization work is done ?

fabpot added a commit that referenced this pull request Sep 16, 2015
This PR was merged into the 2.3 branch.

Discussion
----------

Improve the structure of the Finder testsuite

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

Testing against different adapters is now handled by multiple subclasses of a common test case rather than using data providers. This allows tests to be marked as skipped for unsupported adapters instead of making them disappear from the testsuite.
This will also make it much easier to mark tests for the find-based adapters as legacy ones when deprecating them.
This correspond to changes done by @nicolas-grekas in #15805, backported to 2.3 and with the data providers removed (his PR was keeping data providers for the adapter but making it return a single adapter all the time, hence the much bigger diff in my PR).
All tests in AbstractFinderTest are just moved from the FinderTest (they are all the tests running against multiple adapters). FinderTest itself runs the PhpAdapter (as this is the logic we want to keep in the finder in 3.0). I also tried to have a PhpFinderTest and keeping FinderTest only with the extra tests, but this would make things harder to merge branches between 2.8 and 3.0 in the future (once we remove other adapter tests) as we could simply keep the AbstractFinderTest in 3.0 for now to ease merging PRs adding new tests for bug fixes.

Commits
-------

20f2d03 Improve the structure of the Finder testsuite
@stof
Copy link
Member

stof commented Sep 16, 2015

@nicolas-grekas you can now work again on this (after merging branches together)

@nicolas-grekas nicolas-grekas force-pushed the deprec-adapters branch 2 times, most recently from a0002a7 to 55fb6b3 Compare September 18, 2015 07:56
@nicolas-grekas nicolas-grekas changed the title [Finder] Deprecate find based adapters [Finder] Deprecate adapters and related classes Sep 18, 2015
@nicolas-grekas
Copy link
Member Author

PR updated with all the adapter layer being deprecated.

$iterator = $iteratorAggregate->getIterator();
}

return $iterator;
Copy link
Member

Choose a reason for hiding this comment

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

We should find a way to avoid duplicating the PhpAdapter codebase. It would be a maintenance pain otherwise as we would have to think about duplicating any change when merging branches into 2.8

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought the same at first, but this would require some indirection that would be just boilerplate for the shake of synchronization.
Instead, I propose to add a test (here) that just checks that the source code is kept in sync.
Given that all 2.x branches are going to be moved to maintenance only mode, this code won't move that much now.
I think this new test + the test suite is enough as a safe guard. Don't you?

Copy link
Member

Choose a reason for hiding this comment

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

@nicolas-grekas given that Finder optimization are currently considered as being suited for maintenance releases, it might still change :)
but yeah, the test is a good idea.

@nicolas-grekas
Copy link
Member Author

Status: needs review

@@ -771,11 +792,7 @@ private function sortAdapters()
}

/**
* @param $dir
Copy link
Member

Choose a reason for hiding this comment

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

the param should be kept (but we should add the missing type in a 2.3+ PR)

Copy link
Member Author

Choose a reason for hiding this comment

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

that's a private function...

Copy link
Member Author

Choose a reason for hiding this comment

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

but ok, reverted

@stof
Copy link
Member

stof commented Sep 18, 2015

👍

Status: reviewed

@fabpot
Copy link
Member

fabpot commented Sep 22, 2015

Thank you @nicolas-grekas.

@fabpot fabpot merged commit c08cf4b into symfony:2.8 Sep 22, 2015
fabpot added a commit that referenced this pull request Sep 22, 2015
…as-grekas)

This PR was merged into the 2.8 branch.

Discussion
----------

[Finder] Deprecate adapters and related classes

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | yes
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Commits
-------

c08cf4b [Finder] Deprecate adapters and related classes
@nicolas-grekas nicolas-grekas deleted the deprec-adapters branch September 22, 2015 13:39
@fabpot fabpot mentioned this pull request Nov 16, 2015
fabpot added a commit that referenced this pull request Dec 13, 2016
This PR was merged into the 3.3-dev branch.

Discussion
----------

[Finder] Deprecate ExceptionInterface

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | yes
| Tests pass?   | yes
| Fixed tickets | N/A
| License       | MIT
| Doc PR        | N/A

This interface was missed in #15805, and should have been removed in 3.0.

Ideally, the component should have such an interface, though, as other components does. But the only domain exception in this component is an `AccessDeniedException` used by the `RecursiveDirectoryIterator`. So it isn't worth it right now.

I think this interface was almost internal actually, but anyway the `\Symfony\Component\Finder\Adapter\AdapterInterface` interface does not exist anymore. So the `ExceptionInterface::getAdapter()` signature cannot be satisfied anyway. I guess anyone relying on this interface in any way should have notice that and removed anything related to Symfony Finder's adapters when upgrading to 3.0.
Should we consider removing it directly in the 3.1 branch instead?

Commits
-------

1b600b0 [Finder] Deprecate ExceptionInterface
joshtrichards pushed a commit to joshtrichards/symfony-finder that referenced this pull request Apr 26, 2024
This PR was merged into the 2.3 branch.

Discussion
----------

Improve the structure of the Finder testsuite

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

Testing against different adapters is now handled by multiple subclasses of a common test case rather than using data providers. This allows tests to be marked as skipped for unsupported adapters instead of making them disappear from the testsuite.
This will also make it much easier to mark tests for the find-based adapters as legacy ones when deprecating them.
This correspond to changes done by @nicolas-grekas in symfony/symfony#15805, backported to 2.3 and with the data providers removed (his PR was keeping data providers for the adapter but making it return a single adapter all the time, hence the much bigger diff in my PR).
All tests in AbstractFinderTest are just moved from the FinderTest (they are all the tests running against multiple adapters). FinderTest itself runs the PhpAdapter (as this is the logic we want to keep in the finder in 3.0). I also tried to have a PhpFinderTest and keeping FinderTest only with the extra tests, but this would make things harder to merge branches between 2.8 and 3.0 in the future (once we remove other adapter tests) as we could simply keep the AbstractFinderTest in 3.0 for now to ease merging PRs adding new tests for bug fixes.

Commits
-------

12f0f55 Improve the structure of the Finder testsuite
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants