Closed ryanshowers closed 10 years ago
Are you using it with the full Orchestra Platform, or just as Laravel component?
Full Orchestra Platform, using composer instructions here - http://orchestraplatform.com/docs/2.1/installation#install-orchestra-platform
I wasn't able to replicate the issue on a fresh installation. The ACL is being added during installation process https://github.com/orchestral/foundation/blob/2.1/src/Orchestra/Foundation/Installation/Installer.php#L97-L130 which hasn't changed in awhile.
Could you try to re-install (drop the database) and test again.
Hmmm. I dropped the tables and completed the installation process several times, including removing the files and running the composer command.
Here's my value for acl_orchestra:
a:5:{s:4:"name";s:18:"Orchestra Platform";s:5:"theme";a:2:{s:8:"frontend";s:7:"default";s:7:"backend";s:7:"default";}s:7:"actions";a:0:{}s:5:"roles";a:1:{i:0;s:5:"guest";}s:3:"acl";a:0:{}}
Can you also send my your app/storage/logs/laravel.log
file.
Sure thing.
can't find anything strange. PHP version and MySQL version? And OS.
MySQL: 5.1.71 PHP: 5.4.15 OSX 10.9
I went ahead and manually inserted the serialized values. I wish I could help debug but I'm just starting with Laravel and Orchestra. Thanks for your time and let me know if you need anything else.
I can't find anything that could cause this, but at the same time I would like to avoid such issue.
If you're free. Could you debug https://github.com/orchestral/auth/blob/master/src/Orchestra/Auth/Acl/Container.php#L75 and remove and $memory !== $this->memory
.
Removed from line 75, dropped tables and reinstalled. Issue remains.
There no issue with orchestra/memory as other configuration are properly saved. The only missing here are https://github.com/orchestral/foundation/blob/master/src/Orchestra/Foundation/Installation/Installer.php#L130 which attach memory to ACL action. Does moving line 130 to between line 123 and line 124 solve it?
Unfortunately, no.
I think that there may be a problem with MySQL Databases. have you checked this problem on a latest MySQL Version? if that problem goes off. you know the reason.
Technically 5.1.71 was released last August http://dev.mysql.com/doc/relnotes/mysql/5.1/en/news-5-1-71.html.
Upgraded port to mysql 5.1.72 - no change.
ACL is added to $memory during admin/install/create - https://gist.github.com/ryanshowers/8aa5cbdf49999816b78a
However, I interrupted /admin/install/done and noticed the value for "site" is used for "acl_orchestra" - https://gist.github.com/ryanshowers/06ef7f9290f07fe2dfdf
It seems the acl value isn't stored properly in the database during admin/install/create. Am I on the right track here?
Am I on the right track here?
Yeah we're getting somewhere. Can you try the following:
composer update
I'm been doing some small refactor on auth, memory and foundation while trying to solve this, it might be possible it's already fixed.
// We should also create a basic ACL for Orchestra Platform, since
// the basic roles is create using Fluent Query Builder we need
// to manually insert the roles.
$acl = $this->app['orchestra.acl']->make('orchestra');
$acl->attach($memory);
$acl->actions()->attach($actions);
$acl->roles()->attach(array_values($roles));
$acl->allow($roles[$admin], $actions);
$this->app['events']->fire('orchestra.install: acl', array($acl));
$this->app['orchestra.memory']->finish(); // this will force memory to shutdown and save the content to db.
No luck. After installation "acl_orchestra" = a:3:{s:3:"acl";a:0:{}s:7:"actions";a:0:{}s:5:"roles";a:1:{i:0;s:5:"guest";}}
What do you get if you do
// We should also create a basic ACL for Orchestra Platform, since
// the basic roles is create using Fluent Query Builder we need
// to manually insert the roles.
$acl = $this->app['orchestra.acl']->make('orchestra');
$acl->attach($memory);
$acl->actions()->attach($actions);
$acl->roles()->attach(array_values($roles));
$acl->allow($roles[$admin], $actions);
$this->app['events']->fire('orchestra.install: acl', array($acl));
$this->app['orchestra.memory']->finish(); // this will force memory to shutdown and save the content to db.
$memory = $this->app['orchestra.memory']->make(); // reload a fresh copy.
var_dump($memory->all());
exit;
Here's the dump...
array(3) {
["site"]=>
array(2) {
["name"]=>
string(18) "Orchestra Platform"
["theme"]=>
array(2) {
["frontend"]=>
string(7) "default"
["backend"]=>
string(7) "default"
}
}
["email"]=>
array(9) {
["driver"]=>
string(4) "mail"
["host"]=>
string(16) "smtp.mailgun.org"
["port"]=>
int(587)
["from"]=>
array(2) {
["name"]=>
string(18) "Orchestra Platform"
["address"]=>
string(13) "test@test.com"
}
["encryption"]=>
string(3) "tls"
["username"]=>
NULL
["password"]=>
NULL
["sendmail"]=>
string(22) "/usr/sbin/sendmail -bs"
["pretend"]=>
bool(false)
}
["acl_orchestra"]=>
array(2) {
["name"]=>
string(18) "Orchestra Platform"
["theme"]=>
array(2) {
["frontend"]=>
string(7) "default"
["backend"]=>
string(7) "default"
}
}
}
I've got the same problem. Asked for the action that is being searched and the result was "manage_users". Does that make any sense?
@schaafie can you share the code, or error page.
@ryanshowers Another test.
use Illuminate\Support\Fluent;
use Orchestra\Support\Str;
Route::get('foo', function () {
$items1 = [];
$items2 = [];
$fixtures = [
new Fluent(['id' => 1, 'name' => 'site', 'value' => 'a:2:{s:4:"name";s:18:"Orchestra Platform";s:5:"theme";a:2:{s:8:"frontend";s:7:"default";s:7:"backend";s:7:"default";}}']),
new Fluent(['id' => 2, 'name' => 'email', 'value' => 'a:9:{s:6:"driver";s:4:"mail";s:4:"host";s:16:"smtp.mailgun.org";s:4:"port";i:587;s:4:"from";a:2:{s:4:"name";s:18:"Orchestra Platform";s:7:"address";s:19:"crynobone@gmail.com";}s:10:"encryption";s:3:"tls";s:8:"username";N;s:8:"password";N;s:8:"sendmail";s:22:"/usr/sbin/sendmail -bs";s:7:"pretend";b:0;}']),
new Fluent(['id' => 3, 'name' => 'acl_orchestra', 'value' => 'a:3:{s:7:"actions";a:2:{i:0;s:16:"manage-orchestra";i:1;s:12:"manage-users";}s:5:"roles";a:3:{i:0;s:5:"guest";i:1;s:13:"administrator";i:2;s:6:"member";}s:3:"acl";a:2:{s:3:"1:0";b:1;s:3:"1:1";b:1;}}']),
];
foreach ($fixtures as $fixture) {
$value = Str::streamGetContents($fixture->value);
array_set($items1, $fixture->name, unserialize($value));
$items2 = array_add($items2, $fixture->name, unserialize($value));
}
var_dump($items1);
var_dump($items2);
exit;
});
@crynobone where would I place that code? Apologies again, but I'm still learning this framework.
@ryanshowers in app/routes.php
And then hit the GET foo
route from your browser.
I'm considering the usage of array_set()
instead of array_add()
could have cause the issue on some environment. Above code return same result on my end.
array(3) {
["site"]=>
array(2) {
["name"]=>
string(18) "Orchestra Platform"
["theme"]=>
array(2) {
["frontend"]=>
string(7) "default"
["backend"]=>
string(7) "default"
}
}
["email"]=>
array(9) {
["driver"]=>
string(4) "mail"
["host"]=>
string(16) "smtp.mailgun.org"
["port"]=>
int(587)
["from"]=>
array(2) {
["name"]=>
string(18) "Orchestra Platform"
["address"]=>
string(19) "crynobone@gmail.com"
}
["encryption"]=>
string(3) "tls"
["username"]=>
NULL
["password"]=>
NULL
["sendmail"]=>
string(22) "/usr/sbin/sendmail -bs"
["pretend"]=>
bool(false)
}
["acl_orchestra"]=>
array(3) {
["actions"]=>
array(2) {
[0]=>
string(16) "manage-orchestra"
[1]=>
string(12) "manage-users"
}
["roles"]=>
array(3) {
[0]=>
string(5) "guest"
[1]=>
string(13) "administrator"
[2]=>
string(6) "member"
}
["acl"]=>
array(2) {
["1:0"]=>
bool(true)
["1:1"]=>
bool(true)
}
}
}
array(3) {
["site"]=>
array(2) {
["name"]=>
string(18) "Orchestra Platform"
["theme"]=>
array(2) {
["frontend"]=>
string(7) "default"
["backend"]=>
string(7) "default"
}
}
["email"]=>
array(9) {
["driver"]=>
string(4) "mail"
["host"]=>
string(16) "smtp.mailgun.org"
["port"]=>
int(587)
["from"]=>
array(2) {
["name"]=>
string(18) "Orchestra Platform"
["address"]=>
string(19) "crynobone@gmail.com"
}
["encryption"]=>
string(3) "tls"
["username"]=>
NULL
["password"]=>
NULL
["sendmail"]=>
string(22) "/usr/sbin/sendmail -bs"
["pretend"]=>
bool(false)
}
["acl_orchestra"]=>
array(3) {
["actions"]=>
array(2) {
[0]=>
string(16) "manage-orchestra"
[1]=>
string(12) "manage-users"
}
["roles"]=>
array(3) {
[0]=>
string(5) "guest"
[1]=>
string(13) "administrator"
[2]=>
string(6) "member"
}
["acl"]=>
array(2) {
["1:0"]=>
bool(true)
["1:1"]=>
bool(true)
}
}
}
false again. :(
I'll ramble on a bit in hopes that this will spark something for you.....
I spent some time today trying to debug this. It seems that $app['orchestra.memory']->finish(); is called 3 times. The value for acl_orchestra is updated each time here - https://github.com/orchestral/memory/blob/master/src/Orchestra/Memory/Abstractable/DatabaseHandler.php#L53
The first time, it stores...
a:2:{s:4:"name";s:18:"Orchestra Platform";s:5:"theme";a:2:{s:8:"frontend";s:7:"default";s:7:"backend";s:7:"default";}}
the second time it stores the correct ACL values
the third loop stores..
a:3:{s:3:"acl";a:0:{}s:7:"actions";a:0:{}s:5:"roles";a:1:{i:0;s:5:"guest";}}
Error page is included in the document attached. This is what my log tells me:
[2014-01-17 08:35:31] production.INFO: manage-users [] []
[2014-01-17 08:35:31] production.ERROR: exception 'InvalidArgumentException' with message 'Unable to verify unknown action .' in F:\root\orchestra\vendor\orchestra\auth\src\Orchestra\Auth\Acl\Container.php:172
Stack trace:
And this is what I did to F:\root\orchestra\vendor\orchestra\auth\src\Orchestra\Auth\Acl\Container.php
public function check($roles, $action)
{
Log::info($action);
$action = $this->actions->search($action);
if (is_null($action)) {
throw new InvalidArgumentException("Unable to verify unknown action {$action}.");
}
foreach ((array) $roles as $role) {
$role = $this->roles->search($role);
// array_search() will return false when no key is found based
// on given haystack, therefore we should just ignore and
// continue to the next role.
if (! is_null($role) and isset($this->acl[$role.':'.$action])) {
return $this->acl[$role.':'.$action];
}
}
return false;
}
Cheers,
Pieter.
Van: Mior Muhammad Zaki [mailto:notifications@github.com] Verzonden: donderdag 16 januari 2014 20:46 Aan: orchestral/auth CC: schaafie Onderwerp: Re: [auth] Unknown Action Exception - Fresh Installation (#25)
@schaafie https://github.com/schaafie can you share the code, or error page.
— Reply to this email directly or view it on GitHub https://github.com/orchestral/auth/issues/25#issuecomment-32522083 . https://github.com/notifications/beacon/6422940__eyJzY29wZSI6Ik5ld3NpZXM6QmVhY29uIiwiZXhwaXJlcyI6MTcwNTQzNDM1OCwiZGF0YSI6eyJpZCI6MjM1NDk2MjV9fQ==--beb5830b8798d32862aefc6f3f68047f85a84e68.gif
More findings:
https://github.com/orchestral/memory/blob/master/src/Orchestra/Memory/FluentMemoryHandler.php#L61 generates the following query:
update `orchestra_options` set `value` = ? where `id` is null
$id = $this->getKeyId($key);
$id is NULL and $this->keyMap is empty
Not sure if $this->keyMap should have values, but this fixes the installation issue I'm having...
if (!is_null($id)) {
$this->resolver()->where('id', '=', $id)->update(array(
'value' => $value,
));
}
That fixed it. Thanks
I'll have tagged all version to a stable version. Should be able to swap with "stable" minimum stability now. Thanks for the report and sorry for the trouble.
Wasn't sure where to post this. Followed the composer installation instructions for v. 2.1.x and receive InvalidArgumentException Unable to verify unknown action . Looks like manager-users and manage-orchestra actions are not inserted during installation.