Skip to content
This repository has been archived by the owner on Jan 1, 2023. It is now read-only.

Fixing 3.0 compatibility problem with ResourceInterface::isFresh() #395

Merged
merged 1 commit into from
Dec 1, 2015

Conversation

weaverryan
Copy link
Member

Hi guys!

The bundle is not ready for 3.0 yet, because of AsseticResource. Implementing isFresh() on ResourceInterface is deprecated: we need to also implement SelfCheckingResourceInterface.

But this patch clearly has issues: it makes AsseticBundle require symfony/config 2.8 (and worse, beta currently). Is there a way to make the bundle compatible with 2.7 (where SelfCheckingResourceInterface doesn't exist) AND 3.0 (where SelfCheckingResourceInterface is required) at the same time?

Thanks!

@weaverryan
Copy link
Member Author

Ping @Ener-Getick - I've seen you add some very nice 3.0 compat in other places - I wonder if you've seen any other places where there is an example of how to correctly handle this situation. Thanks :)

@GuilhemN
Copy link
Contributor

I don't remember any example but you can create a new @internal class (containing the AsseticRessource functions) which will be extended by AsseticRessource with the right interface (you have to place the class definition in a condition that checks the existence of SelfCheckingResourceInterface).

@stof
Copy link
Member

stof commented Nov 24, 2015

Dropping support for LTS versions is not an option.

A better solution would be to register a checker able to handle AsseticResource (I'm planning to refactor these resources to avoid serializing twig in them anyway)

@weaverryan weaverryan force-pushed the resource-interface-update branch 2 times, most recently from c13d6f3 to 4fe2ff9 Compare November 24, 2015 15:44
@weaverryan
Copy link
Member Author

Thanks for the advice! This PR is updated and should be ready to be merged. I used @Ener-Getick's advice to create a sub-class that implements the interface and use that when the interface is available. This can be a short-term solution before properly refactoring the resource checking.

I also tested this locally on a 2.8 project and the deprecation warnings indeed went away.

@GuilhemN
Copy link
Contributor

I was actually more thinking to something like:

<?php

namespace Foo;

/**
 * @internal
 */
class InternalFoo {
    function foo() {
        // ...
    }

    // other functions
}

if(interface_exists('Bar\BarInterface')) {
    class Foo extends InternalFoo implements \Bar\BarInterface { }
} else {
    class Foo extends InternalFoo { }
}

But I don't know if this solution is acceptable... What do you think @stof ?

use Symfony\Component\Config\Resource\SelfCheckingResourceInterface;

/**
* Implmenets SelfCheckingResourceInterface required in Symfony 3.0.
Copy link
Member

Choose a reason for hiding this comment

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

typo here

In 2.8, the SelfCheckingResourceInterface becomes available and you must
implement it for 3.0. An if statement either uses the old AsseticResource
(which does not include this interface) or the new SelfCheckingAsseticResource
if the interface exists.
@weaverryan
Copy link
Member Author

@stof fixed

@weaverryan
Copy link
Member Author

This is ready to be merged. Failure is on php7 and is unrelated.

@xabbuh
Copy link
Member

xabbuh commented Dec 1, 2015

👍

@stof
Copy link
Member

stof commented Dec 1, 2015

Thanks for fixing this bug @weaverryan.

@stof stof merged commit 49c7279 into symfony:master Dec 1, 2015
stof added a commit that referenced this pull request Dec 1, 2015
…resh() (weaverryan)

This PR was merged into the 2.7-dev branch.

Discussion
----------

Fixing 3.0 compatibility problem with ResourceInterface::isFresh()

Hi guys!

The bundle is not ready for 3.0 yet, because of [AsseticResource](https://github.com/symfony/assetic-bundle/blob/master/Config/AsseticResource.php). Implementing `isFresh()` on `ResourceInterface` is deprecated: we need to also implement `SelfCheckingResourceInterface`.

But this patch clearly has issues: it makes AsseticBundle require symfony/config 2.8 (and worse, beta currently). Is there a way to make the bundle compatible with 2.7 (where `SelfCheckingResourceInterface` doesn't exist) AND 3.0 (where `SelfCheckingResourceInterface` is required) at the same time?

Thanks!

Commits
-------

49c7279 Adding a new SelfCheckingAsseticResource for compat with 2.8-3.0+
@stof
Copy link
Member

stof commented Dec 1, 2015

I will wait a bit (either this evening or this weekend depending on my time this evening) before making a release, as I would like to check how much time my refactoring idea would require. If it is not quick, I will release this workaround in the meantime.

@weaverryan
Copy link
Member Author

👍 sounds very reasonable - thanks :)

@weaverryan weaverryan deleted the resource-interface-update branch December 1, 2015 16:17
@Restless-ET
Copy link

@stof Will this change be tagged soon or should I just track the master branch for now?

@jdemangeon
Copy link

👍

@weaverryan
Copy link
Member Author

@stof what are your thoughts now? I'm waiting to record a KnpU episode on upgrading to 3.0 - this is my blocker. Thx :)

@stof
Copy link
Member

stof commented Dec 14, 2015

I wanted to do it this weekend at first, but I ended up not doing anything related to code. Will do this evening

@weaverryan
Copy link
Member Author

Me too ;)

@msvrtan
Copy link

msvrtan commented Dec 18, 2015

Any chance of tagging a new release with this fix? 2.7.1 is still throwing deprecated warnings which my CI doesn't like :)

@Ninir
Copy link

Ninir commented Dec 27, 2015

@stof Any news? a release would be really appreciable :-)

@Wirone
Copy link

Wirone commented Dec 29, 2015

I'm also interested, it's probably last thing triggering deprecation errors in our app.

@fabpico
Copy link

fabpico commented Jan 5, 2016

I'm also waiting for a patch! 👍

@weaverryan
Copy link
Member Author

@stof friendly ping - if you tag, I will buy you 🍨 in Berlin ;)

@kreaton85
Copy link

I hope the patch will come out asap!

@Madeyes44
Copy link

We are stuck ! A patch would be really appreciated !

@Babacooll
Copy link

@stof Same here, last deprecation error too :) ! A patch would also be appreciated !

@x3ro
Copy link

x3ro commented Jan 22, 2016

👍

@RubenHarms
Copy link

@stof, do you have any news about a patch or release tag?

@Oliboy50
Copy link

Hope a 2.7.2 or 2.8.0 tag will come soon to be able to use this bundle using a stable release in SF3 ;)

@rvanlaak
Copy link

Also hope @stof did like @weaverryan 's 🍨

This results in around 500 deprecation notices in my error mails Monolog sends 👍

@mynamedia
Copy link

Is this ready to deploy?

@netmikey
Copy link

netmikey commented Feb 8, 2016

Let me join the crowd: @stof it's been a while man, would be really nice not to let people hang on here any longer ;-)

@DHager
Copy link

DHager commented Feb 8, 2016

I expect there's a large crowd of volunteers for any last-minute tasks that could hurry this along 😀

@mynamedia
Copy link

^ this.

@mynamedia
Copy link

From looking at thread #251, it seems that using the master branch fixes the issue.

This is also talked about on #401.

I installed the master branch and my deprecation notices went away.

@netmikey
Copy link

netmikey commented Feb 9, 2016

While technically correct, it's generally agreed on that using a library's master development branch is bad practice. What if they merge a broken commit and you happen to update your site right at that moment? Sure you could rely on a specific commit hash, but let's not go there... ;-)

@Wirone
Copy link

Wirone commented Feb 10, 2016

You can always force exact commit with

{
    "require": {
        "symfony/assetic-bundle": "dev-master#aa5b4f8"
    }
}

and it will write that commit in composer.lock ensuring that no newer commit will be pulled. It acts like release. So maybe it's a solution while @stof does not respond :-)

@arderyp
Copy link

arderyp commented Feb 17, 2016

Thanks for the workaround @Wirone, though I'm afraid to use it and forget about it. @stof, are there some additional tasks to be completed, code to be changed, etc before this release can be tagged and published? I know you mentioned a refactoring project above. If there is still work to be done, I think some of us would be happy to take a look. Hope all is well. Thanks.

@clytemnestra
Copy link

I have a 2.8 project and want to upgrade it to 3.0, but it uses assetic. My log file is full of this deprecation notice, like hundreds of it. Would this error affect the project or it still works? Since 3.0 removed backward compatibility...

@arderyp
Copy link

arderyp commented Mar 3, 2016

@clytemnestra, I believe that upgrading to 3.0 would break your application in those places where assetic is used, as the isFresh() and other deprecated functions/methods/classes will be removed in 3.0, meaning there will be no more notices to throw, just errors when your app tries to call a non-existent function/method/class. Someone please correct me if I am wrong, but I believe that's how it will work.

@timwhite
Copy link

timwhite commented Mar 3, 2016

👍

@clytemnestra
Copy link

That's how I believe it will work, too. I think Assetic is the only bundle that's keeping me from upgrading my project to 3.0, that's why I'm not doing it yet.

@rvanlaak
Copy link

rvanlaak commented Mar 3, 2016

@clytemnestra you could try requiring dev-master of this bundle to see or that prevents your project from crashing on 3.0

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet