Missing attributes for model User
Hey,
I just ran composer update and for the last commit it seems some attributes were missing on User model class
Updating friendsofsymfony/user-bundle dev-master (3015f09 => 507ae09)
/**
* @var bool
*/
protected $locked;
/**
* @var bool
*/
protected $expired;
/**
* @var \DateTime
*/
protected $expiresAt;
/**
* @var bool
*/
protected $credentialsExpired;
/**
* @var \DateTime
*/
protected $credentialsExpireAt;
Has someone the same problem?
Hi, what error did you get? The expired and credentialsExpired field have been removed from beta1, see https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Changelog.md
I got ReflectionException.
After create the issue I've tried to update Symfony to v3.2 and that lead to update again FosUserBundle
Updating friendsofsymfony/user-bundle dev-master (507ae09 => a38940d)
Same error came out. One ReflectionException for each missing property until I added them to the file.
[ReflectionException]
Property FOS\UserBundle\Model\User::$locked does not exist
Try removing the cache and run composer again.
I've tried that. I manually removed the /var/cache folder and running composer update again
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache
[ReflectionException]
Property FOS\UserBundle\Model\User::$locked does not exist
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-update-cmd event terminated with an exception
[RuntimeException]
An error occurred when executing the "'cache:clear --no-warmup'" command:
[ReflectionException]
Property FOS\UserBundle\Model\User::$locked does not exist
It could be some other dependency or something else?
I have the same problem, some fields are deleted as locked for example.
Why ? And why there is not stable branch ? We use the master as reference for the symfony versions 2.7+
Why ? And why there is not stable branch ? We use the master as reference for the symfony versions 2.7+
There were several discussion why there is not stable branch. The team is working very hard on a stable version. Using the dev-master for production is always a bad idea. Don't do this, ever!
I understand that the team is working hard on a stable version, but in the documentation we can see that they give us this step 1 :
Step 1: Download FOSUserBundle using composer¶ Require the bundle with composer:
$ composer require friendsofsymfony/user-bundle "~2.0@dev"
And they also said that " This version of the bundle requires Symfony 2.7+. If you are using an older Symfony version, please use the 1.3.x releases of the bundle. "
So, ok if you are in under 2.7 you can use the 1.3.x but if you are in 2.7+ you have to use the dev branch.
We are now in 3.0+ and there no stable branch, since many years. Does the team need help to do this quickly ? Why the V2 is always in development ? Well btw, there are some attributes left, and we don't have any other choice to use the v2 dev branch of this bundle.
@christophe-44-27 we have always chance to keep a stable version for our application. A composer update, in my opinion, should be done like a "test approach" and ensure that no errors exist before send to production like @core23 said.
Regarding this issue, I think FOS team can check if they have this error. If some information is need please ping :) And any help need as @christophe-44-27 suggested can be also provided!
Well you can always use the latest beta release instead of relying on master.
https://github.com/FriendsOfSymfony/FOSUserBundle/releases/tag/v2.0.0-beta1
If you use the APC cache for Doctrine mapping, you need to clear the APC cache, otherwise the cache will still be trying to reference the removed fields until you clear it.
@rudirocha Did you try clearing the APC cache?
I'm not able to try it now. But later i'll do it and post the result. I configured Redis to cache some doctrine and session stuff.
And it seems to be cache problem. After flush all REDIS data related to application, composer update had no problem neither the application running. This can be closed! Thanks guys
Got a similar problem using APCu. I've enabled APCu by:
- Adding few lines to production configs:
# app/config/config_prod.yml
framework:
validation:
cache: validator.mapping.cache.doctrine.apc
doctrine:
orm:
metadata_cache_driver: apcu
result_cache_driver: apcu
query_cache_driver: apcu
- Enabling ApcClassLoader in
web/app.php:
// Enable APC for autoloading to improve performance.
// You should change the ApcClassLoader first argument to a unique prefix
// in order to prevent cache key conflicts with other applications
// also using APC.
$apcLoader = new Symfony\Component\ClassLoader\ApcClassLoader(sha1(__FILE__), $loader);
$loader->unregister();
$apcLoader->register(true);
After that I've got error in production logs:
[2016-12-08 14:41:11] request.CRITICAL: Uncaught PHP Exception ReflectionException: "Property ?FOS\UserBundle\Model\User::$locked does not exist" at /home/cdn/www/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/RuntimeReflectionService.php line 80 {"exception":"[object] (ReflectionException(code: 0): Property FOS\UserBundle\Model\User::$locked does not exist at /home/cdn/www/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/RuntimeReflectionService.php:80)"} []
Had to comment out cache driver configs to get rid of this error. However I believe it's rather a hack than a fix.
Regular cache:clear command does not solve the issue for me. @XWB How do you suggest to clear APCu cache?
you need to clear you doctrine mapping cache when upgrading the bundle to beta1.
And when using APCu, it has a separate cache per SAPI. So the command will not clear the cache used by php-fpm. You need to clear it as well. The easiest way to clear APCu for php-fpm is to restart php-fpm.
@icamys I usually clear the APC cache by reloading Apache.
yeah, which is the equivalent of restarting php-fpm when using mod_php rather than php-fpm
Why those properties were removed anyway ?
Because the bundle didn't use them.
And because applications really wanting to use the features need to write some custom code anyway, so it is better if they implement the method in a way fitting their needs exactly instead of trying to fit their use case into the storage structure provided by FOSUserBundle arbitrarily.