Closed ronindesign closed 6 years ago
When trying to save User model, I'm getting fatal exception.
Environment Phalcon: v3.2 UserPlugin: v3.0.x PHP: v7.2.x Server: Apache / PHP-FPM
Code triggering error:
$user = User::findFirst($this->auth->getUserId()); $user->assign( [ 'first_name' => $this->request->getPost('first_name'), 'last_name' => $this->request->getPost('last_name'), 'modified' => date('Y-m-d H:i:s') ] ); $user->save();
This code snippet is responsible lib/Models/User/User.php:
lib/Models/User/User.php
/** * Validations and business logic. */ public function validation() { $this->validate(new Uniqueness( array( 'field' => 'email', 'message' => 'The email is already registered', ) )); return true !== $this->validationHasFailed(); }
Exception
( ! ) Deprecated: Function Phalcon\Mvc\Model\Validator::__construct() is deprecated in /var/www/project/vendor/crada/phalcon-user-plugin/lib/Models/User/User.php on line 871 Call Stack # Time Memory Function Location 1 0.0000 403648 {main}( ) .../index.php:0 2 0.0008 434472 handle ( ) .../index.php:42 3 0.0011 457912 dispatch ( ) .../index.php:42 4 0.0014 464872 callActionMethod ( ) .../index.php:42 5 0.0014 465256 UserController->registerAction( ) .../index.php:42 6 0.0205 594832 save ( ) .../UserController.php:137 7 0.0206 595336 _preSave ( ) .../UserController.php:137 8 0.0208 598592 fireEventCancel ( ) .../UserController.php:137 9 0.0208 599024 Phalcon\UserPlugin\Models\User\User->validation( ) .../UserController.php:137 ( ! ) Fatal error: Uncaught TypeError: Argument 1 passed to Phalcon\Mvc\Model::validate() must implement interface Phalcon\ValidationInterface, instance of Phalcon\Mvc\Model\Validator\Uniqueness given in /var/www/project/vendor/crada/phalcon-user-plugin/lib/Models/User/User.php on line 871 ( ! ) TypeError: Argument 1 passed to Phalcon\Mvc\Model::validate() must implement interface Phalcon\ValidationInterface, instance of Phalcon\Mvc\Model\Validator\Uniqueness given in /var/www/project/vendor/crada/phalcon-user-plugin/lib/Models/User/User.php on line 871 Call Stack # Time Memory Function Location 1 0.0000 403648 {main}( ) .../index.php:0 2 0.0008 434472 handle ( ) .../index.php:42 3 0.0011 457912 dispatch ( ) .../index.php:42 4 0.0014 464872 callActionMethod ( ) .../index.php:42 5 0.0014 465256 UserController->registerAction( ) .../index.php:42 6 0.0205 594832 save ( ) .../UserController.php:137 7 0.0206 595336 _preSave ( ) .../UserController.php:137 8 0.0208 598592 fireEventCancel ( ) .../UserController.php:137 9 0.0208 599024 Phalcon\UserPlugin\Models\User\User->validation( ) .../UserController.php:137
When trying to save User model, I'm getting fatal exception.
Environment Phalcon: v3.2 UserPlugin: v3.0.x PHP: v7.2.x Server: Apache / PHP-FPM
Code triggering error:
This code snippet is responsible
lib/Models/User/User.php
:Exception