Skip to content

findPolicy() in modMediaSource always looks at the mgr context #16212

@CarlBohman

Description

@CarlBohman

Bug report

Summary

The findPolicy function in core/model/modx/sources/modmediasource.class.php explicitly sets the $context to $mgr in all cases, ignoring any value sent into the function.

Step to reproduce

Look at the source code: https://github.com/modxcms/revolution/blob/3.x/core/src/Revolution/Sources/modMediaSource.php (line 1622 as of 6/22/2022). Here is a copy of the relevant code:

    public function findPolicy($context = '')
    {
        $policy = [];
        $enabled = true;
        $context = 'mgr';

Observed behavior

In one specific case on a site with access_resource_group_enabled turned off and log level set to info, this created a large number of errors related to the mgr context when trying to access pages in the web context. Deleting this line eliminated the errors and no side effects have been observed.

Expected behavior

No extraneous error messages and no attempts to look at the mgr context when accessing pages in the web context.

Environment

MODX version 2.8.3, but present in the current 3.x version of the code as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThe issue in the code or project, which should be addressed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions