Giter Site home page Giter Site logo

Comments (5)

cdvrooman avatar cdvrooman commented on July 19, 2024

I did some poking around in /cake/libs/model/model.php and in the _findList() function, I found this:
if (!isset($query['recursive']) || $query['recursive'] === null) {
$query['recursive'] = -1;
}
Which could definitely be screwing things up if 'recursive' is not being explicitly set by Permissionable', perhaps only when the find is of the 'list' variety?

from permissionable.

cdvrooman avatar cdvrooman commented on July 19, 2024

On a related note, I'm running into a similar problem when trying to save something to the Group table, where first the ability to write to the table is verified. The SQL is appearing as:
SELECT COUNT() AS count, GroupPermission. FROM groups AS Group WHERE Group.name = 'Root' AND Group.id != ' ... uuid ...'

In \models\behaviors\permissionable.php I tried adding
'recursive' => 1
to hasPermissions() here:
$perm = $Model->{$alias}->find('count', array( ... ));
but it didn't have any effect.

I also tried modifying $queryData['recursive'] directly in the beforeFind() function, but that caused my browser to be unable to resolve the page.

from permissionable.

cdvrooman avatar cdvrooman commented on July 19, 2024

Two alternatives are:

  1. Adding 'permissionable' => false to the find parameters, i.e.:
    $users = $this->User->find('list', array(
    'permissionable' => false,
    'conditions' => array('User.name <>' => 'guest')
    ));
    or, using find('all') but specifying the fields, i.e.
    $users = $this->User->find('all', array(
    'recursive' => -1,
    'conditions' => array('User.name <>' => 'guest'),
    'fields' => array('User.id', 'User.name')
    ));

from permissionable.

cdvrooman avatar cdvrooman commented on July 19, 2024

Of course in the second case you would have to use Set::extract() or something similar on the results to leave only the 'user_id' => 'user_name'.

from permissionable.

afrance avatar afrance commented on July 19, 2024

Any real solution to this? The same issue crops up when attempting to use the tree behavior.

from permissionable.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.