kohana / orm

Kohana ORM
159 stars 108 forks source link

Allow ORM::has() to check a single far key #100

Closed SaschaGalley closed 10 years ago

SaschaGalley commented 10 years ago
return $count === count($far_keys);

Any ORM model or a single primary key (int) will always fail this comparison.

Added further checks to return FALSE if far_keys is an instance of ORM and not loaded and build an array if $far_keys was not an array.

kemo commented 10 years ago

I reverted this change because ORM::count_relations() already supports ORM parameters.

SaschaGalley commented 10 years ago

The problem I encountered was that Auth::login() wasn't working properly. In line 90:

if ($user->has('roles', ORM::factory('Role', array('name' => 'login'))) AND $user->password === $password)

Will do the following:

// return 1 = 0, because count(ORM) will return 0 although it's loaded
var_dump(count($far_keys)); // dumps int(0)
return $count === count($far_keys);