3

I recently update lithium library and I have this problem. I get this error:

RuntimeException

Deprecated `app\models\StoreCategories::__init()` method, needs to be called it manually.

Source

/works/minhna/public_html/CMP/V0/libraries/lithium/core/Libraries.php: 505

500 
 501        if ($path && include $path) { 
 502            static::$_cachedPaths[$class] = $path; 
 503            if (method_exists($class, '__init')) { 
 504                $msg = "Deprecated `{$class}::__init()` method, needs to be called it manually."; 
 505                throw new RuntimeException($msg); 
 506            } 
 507        } elseif ($require) { 
 508            throw new RuntimeException("Failed to load class `{$class}` from path `{$path}`."); 
 509        } 
 510    }

In the StoreCategories model, I have a simple function

public static function __init(array $options = array()){
    static::config($options);
    static::applyFilter('save', function ($self, $params, $chain) {
        if(!$params['entity']->_id){
            //set created date
            $params['entity']->created = strtotime(gmdate('Y-m-d H:i:s'));
        }
    }
}

I use composer and in the boostrap libraries.php, I load the li3_socialauth library:

/**
 * load the socialauth library
 */
Libraries::add('li3_socialauth');
// Add the composer autoloader if not already done
require_once(LITHIUM_LIBRARY_PATH . '/autoload.php') ;

Thank you in advance.

Minh Nguyen
  • 490
  • 1
  • 3
  • 8

1 Answers1

2

Lithium got rid of __init() in static objects, see this commit.

byte255
  • 936
  • 5
  • 8
  • Use your code, I have another problem: PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 523800 bytes) in /works/minhna/public_html/CMP/V0/libraries/lithium/data/Model.php on line 17 – Minh Nguyen Jan 11 '14 at 18:02
  • I got it working by remove the __init function and add call the applyFilter below the model class defination. – Minh Nguyen Jan 11 '14 at 18:04