fix(sources): avoid loading mgr Context in MediaSource findPolicy - #80
Open
Ibochkarev wants to merge 3 commits into
Open
fix(sources): avoid loading mgr Context in MediaSource findPolicy#80Ibochkarev wants to merge 3 commits into
Ibochkarev wants to merge 3 commits into
Conversation
…xcms#16212) Replace hardcoded $context = 'mgr' with the same defaulting as modContext and modResource: use argument when non-empty, else current request context. Fixes mgr-context errors when serving pages in web context.
Keep Media Source ACL lookups scoped to mgr, but read
access_media_source_enabled without getContext('mgr') on the frontend.
That stops anonymous INFO noise without weakening manager-only ACLs (modxcms#16212).
Move the modxcms#16212 regression test into its own PSR-12 file so PHPCS does not blame pre-existing style debt in modMediaSourceTest.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Что сделано
modMediaSource::findPolicy()по-прежнему ищет Media Source ACL сcontext_key = mgr(как UI менеджера). Он больше не вызываетgetContext('mgr')из фронт-запроса только ради чтенияaccess_media_source_enabled.Если текущий контекст уже
mgr, илиmgrуже в$modx->contexts, используется опция этого контекста. Иначе используется системная опция.Зачем нужно
На фронтенде форсированная загрузка объекта
mgrContext может INFO-логировать отказы ACL для анонимных пользователей (Principal 0 does not have permission to load object of class modContext with primary key: mgr). См. modxcms#16212.Более ранний подход менял хардкод
mgrACL-scope на контекст запроса. Мейнтейнеры указали, что Media Source ACL — только менеджерные (#16214, комментарии от @Mark-H, @theboxer, @smg6511, @opengeek), поэтому это изменение здесь не используется.Как проверить
findPolicy().phpunit --filter MediaSourceFindPolicyTestСвязанные
Refs modxcms#16212
Заменяет подход, обсуждаемый в modxcms#16214 для этого конкретного INFO-noise-пути.
Оригинал: modxcms#16845