Symfony: Profiler sees twig deprecations, but cannot find where they come from - symfony

I'm trying to upgrade a Symfony instance from 2.8 to 3.0, and, while I was checking the deprecations in profiler, I found:
The Twig\Template class implements Twig_TemplateInterface that is deprecated since 1.12 (to be removed in 3.0) (2 times)
The Twig\Lexer class implements Twig_LexerInterface that is deprecated since 1.12 (to be removed in 3.0)
The Twig\Compiler class implements Twig_CompilerInterface that is deprecated since 1.12 (to be removed in 3.0)
The Twig\Node\Node class implements Twig_NodeInterface that is deprecated since 1.12 (to be removed in 3.0)
The Twig\Parser class implements Twig_ParserInterface that is deprecated since 1.12 (to be removed in 3.0)
My Twig version is 1.42.4
Just to confirm: we agree this is deprecation messages from twig itself, telling it will remove those functions in its own 3.0 version ? I mean: it's not Symfony telling it will not support this anymore in its 3.0.0 ?
I also suppose upgrading Twig will not help on this. It is the the responsible for those calls I guess ;)
After confirming the above basics, how can I locate the bundle which uses those deprecated functions, because I suppose THIS is the package I need to upgrade first (I'm pretty sure the problem is not in my own code...) ?
The message does not give so many details, and... the stack is just unclear to me...
DebugClassLoader::loadClass()
spl_autoload_call()
class_exists() (called from Template.php at line 5)
require() (called from DebugClassLoader.php at line 169)
DebugClassLoader::loadClass()
spl_autoload_call()
ReflectionClass::__construct() (called from ClassCollectionLoader.php at line 307)
ClassCollectionLoader::getOrderedClasses() (called from ClassCollectionLoader.php at line 120)
ClassCollectionLoader::load() (called from Kernel.php at line 405)
Kernel::doLoadClassCache() (called from Kernel.php at line 124)
Kernel::boot() (called from Kernel.php at line 180)
Kernel::handle() (called from app_dev.php at line 28)
Maybe that can help to answer: I noticed the deprecation warnings appear ONLY when I load a page for the first time, or when I just deleted the cache... So, it's something generating the Symfony cache, which is calling deprecated features...
At last, but not least, I tried to upgrade Twig from 1.x to 2.x, knowing Symfony composer tells "twig/twig": "^1.0||^2.0". I first though it would go to 2.x, but it just upgraded it to the lmatest 1.x (1.42.4), my current version... Composer message was not clear about what was reponsible of the fact it did not go higher...
IF I understood well, those deprecation warnings are not about Symfony upgrade itself, so I 'could eventually go for it. I have something in my instance, that uses old Twig functions, so I would like to get rid of it...
BONUS question: sometimes, I wonder... it's so complicated to fight with all those version constraints... Wouldn't it be more simple just to use generic composer.json, provided with the symfony version we are trying to reach, instead of editing the one we get for years, in our old version ? At least, I guess all libraries would be updated at versions tested by developpers ?
Thanks for helping, and happy new year ;)

In short, sometimes deprecations are reported for vendor code that you can't really change. This is the case. It's useless for you.
It will go away eventually, once you upgrade to higher Symfony/Twig.

Related

FXMLLoader template flag

Looking at FXMLLoader#load, a "template flag" is mentioned - yet I see no explanation of how to set this flag. Presumably there should be a FXMLLoader#setTemplate, but no such method exists in the linked JavaDoc, and using the latest 1.8 OpenJDK (build 1.8.0_72-internal-b05) I can't see such method either.
So what is this flag, and how do I set it?
There was some discussion on the JavaFX developer list about creating this flag in order to generate a better-performing mode for loading FXML files for certain use cases. It seems this idea was not included in the final release of JavaFX 8.0, but clearly the API documentation didn't fully reflect that decision.
So the actual answer to your question is that the API documentation is wrong: there is no such flag.

How to ignore deprecated messages in log related to 3rd party bundles?

After updating Symfony to 2.7 version it started to log DEPRECATED notices in the log. It is a good thing. And I want use the whole power of this feature.
But now it is very hard to find any deprecated notice related to my own bundle. Many of deprecations are from vendor folder. And I want to completely ignore vendor folder in this case. Then I will see messages related to my bundle only.
Read
http://symfony.com/doc/current/cookbook/upgrade/deprecation_warnings.html
Resume :
ini_set("error_reporting", E_ALL & ~E_USER_DEPRECATED);
EDIT
If you want to show only your deprecated Warning, you should try/catch the E_USER_DEPRECATED Warning and propagate it only if it's related to your bundle

Why does Flyway's Validate ignore missing files?

I use Flyway's migrate when I start my application to, well, migrate the database. As per default validateOnMigrate is enabled and validate reports an error if a already applied file is changed.
So far so good, but it seems to ignore cases where an already applied file is missing.
Secondly, if the schema contains a migration that is newer than the latest available, migrate logs a warning but doesn't fail either, for example:
Schema xxx has a version (1.1.1) that is newer than the latest
available migration (1.0.1) !
Is there a way to prevent this behaviour? I would like to have options like failIfMigrationIsMissing and failIfSchemaIsNewer.
All of this would be useful to make sure nobody installs or starts an older version on top of a newer database, e.g. downgrades. Actually I thought this would be the default behaviour, or do I miss something here?
Here's a scheme that works with flyway 4.0.3. You can check all the migrations if your versioning is more complex.
flyway.migrate();
MigrationInfoService migrationInfoService = flyway.info();
MigrationInfo[] applied = migrationInfoService.applied();
MigrationInfo last = applied[applied.length - 1];
if (MigrationState.FUTURE_SUCCESS.equals(last.getState())) {
throw new Exception("Database downgrade detected.");
}

Best strategy for upgrading application from Symfony 2.0 to Symfony 2.4?

I need to upgrade an existing rather large application from Symfony 2.0.15 to Symfony 2.4.x (replace with current version).
I'm not quite sure what would be the best strategy to do so. Migration critical features like forms or esi are used, of course :)
Upgrade "step by step" from one major version to another (2.1, 2.2, 2.3, 2.4)
Upgrade directly from 2.0.x to 2.4
Do you have any tips / experience to share ? Would appreciate it :)
Thanks,
Stephan
Each new version comes with an update UPGRADE-2.x.md file containing all intructions to convert your application from the immediately previous version.
I had to do that on my project as well, and I found the step-by-step method more natural and easier to manage. Fact is, there is no file such file as UPGRADE-2.0-to-2.4.md that would help you out for a direct conversion to 2.4.
I shall first recommend to make sure that none of your code uses obsolete functionnalities of Symfony 2.0 (not sure if there are deprecated parts in this version, though), because these can be removed in ulterior versions and will not be included in the UPGRADE file.
If you have done indeep modifications of the core Symfony code, you may find that some undocumented modifications are needed. For instance, there is a custom error handler in my project, extending the Symfony error handler. Well, although it was not documented in the UPGRADE file, the signature of ErrorHandler::handle() was modified and needed to be updated in my custom handler.
Similarly, I had to modify some namespaces because files had been moved in the framework code.
The conversion is still ongoing and I'm currently experiencing a weird error I'm trying to get rid of: The 'request' scope on services registered on custom events generates errors in the logs.

Symfony 2 prod environment Deprecated call

I just finished the Symblog tutorial for symfony. Everything works just fine except when I try running the project on the production environment. On the blog page the following error message appears on the top of the page and on top of the comment section: Deprecated: getEntityManager is deprecated since Symfony 2.1. Use getManager instead in F:\xampp\htdocs\php\symblog\vendor\doctrine\doctrine-bundle\Doctrine\Bundle\DoctrineBundle\Registry.php on line 71
I am wondering why because I used the same version (symfony 2.3.10) for other projects and in these I have never seen this message. So what should I do?
Thanks in advance!
You should replace your code to use getManager() method instead of getEntityManager() or just change your error_reporting PHP setting (take a look at the below snippet).
The reason of not showing other depreciation messages in other project is different error reporting configuration (probably somwthing similar to the following - deprecated warnings will not be reported):
error_reporting(E_ALL ^ E_DEPRECATED);

Resources