Skip to content

Commit

Permalink
Moodle code compliance changes, a noop
Browse files Browse the repository at this point in the history
  • Loading branch information
srdjan-catalyst committed Jul 27, 2023
1 parent 796916e commit d6d8523
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 33 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# .github/workflows/ci.yml
name: ci

env:
PLUGIN: tool_forcedcache

on: [push, pull_request]

jobs:
ci:
uses: catalyst/catalyst-moodle-workflows/.github/workflows/ci.yml@main
secrets:
moodle_org_token: ${{ secrets.MOODLE_ORG_TOKEN }}
with:
disable_behat: true
8 changes: 3 additions & 5 deletions classes/cache_administration_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* This class changes the actions that are available to various stores,
* and changes the layout slightly
* This class changes the actions that are available to various stores, and changes the layout slightly
*
* @package tool_forcedcache
* @author Peter Burnett <[email protected]>
* @copyright Catalyst IT
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

class tool_forcedcache_cache_administration_helper extends core_cache\administration_helper {

/**
Expand Down Expand Up @@ -133,7 +131,7 @@ public function get_ruleset_output(): string {
/**
* Generates a config table for the selected caching store
*
* @param integer $mode the mode to generate the table for.
* @param string $name def table name (prefix)
* @param array $config the config array from the JSON.
* @return string HTML for the table.
*/
Expand Down Expand Up @@ -197,7 +195,7 @@ private function generate_override_table(array $overrides): string {
/**
* Generates a ruleset table for the selected caching mode.
*
* @param integer $mode the mode to generate the table for.
* @param int $mode the mode to generate the table for.
* @param array $config the config array from the JSON.
* @return string HTML for the table.
*/
Expand Down
10 changes: 5 additions & 5 deletions classes/cache_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,15 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* This cache_config class extends the first one, and generates the
* configuration array from reading a hardcoded JSON file instead of
* the configuration file on shared disk.
* This cache_config class generates the configuration array from reading a hardcoded JSON file
*
* Instead of the configuration file on shared disk.
*
* @package tool_forcedcache
* @author Peter Burnett <[email protected]>
* @copyright Catalyst IT
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

class tool_forcedcache_cache_config extends cache_config {

/**
Expand Down Expand Up @@ -283,9 +282,10 @@ public static function get_default_mode_mappings() : array {
/**
* This function generates the mappings for each cache mode after rules are applied.
*
* @param array $rules
* @return array the generated mode mappings post-rules.
*/
private function generate_mode_mapping($rules): array {
private function generate_mode_mapping(array $rules): array {
$modetostr = [
cache_store::MODE_APPLICATION => 'application',
cache_store::MODE_SESSION => 'session',
Expand Down
9 changes: 4 additions & 5 deletions classes/cache_config_writer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

defined('MOODLE_INTERNAL') || die();
// Manually require locallib as it isn't autoloaded.
require_once(__DIR__.'/../../../../cache/locallib.php');

/**
* This config_writer is readonly, and provides public access to some protected methods.
*
Expand All @@ -22,11 +26,6 @@
* @copyright Catalyst IT
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die();
// Manually require locallib as it isn't autoloaded.
require_once(__DIR__.'/../../../../cache/locallib.php');

class tool_forcedcache_cache_config_writer extends cache_config_writer {

/**
Expand Down
5 changes: 3 additions & 2 deletions classes/cache_factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@
* @copyright Catalyst IT
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

class tool_forcedcache_cache_factory extends cache_factory {

/**
* This is a copy of the core class, with the classes swapped out.
* TODO: Refactor core method to accept class param, and call parent with param.
*
* @param bool $writer
*/
public function create_config_instance($writer = false) {
public function create_config_instance(bool $writer = false) {

This comment has been minimized.

Copy link
@aspark21

aspark21 Jul 28, 2023

can't do this, it's incompatible with core

global $CFG;

// The class to use.
Expand Down
11 changes: 6 additions & 5 deletions classes/check/enabled.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

namespace tool_forcedcache\check;
use core\check\check;
use core\check\result;

/**
* Forcedcache enabled check
*
Expand All @@ -22,10 +26,6 @@
* @copyright Catalyst IT
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace tool_forcedcache\check;
use core\check\check;
use core\check\result;

class enabled extends check {
/**
* Get the short check name
Expand Down Expand Up @@ -58,7 +58,8 @@ public function get_result() : result {
$dummy = new \tool_forcedcache_cache_config();
$errors = $dummy->get_inclusion_errors();

$forcedcacheenabled = isset($CFG->alternative_cache_factory_class) && $CFG->alternative_cache_factory_class === 'tool_forcedcache_cache_factory';
$forcedcacheenabled = isset($CFG->alternative_cache_factory_class)
&& $CFG->alternative_cache_factory_class === 'tool_forcedcache_cache_factory';

if (!$forcedcacheenabled || !empty($errors)) {
$status = $forcedcacheenabled ? result::ERROR : result::WARNING;
Expand Down
5 changes: 2 additions & 3 deletions classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,15 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

namespace tool_forcedcache\privacy;

/**
* Plugin privacy provider
*
* @package tool_forcedcache
* @copyright 2020 Peter Burnett <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace tool_forcedcache\privacy;

class provider implements
// This plugin does not store any personal user data.
\core_privacy\local\metadata\null_provider {
Expand Down
9 changes: 9 additions & 0 deletions lang/en/tool_forcedcache.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Language strings
*
* @package tool_forcedcache
* @author Peter Burnett <[email protected]>
* @copyright 2022, Catalyst IT
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

$string['pluginname'] = 'Forced Caching';

// Page Strings.
Expand Down
10 changes: 5 additions & 5 deletions tests/cache_config_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

namespace tool_forcedcache;

/**
* Test file for tool_forcedcache_cache_config.
* Tests for tool_forcedcache_cache_config.
*
* @package tool_forcedcache
* @author Peter Burnett <[email protected]>
* @copyright Catalyst IT
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @covers \tool_forcedcache_cache_config
*/

namespace tool_forcedcache\tests;

class tool_forcedcache_cache_config_testcase extends \advanced_testcase {
class cache_config_test extends \advanced_testcase {

/**
* We need to load the config files outside of the $CFG->dirroot, so it
Expand Down

0 comments on commit d6d8523

Please sign in to comment.