-
Notifications
You must be signed in to change notification settings - Fork 13
Update Application.php prevent double declaration #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: FRAMEWORK_6_0
Are you sure you want to change the base?
Update Application.php prevent double declaration #17
Conversation
Guard to avoid double declaration. rootcause still unclear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a guard to prevent the redeclaration of the Kronolith_Application class in case the file gets included multiple times through different autoloaders or paths.
- Adds a class existence check before class definition
- Includes explanatory comment about the purpose of the guard
- Uses early return to prevent redeclaration errors
| if (class_exists('Kronolith_Application', false)) { | ||
| return; | ||
| } | ||
|
|
Copilot
AI
Aug 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider using include_once or require_once at the inclusion point instead of adding guards within the file. This approach is more conventional and prevents the file from being processed multiple times entirely.
| if (class_exists('Kronolith_Application', false)) { | ||
| return; | ||
| } | ||
|
|
Copilot
AI
Aug 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The guard addresses a symptom rather than the root cause. Since the description mentions the root cause is unclear, consider investigating why the file is being included multiple times to implement a more robust solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's rather fix the portal block loader.
|
It looks like the root cause of this is when For example, it happens when 'horde/services/portal/' url is opened. Then // Implied attempt to trigger a previously setup autoloader
if (class_exists($classname, true)) {
} elseif (file_exists($path)) {
include_once $path;
} else {
$classname = __CLASS__ . '_' . $cname;
}The solution is to set if (is_null($app)) {
$app = $this->getApp();
}Then there will be no need to add the guard. I can submit a PR with additional cleanups, if needed. Note, there is also another (unrelated) case of double declaration, when class is loaded using |
This fixes double declaration issues such as decribed in horde/kronolith#17
|
I added a minimal Horde Core fix that resolves the issue. Potentially other I would bee happy to update it, if requested. |
Guard to avoid double declaration. root cause still unclear.