-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Lazy load uncommon CFG_GLPI values #21528
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
Closed
cconard96
wants to merge
5
commits into
glpi-project:11.0/bugfixes
from
cconard96:performance/js_proxy_cfg
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cedric-anne marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * --------------------------------------------------------------------- | ||
| * | ||
| * GLPI - Gestionnaire Libre de Parc Informatique | ||
| * | ||
| * http://glpi-project.org | ||
| * | ||
| * @copyright 2015-2025 Teclib' and contributors. | ||
| * @licence https://www.gnu.org/licenses/gpl-3.0.html | ||
| * | ||
| * --------------------------------------------------------------------- | ||
| * | ||
| * LICENSE | ||
| * | ||
| * This file is part of GLPI. | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
| * | ||
| * --------------------------------------------------------------------- | ||
| */ | ||
|
|
||
| namespace Glpi\Controller\Session; | ||
|
|
||
| use Config; | ||
| use Glpi\Controller\AbstractController; | ||
| use Glpi\Exception\Http\NotFoundHttpException; | ||
| use Glpi\Http\Firewall; | ||
| use Glpi\Security\Attribute\SecurityStrategy; | ||
| use Symfony\Component\HttpFoundation\JsonResponse; | ||
| use Symfony\Component\HttpFoundation\Request; | ||
| use Symfony\Component\HttpFoundation\Response; | ||
| use Symfony\Component\Routing\Attribute\Route; | ||
|
|
||
| final class ConfigController extends AbstractController | ||
| { | ||
| #[Route("/Session/Config/{key}", name: "get_config_value")] | ||
| #[SecurityStrategy(Firewall::STRATEGY_AUTHENTICATED)] | ||
| public function content(Request $request): Response | ||
| { | ||
| $safe_config = Config::getSafeConfig(true); | ||
| $key = $request->get('key'); | ||
| if (!array_key_exists($key, $safe_config)) { | ||
| throw new NotFoundHttpException(); | ||
| } | ||
| return new JsonResponse($safe_config[$key]); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
As discussed on similar changes, we might disagree on this but I am against adding synchronous calls.
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.
We don't disagree on this point. If it is async though, something will try using a config value that isn't loaded, trigger it to be loaded, and immediately get no value since it didn't wait for the response. I don't want it to be synchronous but it needs to be to make this work with existing code.
We could close the PR and leave the entire dump available, but I'm just trying to improve performance as best I can with what we have for now.
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.
I think your idea is great, it is a nightmare to send 50k chars for the config object in every pages and it would definitely be an improvement to only send useful values (since 99% of the config is likely never used as you said).
I'm just not sold on the solution because I really think synchronous requests should never be added into new code.
If you can make it work another way, I'll gladly approve the PR :)
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.
My only other solution is a comprehensive rework which people aren't onboard with currently, or at least conversion of the legacy JS to modules/classes where we can pass the needed configs through in Twig which cannot really be done in a bugfix version either IMO. Either way, I cannot fix the plugins which may use other config values so we are very limited in terms of solutions at this point if we want to avoid BC breaks.