Symfony 2 CSRF issue - symfony

I'm having a trouble with a legacy Symfony application:
The application has been deployed 2 years ago.
The application was working perfectly until two days ago. Now, every user that try log in get CSRF error (CSRF invalid token)
No modification has been made, neither software, nor on the server, NOTHING.
It's a critical application and I need to solve it. I have tried:
Looking in Apache logs. I don't found any relevant information.
Disable CSRF validation. That had no effect (the error is the same).
Increase php limits (trying this answer)
Any ideas?
Some facts and versions:
"require": {
"php": ">=5.4.3",
"symfony/symfony": "~2.4",
"doctrine/orm": "~2.2,>=2.2.3",
"doctrine/doctrine-bundle": "~1.2",
"twig/extensions": "~1.0",
"symfony/assetic-bundle": "~2.3",
"symfony/swiftmailer-bundle": "~2.3",
"symfony/monolog-bundle": "~2.4",
"sensio/distribution-bundle": "~2.3",
"sensio/framework-extra-bundle": "~3.0",
"sensio/generator-bundle": "~2.3",
"incenteev/composer-parameter-handler": "~2.0",
"friendsofsymfony/user-bundle": "~2.0#dev",
"mopa/bootstrap-bundle": "v3.0.0-beta3",
"twbs/bootstrap": "v3.0.0",
"knplabs/knp-paginator-bundle": "dev-master",
"knplabs/knp-menu-bundle": "dev-master",
"knplabs/knp-menu": "2.0.*#dev",
"craue/formflow-bundle": "dev-master",
"leafo/lessphp": "0.4.0",
"genemu/form-bundle": "2.2.*",
"lrotherfield/form": "1.1.x-dev",
"stof/doctrine-extensions-bundle": "~1.1#dev",
"liip/imagine-bundle": "dev-master",
"dizda/cloud-backup-bundle": "dev-master",
"antimattr/google-bundle": "dev-master",
"friendsofsymfony/jsrouting-bundle": "#stable",
"pugx/multi-user-bundle": "3.0.*#dev",
"liuggio/excelbundle": "~2.0",
"fresh/doctrine-enum-bundle": "v2.5",
"igorw/file-serve-bundle": "~1.0",
"knplabs/knp-snappy-bundle": "dev-master",
"hakre/dropbox-uploader": "dev-master",
"dropbox/dropbox-sdk": "1.1.*"
},

Related

Compile Error: Declaration of validateBlock() must be compatible with Blockadmin in Symfony2 Sonata Project

I am getting this following error after adding page bundle to formarly working Symfony2 project.
[Symfony\Component\Debug\Exception\FatalErrorException]
Compile Error: Declaration of Sonata\PageBundle\Block\ChildrenPagesBlockServic
e::validateBlock() must be compatible with Sonata\BlockBundle\Block\BlockAdmin
ServiceInterface::validateBlock(Sonata\CoreBundle\Validator\ErrorElement $erro
rElement, Sonata\BlockBundle\Model\BlockInterface $block)
My Composer.json is as following.
"php": ">=5.3.9",
"symfony/symfony": "2.8.*",
"doctrine/orm": "^2.4.8",
"doctrine/doctrine-bundle": "~1.4",
"symfony/swiftmailer-bundle": "~2.3",
"symfony/monolog-bundle": "~2.4",
"sensio/distribution-bundle": "~5.0",
"sensio/framework-extra-bundle": "^3.0.2",
"incenteev/composer-parameter-handler": "~2.0",
"sonata-project/core-bundle": "^2.3",
"knplabs/knp-menu-bundle": "dev-master",
"sonata-project/admin-bundle": "dev-master",
"sonata-project/doctrine-orm-admin-bundle": "dev-master",
"sonata-project/easy-extends-bundle": "^2.1",
"sonata-project/seo-bundle": "~1.1",
"sonata-project/notification-bundle": "^2.3",
"sonata-project/cache-bundle": "^2.2",
"sonata-project/datagrid-bundle": "2.2.*#dev",
"sonata-project/page-bundle": "^2.3",
"sonata-project/block-bundle": "^2.3"
Thanks in advance...
Had to downgrade few packages to make page bundle compatable with admin-bundle and block bundle.
"require": {
"sonata-project/admin-bundle": "2.3.*",
"sonata-project/doctrine-orm-admin-bundle": "~2.3",
"sonata-project/page-bundle": "^2.3",
"sonata-project/block-bundle": "2.2.*"
},
"require-dev": {
"sensio/generator-bundle": "~2.3",
},

error in sonata media bundle

i installed sonata admin bundle as giving in document
mine issue is i am getting this error on clearing cache
Runtime Notice: Declaration of Sonata\MediaBundle\Controller\MediaAdminController::render() should be compatible with Symfony\Bundle\FrameworkBundle\Controller\Controller::render($view, array $parameters = Array, Symfony\Component\HttpFoundation\Response $response = NULL)
here is my composer.json req
"php": ">=5.3.9",
"symfony/symfony": "2.7.*",
"doctrine/orm": "~2.2,>=2.2.3,<2.5",
"doctrine/dbal": "<2.5",
"doctrine/doctrine-bundle": "~1.4",
"symfony/assetic-bundle": "~2.3",
"symfony/swiftmailer-bundle": "~2.3",
"symfony/monolog-bundle": "~2.4",
"sensio/distribution-bundle": "~4.0",
"sensio/framework-extra-bundle": "~3.0,>=3.0.2",
"incenteev/composer-parameter-handler": "~2.0",
"sonata-project/admin-bundle": "2.4.x-dev",
"sonata-project/doctrine-orm-admin-bundle": "2.4.*#dev",
"sonata-project/datagrid-bundle": "2.2.*#dev",
"sonata-project/user-bundle": "2.3.*#dev",
"sonata-project/formatter-bundle": "2.3.*#stable",
"jms/serializer-bundle": "~0.11",
"doctrine/doctrine-fixtures-bundle": "~2.2",
"stof/doctrine-extensions-bundle": "dev-master",
"egeloen/ckeditor-bundle": "~2.0",
"sonata-project/media-bundle": "2.3.2"
i tired everything but still no clue why i am getting this error please help me
You are using sonata media 2.3 with sonata admin 2.4 : github issue
Change all reference to the 2.4 verson to 2.3. You can set for example : ~2.3.0

install symfony-cmf PHP Fatal error

I have installed symfony-cmf and finaly I got this error :
PHP Fatal error: Class Sonata\MediaBundle\Block\MediaBlockService contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Sonata\BlockBundle\Block\BlockServiceInterface::validateBlock) in /home/jeremy/web/vendor/sonata-project/media-bundle/Block/MediaBlockService.php on line 213.
My composer.json :
"php": ">=5.3.3",
"symfony/symfony": "~2.4",
"doctrine/orm": "v2.4.2",
"doctrine/doctrine-bundle": "~1.2",
"twig/extensions": "~1.0",
"symfony/assetic-bundle": "~2.3",
"symfony/swiftmailer-bundle": "~2.3",
"symfony/monolog-bundle": "~2.4",
"sensio/distribution-bundle": "~2.3",
"sensio/framework-extra-bundle": "~3.0",
"sensio/generator-bundle": "~2.3",
"incenteev/composer-parameter-handler": "~2.0",
"friendsofsymfony/user-bundle": "dev-master",
"friendsofsymfony/jsrouting-bundle": "2.0.*#dev",
"jms/security-extra-bundle": "dev-master",
"friendsofsymfony/oauth-server-bundle": "dev-master",
"doctrine/doctrine-fixtures-bundle": "dev-master",
"doctrine/data-fixtures": "#dev",
"jms/serializer-bundle": "0.12.*#dev",
"knplabs/gaufrette": "0.2.*#dev",
"knplabs/knp-gaufrette-bundle": "dev-master",
"vlabs/media-bundle": "v1.1.1",
"lexik/paybox-bundle": "dev-master",
"stof/doctrine-extensions-bundle": "1.1.*#dev",
"sonata-project/admin-bundle": "2.3.*#dev",
"sonata-project/doctrine-orm-admin-bundle": "2.3.*#dev",
"simplethings/entity-audit-bundle": "0.*#dev",
"hwi/oauth-bundle": "0.4.*#dev",
"sonata-project/media-bundle": "2.3.*#dev",
"tilleuls/ckeditor-sonata-media-bundle": "dev-master",
"egeloen/ckeditor-bundle": "2.*",
"sonata-project/formatter-bundle": "2.3.*#dev",
"kunstmaan/voting-bundle": "2.3.*#dev",
"fyneworks/jquery-star-rating": "dev-master",
"friendsofsymfony/comment-bundle": "2.0.*#dev",
"kartik-v/bootstrap-star-rating": "2.5.0",
"symfony-cmf/create-bundle": "1.1.*",
"jackalope/jackalope-doctrine-dbal": "1.1.*",
"doctrine/doctrine-cache-bundle": "1.0.*",
"symfony-cmf/symfony-cmf": "1.1.*",
"symfony-cmf/simple-cms-bundle": "1.1.*",
"nelmio/alice": "1.*"
Do yo have an idea please, Thanks.
why are you using this vendors in the dev version?
If you need to develop something using stable components, use the #stable
"sonata-project/admin-bundle": "#stable",
"sonata-project/doctrine-orm-admin-bundle": "#stable",

KnpLabs / DoctrineBehaviors Translatable - currentLocale = null

Using the trait \Knp\DoctrineBehaviors\Model\Translatable\Translation inside an Entity, I see that the property currentLocale is never setted , so we always obtain the default locale ('en') in all the calls to $this->translate().
If I change this getDefaultLocale, all the translations are made correctly, so I think that is no problem with the fallback.
I tried debug the currentLocaleCallable. I see that if I put a "var_dump ($this->container->get('request'));" in the contructor of currentLocaleCallable, the request have a locale to null. And outside the request has the correct locale.It seems that container is not in the scope: request , i don't know how can I get it to work
I post an issue in github https://github.com/KnpLabs/DoctrineBehaviors/issues/71
EDITED
This service is defined in vendor/knplabs/doctrine-behaviors/config/orm-services.yml and is:
knp.doctrine_behaviors.reflection.class_analyzer:
class: "%knp.doctrine_behaviors.reflection.class_analyzer.class%"
public: false
knp.doctrine_behaviors.translatable_listener:
class: "%knp.doctrine_behaviors.translatable_listener.class%"
public: false
arguments:
- "#knp.doctrine_behaviors.reflection.class_analyzer"
- "%knp.doctrine_behaviors.reflection.is_recursive%"
- "#knp.doctrine_behaviors.translatable_listener.current_locale_callable"
tags:
- { name: doctrine.event_subscriber }
knp.doctrine_behaviors.translatable_listener.current_locale_callable:
class: "%knp.doctrine_behaviors.translatable_listener.current_locale_callable.class%"
arguments:
- "#service_container" # lazy request resolution
public: false
EDIT 2: My composer.json
"php": ">=5.3.3",
"symfony/symfony": "2.3.*",
"doctrine/orm": ">=2.2.3,<2.4-dev",
"doctrine/doctrine-bundle": "1.2.*",
"twig/extensions": "1.0.*",
"symfony/assetic-bundle": "2.3.*",
"symfony/swiftmailer-bundle": "2.3.*",
"symfony/monolog-bundle": "2.3.*",
"sensio/distribution-bundle": "2.3.*",
"sensio/framework-extra-bundle": "2.3.*",
"sensio/generator-bundle": "2.3.*",
"incenteev/composer-parameter-handler": "~2.0",
"friendsofsymfony/user-bundle": "1.3.*",
"avalanche123/imagine-bundle": "v2.1",
"raulfraile/ladybug-bundle": "~1.0",
"genemu/form-bundle": "2.2.*",
"friendsofsymfony/rest-bundle": "0.12.0",
"stof/doctrine-extensions-bundle": "dev-master",
"sonata-project/admin-bundle": "dev-master",
"a2lix/translation-form-bundle": "1.*#dev",
"sonata-project/user-bundle": "dev-master",
"psliwa/pdf-bundle": "dev-master",
"jms/serializer-bundle": "dev-master",
"jms/di-extra-bundle": "dev-master",
"knplabs/doctrine-behaviors": "dev-master",
"sonata-project/doctrine-orm-admin-bundle": "dev-master",
"knplabs/knp-paginator-bundle": "dev-master",
"friendsofsymfony/jsrouting-bundle": "~1.1",
"zendframework/zend-validator": ">=2.0.0-rc2",
"zendframework/zend-barcode": ">=2.0.0-rc2"

Can i use orm entites with SonataDoctrinePhpcrAdminBundle?

How to start using orm enites with Sonata-Admin-bundle if alredy use SonataDoctrinePhpcrAdminBundle ?
This is possible ?
my composer.json
"minimum-stability": "dev",
"require": {
"php": ">=5.3.3",
"symfony/symfony": "2.2.*",
"twig/extensions": "1.0.*",
"symfony/monolog-bundle": "2.2.*",
"symfony/assetic-bundle": "2.1.*",
"sensio/distribution-bundle": "2.2.*",
"symfony-cmf/symfony-cmf": "dev-master",
"symfony-cmf/simple-cms-bundle": "1.0.*",
"symfony-cmf/create-bundle": "1.0.*",
"jackalope/jackalope-jackrabbit": "1.0.*",
"jackalope/jackalope-doctrine-dbal":"dev-master",
"doctrine/phpcr-bundle": "1.0.*",
"doctrine/phpcr-odm": "1.0.*",
"doctrine/doctrine-bundle": "1.2.*",
"doctrine/doctrine-fixtures-bundle": "dev-master",
"liip/functional-test-bundle": "dev-master",
"lunetics/locale-bundle": "dev-master",
"liip/doctrine-cache-bundle": "dev-master",
"sonata-project/doctrine-phpcr-admin-bundle": "1.0.*",
"symfony/twig-bridge": "2.2.*",
"jms/security-extra-bundle": "1.4.*",
"symfony-cmf/content-bundle": "1.0.*#dev",
"symfony-cmf/routing-extra-bundle": "1.0.*#dev",
"symfony-cmf/routing": "1.1.*#dev",
"symfony-cmf/routing-bundle": "1.1.*#dev",
"sonata-project/easy-extends-bundle": "2.1.*#dev",
"sonata-project/block-bundle": "2.2.*#dev",
"egeloen/ckeditor-bundle": "2.*",
"sensio/generator-bundle": "2.2.*"
},
I spent a few days in the search for solutions and fixing most errors.
Some one use Symfony-cmf in production ?Or symfony-cmf not ready now for this segment ?
Will there be a better solution to use only Sonata bundles ?
You should use the SonataDoctrineORMAdminBundle for your entities. The SonataDoctrinePhpcrAdminBundle will only work with documents managed by the doctrine-phpcrodm project.
It is very much possible to use the two bundles and corresponding backend system side by side so you can mix orm and phpcrodm admins in the same application.

Resources