-
Notifications
You must be signed in to change notification settings - Fork 2.9k
fix: add port check for php runtime port config #8941
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
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 |
|---|---|---|
|
|
@@ -1022,11 +1022,15 @@ func (r *RuntimeService) UpdatePHPContainer(req request.PHPContainerConfig) erro | |
| return err | ||
| } | ||
| var ( | ||
| hostPorts []string | ||
| composeContent []byte | ||
| ) | ||
| for _, export := range req.ExposedPorts { | ||
| hostPorts = append(hostPorts, strconv.Itoa(export.HostPort)) | ||
| if strconv.Itoa(export.HostPort) == runtime.Port { | ||
| return buserr.WithName("ErrPHPRuntimePortFailed", strconv.Itoa(export.HostPort)) | ||
| } | ||
| if export.ContainerPort == 9000 { | ||
| return buserr.New("ErrPHPPortIsDefault") | ||
| } | ||
| if err = checkRuntimePortExist(export.HostPort, false, runtime.ID); err != nil { | ||
| return err | ||
| } | ||
|
|
@@ -1075,6 +1079,7 @@ func (r *RuntimeService) UpdatePHPContainer(req request.PHPContainerConfig) erro | |
| for k, v := range newMap { | ||
| envs[k] = v | ||
| } | ||
| envs["PANEL_APP_PORT_HTTP"] = runtime.Port | ||
| envStr, err := gotenv.Marshal(envs) | ||
| if err != nil { | ||
| return err | ||
|
Member
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. The provided code snippets appear to be part of a function in a Go application that manages PHP containers within Docker using a runtime service. Here are some points and suggestions: Code Differences and Potential Issues
Optimization Suggestions
ConclusionBy addressing these issues, the overall code will become more robust, readable, and efficient. Additionally, incorporating additional features or refactoring existing functionalities based on further analysis and understanding could lead to a more sophisticated solution tailored to the needs of the application running this code base. |
||
|
|
||
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.
There are no apparent issues with the code in this diff. However, you can consider the following optimizations:
Replace
WHERE field REGEXP 'pattern'withSELECT id FROM table WHERE field LIKE %pattern%. This will be more efficient on databases that support it.You might want to add error handling for cases where port is not an integer or out of range, depending on your application's requirements.
Consider using a separate option function for each DBOption if it helps readability or maintainability.
In terms of performance, since there may be many records, optimizing the query could potentially improve response times.