Skip to content

[Debug] Fixed erroneous deprecation notice for extended Interfaces #17320

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
Jan 12, 2016
Merged

[Debug] Fixed erroneous deprecation notice for extended Interfaces #17320

merged 1 commit into from
Jan 12, 2016

Conversation

peterrehm
Copy link
Contributor

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

Replaces #16775.

@Tobion
Copy link
Contributor

Tobion commented Jan 10, 2016

I think this implementation is too specific. It should be solved generically. Something like ignore deprecated interfaces if the parent interface is from the Symfony namespace as well.

@peterrehm
Copy link
Contributor Author

@Tobion Updated accordingly. I don't know if this might cause any unwanted side effects.

@Tobion
Copy link
Contributor

Tobion commented Jan 10, 2016

Lets see what @nicolas-grekas thinks

@nicolas-grekas
Copy link
Member

There is an issue, and I think we should not restrict the fix to Symfony* names.
I propose this patch:

--- a/src/Symfony/Component/Debug/DebugClassLoader.php
+++ b/src/Symfony/Component/Debug/DebugClassLoader.php
@@ -200,8 +200,23 @@ class DebugClassLoader
                         @trigger_error(sprintf('The %s class extends %s that is deprecated %s', $name, $parent->name, self::$deprecated[$parent->name]), E_USER_DEPRECATED);
                     }

+                    $parentInterfaces = array();
+                    $deprecatedInterfaces = array();
+                    if ($parent) {
+                        foreach ($parent->getInterfaceNames() as $interface) {
+                            $parentInterfaces[$interface] = 1;
+                        }
+                    }
                     foreach ($refl->getInterfaceNames() as $interface) {
-                        if (isset(self::$deprecated[$interface]) && strncmp($ns, $interface, $len) && !($parent && $parent->implementsInterface($interface))) {
+                        if (isset(self::$deprecated[$interface]) && strncmp($ns, $interface, $len)) {
+                            $deprecatedInterfaces[] = $interface;
+                        }
+                        foreach (class_implements($interface) as $interface) {
+                            $parentInterfaces[$interface] = 1;
+                        }
+                    }
+                    foreach ($deprecatedInterfaces as $interface) {
+                        if (!isset($parentInterfaces[$interface])) {
                             @trigger_error(sprintf('The %s %s %s that is deprecated %s', $name, $refl->isInterface() ? 'interface extends' : 'class implements', $interface, self::$deprecated[$interface]), E_USER_DEPRECATED);
                         }
                     }

@peterrehm could you please also squash your PR and fix the commit message (and PR title)?
This would help generating a useful changelog when releasing. Thanks!

@peterrehm peterrehm changed the title Fixed erroneous deprecation notice for the SimplePreAuthenticatorInterface Fixed erroneous deprecation notice for extended Interfaces Jan 11, 2016
@peterrehm peterrehm changed the title Fixed erroneous deprecation notice for extended Interfaces [Debug] Fixed erroneous deprecation notice for extended Interfaces Jan 11, 2016
@Tobion
Copy link
Contributor

Tobion commented Jan 11, 2016

Needs tests IMO

@stof
Copy link
Member

stof commented Jan 11, 2016

Can you add a test covering this ?

@peterrehm
Copy link
Contributor Author

Not sure yet, working on it.

@peterrehm
Copy link
Contributor Author

Just added a test, please have a look at the test. @nicolas-grekas Otherwise all your comments should have been incorporated as well...


$this->assertSame($xError, $lastError);
}

public function provideDeprecatedSuper()
Copy link
Member

Choose a reason for hiding this comment

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

please keep this dataProvider near the test using it instead of inserting your new test between them

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

@nicolas-grekas
Copy link
Member

Thank you @peterrehm.

@nicolas-grekas nicolas-grekas merged commit 5f4e968 into symfony:2.8 Jan 12, 2016
nicolas-grekas added a commit that referenced this pull request Jan 12, 2016
…terfaces (peterrehm)

This PR was merged into the 2.8 branch.

Discussion
----------

[Debug] Fixed erroneous deprecation notice for extended Interfaces

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

Replaces #16775.

Commits
-------

5f4e968 Fixed erroneous deprecation notice for extended Interfaces
@peterrehm peterrehm deleted the deprecated-auth-interface branch January 12, 2016 09:14
@Tobion
Copy link
Contributor

Tobion commented Jan 12, 2016

So when a user-land interface extends a deprecated symfony interface, there are no deprecation messages anymore?

@nicolas-grekas
Copy link
Member

yes there is, when the user interface is loaded, isn't it?

@Tobion
Copy link
Contributor

Tobion commented Jan 12, 2016

Ok I just wanted to make sure.

@fabpot fabpot mentioned this pull request Jan 14, 2016
@fabpot fabpot mentioned this pull request Feb 3, 2016
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.

5 participants