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

Allow plugin environment checks to work without defining explicit versions of Moodle

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.8, 2.9
    • Fix Version/s: 2.9
    • Component/s: Unknown
    • Testing Instructions:
      Hide

      Plugin environment.xml

      1. Create an environment.xml file in a plugin directory (for example block_navigation) Using the following code:
        <COMPATIBILITY_MATRIX>
        <MOODLE version="2.8">
        <PHP_EXTENSIONS>
        <PHP_EXTENSION name="xml" level="required" />
        </PHP_EXTENSIONS>
        </MOODLE>
        <PLUGIN name="block_navigation">
        <PHP_EXTENSIONS>
        <PHP_EXTENSION name="xsl" level="required" />
        </PHP_EXTENSIONS>
        </PLUGIN>
        </COMPATIBILITY_MATRIX>
      2. Replace the version attribute with the version of Moodle you are testing against
      3. Replace the name attribute with the franken_style name of the plugin you added the file to.
      4. Go to Site Administration > Server > Environment
        • In a version with this patch installed there should be an entry displayed for this plugin showing that the xsl extension is required. Changing the version of Moodle should leave this information showing.
        • In a version without this patch the requirement for the plugin would be that the xml plugin is required.
      5. Edit the plugin's environment.xml file so that the name attribute does not match the plugin.
      6. Refresh the environment page, it should no longer list requirements for the plugin.
      7. Edit the plugin's environment.xml and remove the name attribute entirely.
      8. Refresh the environment page, it should show that the xsl extension is required by the plugin. it should no longer list requirements for the plugin (because we finally made it mandatory).

      Unit tests

      Run the unit tests in the lib/tests/environment_test.php file

      The PLUGIN tag should not have any affect in the main moodle environment.xml file

      1. Add a plugin tag to the main moodle environment.xml file, with a requirement that is not already in Moodle.
      2. Go to Site Administration > Server > Environment
      3. You should not see this requirement listed against any version of Moodle.
      Show
      Plugin environment.xml Create an environment.xml file in a plugin directory (for example block_navigation) Using the following code: <COMPATIBILITY_MATRIX> <MOODLE version="2.8"> <PHP_EXTENSIONS> <PHP_EXTENSION name="xml" level="required" /> </PHP_EXTENSIONS> </MOODLE> <PLUGIN name="block_navigation"> <PHP_EXTENSIONS> <PHP_EXTENSION name="xsl" level="required" /> </PHP_EXTENSIONS> </PLUGIN> </COMPATIBILITY_MATRIX> Replace the version attribute with the version of Moodle you are testing against Replace the name attribute with the franken_style name of the plugin you added the file to. Go to Site Administration > Server > Environment In a version with this patch installed there should be an entry displayed for this plugin showing that the xsl extension is required. Changing the version of Moodle should leave this information showing. In a version without this patch the requirement for the plugin would be that the xml plugin is required. Edit the plugin's environment.xml file so that the name attribute does not match the plugin. Refresh the environment page, it should no longer list requirements for the plugin. Edit the plugin's environment.xml and remove the name attribute entirely. Refresh the environment page, it should show that the xsl extension is required by the plugin. it should no longer list requirements for the plugin (because we finally made it mandatory). Unit tests Run the unit tests in the lib/tests/environment_test.php file The PLUGIN tag should not have any affect in the main moodle environment.xml file Add a plugin tag to the main moodle environment.xml file, with a requirement that is not already in Moodle. Go to Site Administration > Server > Environment You should not see this requirement listed against any version of Moodle.
    • Affected Branches:
      MOODLE_28_STABLE, MOODLE_29_STABLE
    • Fixed Branches:
      MOODLE_29_STABLE
    • Pull from Repository:
    • Pull Master Branch:

      Description

      The current state

      At the moment the plugin environment check requires that you define a specific version of Moodle for the environment checks to be carried out in, i.e.

      <COMPATIBILITY_MATRIX>
      <MOODLE version="2.6">
      <PHP_EXTENSIONS>
      <PHP_EXTENSION name="xml" level="required" />
      <PHP_EXTENSION name="xsl" level="required" />
      </PHP_EXTENSIONS>
      </MOODLE>
      </COMPATIBILITY_MATRIX>

      Even though a plugin would likely have the same environment requirements in any version of Moodle.

      The proposal

      This feature would be more usable for developers if it was possible to make the requirements work against all versions of Moodle.

      The code I have developed does this by adding a new PLUGIN tag

      <COMPATIBILITY_MATRIX>
      <PLUGIN name="franken_style">
      <PHP_EXTENSIONS>
      <PHP_EXTENSION name="xml" level="required" />
      <PHP_EXTENSION name="xsl" level="required" />
      </PHP_EXTENSIONS>
      </PLUGIN>
      </COMPATIBILITY_MATRIX>

      The tag has the following properties:

      • The Environment file would not break versions of Moodle that do not support the PLUGIN syntax, as the PLUGIN tag would be ignored by them.
      • Specific versioned MOODLE tags could be defined for 2.6, 2.7 and 2.8 if you wanted all versions of Moodle that support plugin environment.xml files to work.
      • If both MOODLE and PLUGIN tags exist the PLUGIN tag will be used in preference.
      • The PLUGIN tag will not function in the main Moodle environment.xml file.
      • the PLUGIN tag has an optional attribute of name. If present the checks will only be run when it matches the plugins franken_style name.

      For a discussion on this issue see: https://moodle.org/mod/forum/discuss.php?d=274831

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                3 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  11/May/15