-
-
Notifications
You must be signed in to change notification settings - Fork 236
Fix: prevent global environment pollution in multi-site ls check #2174
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: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -202,20 +202,26 @@ class Instance { | |
| if (!this._cliConfig.has('running')) { | ||
| const currentEnvironment = this.system.development; | ||
|
|
||
| const envIsRunning = async (environment) => { | ||
| const envIsRunning = async (environment) => { | ||
| if (!Config.exists(path.join(this.dir, `config.${environment}.json`))) { | ||
| return false; | ||
| } | ||
|
|
||
| // 1. Save original environment state | ||
| const originalEnv = this.system.environment; | ||
|
|
||
| this.system.setEnvironment(environment === 'development'); | ||
| const running = await this.process.isRunning(this.dir); | ||
| if (running) { | ||
| this._cliConfig.set('running', environment).save(); | ||
| } | ||
|
|
||
| // 2. Restore original environment state | ||
| this.system.setEnvironment(originalEnv === 'development'); | ||
|
|
||
| return running; | ||
| }; | ||
|
|
||
| const production = await envIsRunning('production'); | ||
| if (production) { | ||
| return true; | ||
|
|
@@ -386,7 +392,7 @@ class Instance { | |
| dir: this.dir.replace(os.homedir(), '~'), | ||
| running: true, | ||
| version: this.version, | ||
| mode: this.system.environment, | ||
| mode: this._cliConfig.get('running') || this.system.environment, | ||
| url: this.config.get('url'), | ||
| port: this.config.get('server.port'), | ||
| process: this.process.name | ||
|
Comment on lines
+395
to
398
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keep Line 395 fixes Proposed fix if (!running) {
return {
name: this.name,
dir: this.dir.replace(os.homedir(), '~'),
version: this.version,
running: false
};
}
+ this.loadRunningEnvironment();
+
return {
name: this.name,
dir: this.dir.replace(os.homedir(), '~'),
running: true,
version: this.version,
mode: this._cliConfig.get('running') || this.system.environment,
url: this.config.get('url'),
port: this.config.get('server.port'),
process: this.process.name
};🤖 Prompt for AI Agents |
||
|
|
||
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.
Ensure environment restoration on exceptions in
envIsRunning.At Line 214, if
this.process.isRunning(this.dir)throws, Line 220 never runs, leaving global environment mutated. Wrap the switch/restore block intry/finally.Proposed fix
🤖 Prompt for AI Agents