Skip to content

Commit

Permalink
A fix to prevent allowedActions() from failing with a warning when th…
Browse files Browse the repository at this point in the history
…e main class doesn't have an allowed_actions array, but one or more of its extensions does.


Background:
I created a DataObjectDecorator for a form object that added an action. However, it refused to execute the action, giving an "action not allowed" error. Adding an allowed_actions array to the decorator was the only option, but caused RequestHandler::allowedActions() to fail with the following error: "Argument silverstripe#1 is not an array". This small patch eliminates the error.

NOTES: 
- The reason why the new code is where it is, is so that the function still returns nothing (not even an empty array) if no actions are found
- The master branch appears to also have the same defect, so it's worth checking that too, and fixing it if necessary
  • Loading branch information
hdrlab committed May 9, 2012
1 parent 9bf3ae9 commit c18fa29
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions core/control/RequestHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ public function allowedActions() {

foreach($this->extension_instances as $extension) {
if($extensionActions = Object::get_static(get_class($extension), 'allowed_actions')) {
if(!$actions)
{
$actions = array();
}
$actions = array_merge($actions, $extensionActions);
}
}
Expand Down

0 comments on commit c18fa29

Please sign in to comment.