Skip to content

Commit

Permalink
Prevent "Cannot declare class error because name already in use" erro…
Browse files Browse the repository at this point in the history
…r after manually adding namespace to site actions that are already previously compiled.
  • Loading branch information
adrianbj committed Feb 22, 2024
1 parent c4e9f2d commit 740e174
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions ProcessAdminActions.module.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static function getModuleInfo() {
'title' => 'Admin Actions',
'summary' => 'Control panel for running various admin actions',
'author' => 'Adrian Jones',
'version' => '0.9.3',
'version' => '0.9.4',
'singular' => true,
'autoload' => false,
'icon' => 'wrench',
Expand Down Expand Up @@ -540,8 +540,11 @@ private function includeAndInstantiate($actionName) {
else {
$nsClass = $ns . '\\' . $actionName;
}
$this->wire('files')->includeOnce($actionPath);
$this->action = new $nsClass();

if(!class_exists($nsClass)) {
$this->wire('files')->includeOnce($actionPath);
$this->action = new $nsClass();
}
}


Expand Down

2 comments on commit 740e174

@adrianbj
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Toutouwai - just pinging you to let you know that I found another change was needed. New version has been released.

@Toutouwai
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, thanks!

Please sign in to comment.