Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-72559

The core plugin_functions cache should be allowed to be stored locally

XMLWordPrintable

    • MOODLE_310_STABLE, MOODLE_311_STABLE, MOODLE_402_STABLE
    • MOODLE_402_STABLE
    • MDL-72559-master
    • Hide

      Testing setup steps

      1. Install tool_mfa:

        git clone https://github.com/catalyst/moodle-tool_mfa/ admin/tool/tool_mfa
        

      2. Install tool_forcedcache:

        git clone https://github.com/catalyst/moodle-tool_forcedcache admin/tool/forcedcache
        

      3. Configure tool_forcedcache by addign the following to your config.php BEFORE the require_once(_DIR_ . '/lib/setup.php'); line:

        // config.php
        if (file_exists(__DIR__.'/admin/tool/forcedcache/version.php')) {
            $CFG->alternative_cache_factory_class = 'tool_forcedcache_cache_factory';
        }
        $CFG->tool_forcedcache_config_array = [
            'stores' => [
                'local_file' => [
                    'type' => 'file',
                    'config' => [
                        'path' => '/tmp/local-cache-file',
                        'autocreate' => 1,
                    ],
                ],
            ],
            'rules' => [
                'application' => [
                    [
                        'stores' => ['local_file'],
                    ],
                ],
                'session' => [],
                'request' => []
            ]
        ];
        

      4. Apply the following patch in core to the constructor of cache/stores/file/lib.php (around _line 166) to simulate 20 different front ends each with their own local file cache.

        // Inside of cache/stores/file/lib.php
        // Put the extra block inside the __construct method near the start
        // In my case, I have it immediately after $this->name = $name (9 lines into the function)
         
                if ($name == 'local_file') {
                    $configuration['path'] .= '/' . rand(10,20);
                }
        

      Testing steps

      Throughout the following tests, any issues loading the expected content when navigating around should be considered a test failure, and might indicate a stagnant or incorrect cache item

      Plugin Install works

      1. Install a plugin with a callback / hook, such as tool_mfa.
      2. Go to Site administration
      3. Click on each of the tabs at the top, and then reload the page
      4. For each click + reload:
        1. Confirm that the correct tab content was loaded

      Plugin Uninstall works

      1. Remove the tool_mfa plugin that was previously installed, then similar to previously
      2. Go to Site administration
      3. Click on each of the tabs at the top, and then reload the page
      4. For each click + reload:
        1. Confirm that the correct tab content was loaded

      Plugin Reinstall works

      1. Reinstall the tool_mfa plugin that was previously installed, then similar to previously
      2. Go to Site administration
      3. Click on each of the tabs at the top, and then reload the page
      4. For each click + reload:
        1. Confirm that the correct tab content was loaded
      Show
      Testing setup steps Install tool_mfa: git clone https://github.com/catalyst/moodle-tool_mfa/ admin/tool/tool_mfa Install tool_forcedcache: git clone https://github.com/catalyst/moodle-tool_forcedcache admin/tool/forcedcache Configure tool_forcedcache by addign the following to your config.php BEFORE the require_once(_ DIR _ . '/lib/setup.php'); line: // config.php if (file_exists(__DIR__.'/admin/tool/forcedcache/version.php')) { $CFG->alternative_cache_factory_class = 'tool_forcedcache_cache_factory'; } $CFG->tool_forcedcache_config_array = [ 'stores' => [ 'local_file' => [ 'type' => 'file', 'config' => [ 'path' => '/tmp/local-cache-file', 'autocreate' => 1, ], ], ], 'rules' => [ 'application' => [ [ 'stores' => ['local_file'], ], ], 'session' => [], 'request' => [] ] ]; Apply the following patch in core to the constructor of cache/stores/file/lib.php (around _line 166) to simulate 20 different front ends each with their own local file cache. // Inside of cache/stores/file/lib.php // Put the extra block inside the __construct method near the start // In my case, I have it immediately after $this->name = $name (9 lines into the function)   if ($name == 'local_file') { $configuration['path'] .= '/' . rand(10,20); } Testing steps Throughout the following tests, any issues loading the expected content when navigating around should be considered a test failure, and might indicate a stagnant or incorrect cache item Plugin Install works Install a plugin with a callback / hook, such as tool_mfa. Go to Site administration Click on each of the tabs at the top, and then reload the page For each click + reload: Confirm that the correct tab content was loaded Plugin Uninstall works Remove the tool_mfa plugin that was previously installed, then similar to previously Go to Site administration Click on each of the tabs at the top, and then reload the page For each click + reload: Confirm that the correct tab content was loaded Plugin Reinstall works Reinstall the tool_mfa plugin that was previously installed, then similar to previously Go to Site administration Click on each of the tabs at the top, and then reload the page For each click + reload: Confirm that the correct tab content was loaded

      The core/plugin_functions cache stores the results of the get_plugins_with_function function, which only depends on the installed code.

      Therefore, this is a good candidate to be stored on local disc. However, the cache definition does not allow this.

            kevinpham Kevin Pham
            timhunt Tim Hunt
            Brendan Heywood Brendan Heywood
            Andrew Lyons Andrew Lyons
            Kim Jared Lucas Kim Jared Lucas
            Votes:
            1 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 day, 5 minutes
                1d 5m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.