I have been digging using xdebug and found the following so far:
Permission/Key/Key->validate() :: Line 566
$pae = $this->getPermissionAccessObject();
if (is_object($pae)) {
$valid = $pae->validate();
} else {
$valid = false;
}
$this->getPermissionAccessObject()
returned null
, So $pae
is null
. This resulted in valid set to false
.
Digging deeper into this function:
public function getPermissionAccessObject()
{
$targ = $this->getPermissionAssignmentObject();
return $targ->getPermissionAccessObject();
}
$targ->permissionObjectToCheck
is an instance of Page
. Why??
Permission/Assignment/BlockAssignment :: Line 20
public function setPermissionObject($b)
{
$this->permissionObject = $b;
// if the area overrides the collection permissions explicitly (with a one on the override column) we check
if ($b->overrideAreaPermissions()) {
$this->permissionObjectToCheck = $b;
} else {
$a = $b->getBlockAreaObject();
if ($a instanceof SubArea && !$a->overrideCollectionPermissions()) {
$a = $a->getSubAreaParentPermissionsObject();
}
if (is_object($a)) {
....
} else {
$this->permissionObjectToCheck = Page::getCurrentPage();
}
}
}
$b->overrideAreaPermissions()
returns 0
. And in the end this causes this function to return Page::getCurrentPage();
.
Its strange this is 0 as in the GUI it saus the block overrides the permission.

Also, looking at the database the cbOverrideAreaPermissions for this block is set to 1. So why is overrideAreaPermissions()
returning 0?
Clicking the “Revert to Area Permissions” button in the GUI will change this value to 0, and clicking “Override Permissions” will set it to 1.
So why is it not loaded correctly in the Block
object?
So, to conclude…
In my controller I run:
$b = Block::getByID($this->bID);
The code in Block/Block.php
does not load cbOverrideAreaPermissions
from the database as no Collection
or Area
is provided.
As this is not set, the $b->overrideAreaPermissions()
will set it to 0:
public function overrideAreaPermissions()
{
if (!isset($this->cbOverrideAreaPermissions) || !$this->cbOverrideAreaPermissions) {
$this->cbOverrideAreaPermissions = 0;
}
return $this->cbOverrideAreaPermissions;
}
And thus the permissions will never work
So how to I get it to load this from the database? I could use something like below, but that does not work as I need to provided both the collection and area. How to I know the area?
$b = Block::getByID($this->bID);
$c = $b->getBlockCollectionObject();
$b = Block::getByID($this->bID, $c);
A temporary workaround could be:
$b = Block::getByID($this->bID);
$b->cbOverrideAreaPermissions=1;
$bp = new Permissions($b);
Now var_dump($bp->canMyCustomPermission());
will give int(1)
.