Welcome Guest, Not a member yet? Register   Sign In
Indirect modification of overloaded property User::$_ci_scaffolding has no effect Filename: libraries/Model.php
#1

[eluser]johnmerlino[/eluser]
Hey all,

I had a similar error to this which I posted here before:

A PHP Error was encountered

Severity: Notice

Message: Indirect modification of overloaded property User::$_ci_scaffolding has no effect

Filename: libraries/Model.php

Line Number: 69

Fatal error: Cannot assign by reference to overloaded object in /Users/jmerlino/Sites/hmlaw/system/libraries/Model.php on line 69


But this time it's telling me that it's in Model.php, which is part of codeigniter core code, so I am reluctant to modify it.

However, this error is thrown as soon as I load a model in the controller:

$this->load->model('user');


This is what the model looks like:

Code:
class User extends Model {
            private $_email;
            private $_password_salt;
            private $_encrypted_password;

            public function __construct($attributes=array()){  
                $this->email = (!empty($attributes)) ? $attributes['email'] : null;
                $this->password = (!empty($attributes)) ? $attributes['password'] : null;
            
            }

            public function __get($property){
                $method = "get{$property}";
                if ( method_exists($this, $method)){
                    return $this->$method();
                }
            }

            public function __set($property,$value){
                $method = "set{$property}";
                if(method_exists($this, $method)){
                    return $this->$method( $value );
                }
            }

            public function setEmail($email){
                if ( ! is_null( $email ) ) {
                    $this->_email = $email;
                }
                return null;
            }

            public function getEmail(){
                return $this->_email;
            }
            
            private static function randomize(){
               $chars = array_merge(range("a","z"),range("A","Z"),range("0","9"));
               shuffle($chars);
               return implode('',array_slice($chars,0,10));
            }

            private static function setPassword_salt($salt){
                $this->_password_salt = $salt;
            }

            public function getPassword_salt(){
                return $this->_password_salt;
            }

            private static function encrypt($password,$salt){
                return sha1($password . $salt);
            }

            private static function setEncrypted_password($encrypted_password){
                $this->_encrypted_password = $encrypted_password;
            }

            public function getEncrypted_password(){
                return $_encrypted_password;
            }

            public function setPassword($password){
                if ( ! is_null( $password ) ) {
                    User::$password_salt = User::randomize();
                    User::$encrypted_password = User::encrypt($this->password,User::$password_salt);
                }
                return null;    
            }

            public function save(){
                $insert_data = array(
                    'email' => $this->email,
                    'password_salt' => $this->password_salt,
                    'encrypted_password' => $this->encrypted_password    
                );

                $created = $this->db->insert('users',$insert_data);
                return $created;
            }

            private static function authenticate($email, $password){
                $this->db->where('email',$email);
                $user = $this->db->get('users');
                if($user->num_rows == 1){
                    if(User::encrypt($password,$user->password_salt) == $user->encrypted_password){
                        return $user;
                    }
                }
                return null;
            }
    }

Any idea what might be the cause of this error?

Thanks for response.




Theme © iAndrew 2016 - Forum software by © MyBB