开发者

CakePHP - Including ACL component gives fatal error: ConnectionManager::getDataSource - Non-existent data source

I'm trying to figure out ACL, and so I'm trying to work through the tutorial in the book (Cake 1.3, by the way).

I've created the database tables (aros,acos,aros_acos). As soon as I try to include the Acl component in my AppController, however, I get a fatal error when I try to access any page:

Fatal Error (256): ConnectionManager::getDataSource - Non-existent data source [CORE/cake/libs/model/connection_manager.php, line 102]

In my AppController:

    public $components = array('Auth','Session','RequestHandler','Acl');

Removing Acl from the components array makes ever开发者_开发问答ything work again.

The errors disappear when I comment out some code in my AppController. Here is the code - the lines commented out are the culprits. AppModel::slugList() is a custom function that just does a find query based on a slug. It works fine, at least until Acl is included.

        if ($this->modelClass != 'Country'){
            $this->loadModel('Country');
        }
        if ($this->modelClass != 'Category'){
            $this->loadModel('Category');
        }
        $this->Session->write('Country',1);
        $this->Session->write('City',1);
        $_countryId = $this->Session->read('Country');
        //$_countries = $this->Country->slugList();
        $_cityId = $this->Session->read('City');
        //$_cities = $this->Country->City->slugList();

Edit - also, three notices appear:

Notice (8): Trying to get property of non-object [CORE/cake/libs/model/datasources/dbo_source.php, line 813]
Notice (8): Trying to get property of non-object [CORE/cake/libs/model/datasources/dbo_source.php, line 838]
Notice (8): Trying to get property of non-object [CORE/cake/libs/model/datasources/dbo_source.php, line 841]


This error is caused by an inconsistency between your models and/or the database table structure. The key to debugging it is the set of notices. Inserting a var_dump statement on dbo_source.php::line 813 will give you a hint as to where your break is located. Example:

foreach ($model->{$type} as $assoc => $assocData) {
    $linkModel =& $model->{$assoc};
    $external = isset($assocData['external']);

    var_dump($model->name, $assoc);
    if ($model->useDbConfig == $linkModel->useDbConfig) {
        if (true === $this->generateAssociationQuery($model, $linkModel, $type, $assoc, $assocData, $queryData, $external, $null)) {
            $linkedModels[$type . '/' . $assoc] = true;
        }
    }
}

In my case, I had a model defined for a database table I had forgotten to create.


Well, I had a model called "Permission" that my model "Role" that actsAs an Acl requester was related to. This was the problem. I guess the Acl component uses a class with this name somewhere?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜