Merge pull request #2727 from rchavik/2.5-remove-acl-trigger-errors

Log errors instead of calling trigger_error()
This commit is contained in:
Mark Story 2014-01-29 06:31:23 -08:00
commit b0533f32ad
2 changed files with 8 additions and 16 deletions

View file

@ -83,7 +83,7 @@ class Permission extends AppModel {
$acoPath = $this->Aco->node($aco); $acoPath = $this->Aco->node($aco);
if (!$aroPath || !$acoPath) { if (!$aroPath || !$acoPath) {
trigger_error(__d('cake_dev', $this->log(__d('cake_dev',
"%s - Failed ARO/ACO node lookup in permissions check. Node references:\nAro: %s\nAco: %s", "%s - Failed ARO/ACO node lookup in permissions check. Node references:\nAro: %s\nAco: %s",
'DbAcl::check()', 'DbAcl::check()',
print_r($aro, true), print_r($aro, true),
@ -94,7 +94,7 @@ class Permission extends AppModel {
} }
if (!$acoPath) { if (!$acoPath) {
trigger_error(__d('cake_dev', $this->log(__d('cake_dev',
"%s - Failed ACO node lookup in permissions check. Node references:\nAro: %s\nAco: %s", "%s - Failed ACO node lookup in permissions check. Node references:\nAro: %s\nAco: %s",
'DbAcl::check()', 'DbAcl::check()',
print_r($aro, true), print_r($aro, true),
@ -105,7 +105,7 @@ class Permission extends AppModel {
} }
if ($action !== '*' && !in_array('_' . $action, $permKeys)) { if ($action !== '*' && !in_array('_' . $action, $permKeys)) {
trigger_error(__d('cake_dev', "ACO permissions key %s does not exist in %s", $action, 'DbAcl::check()'), E_USER_NOTICE); $this->log(__d('cake_dev', "ACO permissions key %s does not exist in %s", $action, 'DbAcl::check()'), E_USER_NOTICE);
return false; return false;
} }
@ -176,7 +176,7 @@ class Permission extends AppModel {
$save = array(); $save = array();
if (!$perms) { if (!$perms) {
trigger_error(__d('cake_dev', '%s - Invalid node', 'DbAcl::allow()'), E_USER_WARNING); $this->log(__d('cake_dev', '%s - Invalid node', 'DbAcl::allow()'), E_USER_WARNING);
return false; return false;
} }
if (isset($perms[0])) { if (isset($perms[0])) {

View file

@ -256,7 +256,6 @@ class DbAclTest extends CakeTestCase {
/** /**
* testDbAclAllow method * testDbAclAllow method
* *
* @expectedException PHPUnit_Framework_Error_Warning
* @return void * @return void
*/ */
public function testAllow() { public function testAllow() {
@ -297,17 +296,16 @@ class DbAclTest extends CakeTestCase {
* @return void * @return void
*/ */
public function testAllowInvalidPermission() { public function testAllowInvalidPermission() {
$this->Acl->allow('Micheal', 'tpsReports', 'derp'); $this->assertFalse($this->Acl->allow('Micheal', 'tpsReports', 'derp'));
} }
/** /**
* testAllowInvalidNode method * testAllowInvalidNode method
* *
* @expectedException PHPUnit_Framework_Error_Warning
* @return void * @return void
*/ */
public function testAllowInvalidNode() { public function testAllowInvalidNode() {
$this->Acl->allow('Homer', 'tpsReports', 'create'); $this->assertFalse($this->Acl->allow('Homer', 'tpsReports', 'create'));
} }
/** /**
@ -333,7 +331,6 @@ class DbAclTest extends CakeTestCase {
/** /**
* testCheckInvalidNode method * testCheckInvalidNode method
* *
* @expectedException PHPUnit_Framework_Error_Warning
* @return void * @return void
*/ */
public function testCheckInvalidNode() { public function testCheckInvalidNode() {
@ -343,21 +340,19 @@ class DbAclTest extends CakeTestCase {
/** /**
* testCheckInvalidPermission method * testCheckInvalidPermission method
* *
* @expectedException PHPUnit_Framework_Error_Notice
* @return void * @return void
*/ */
public function testCheckInvalidPermission() { public function testCheckInvalidPermission() {
$this->Acl->check('Lumbergh', 'smash', 'foobar'); $this->assertFalse($this->Acl->check('Lumbergh', 'smash', 'foobar'));
} }
/** /**
* testCheckMissingPermission method * testCheckMissingPermission method
* *
* @expectedException PHPUnit_Framework_Error_Warning
* @return void * @return void
*/ */
public function testCheckMissingPermission() { public function testCheckMissingPermission() {
$this->Acl->check('users', 'NonExistent', 'read'); $this->assertFalse($this->Acl->check('users', 'NonExistent', 'read'));
} }
/** /**
@ -380,7 +375,6 @@ class DbAclTest extends CakeTestCase {
/** /**
* testDbAclDeny method * testDbAclDeny method
* *
* @expectedException PHPUnit_Framework_Error_Warning
* @return void * @return void
*/ */
public function testDeny() { public function testDeny() {
@ -450,7 +444,6 @@ class DbAclTest extends CakeTestCase {
/** /**
* testDbGrant method * testDbGrant method
* *
* @expectedException PHPUnit_Framework_Error_Warning
* @return void * @return void
*/ */
public function testGrant() { public function testGrant() {
@ -471,7 +464,6 @@ class DbAclTest extends CakeTestCase {
/** /**
* testDbRevoke method * testDbRevoke method
* *
* @expectedException PHPUnit_Framework_Error_Warning
* @return void * @return void
*/ */
public function testRevoke() { public function testRevoke() {