Uploaded image for project: 'Moodle Community Sites'
  1. Moodle Community Sites
  2. MDLSITE-2178

Plugins with invalid version

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • High
    • Resolution: Fixed
    • moodle.org/plugins
    • None

    Description

      The docs page http://docs.moodle.org/dev/version.php clearly specifies the expected format for the plugin version number. Shortly, Moodle has always expected plugin version being date based in a form like 2YYYMMDDxx.

      While working on the on-click installation feature and automatic updates, I have realized that the plugin version plays very important role in the whole process.

      Unfortunately, Moodle Plugins directory allows users to publish plugins with a version number that violates the documented rule. This is especially true for themes, where version.php is not required and users put various version labels there.

      I have found around 40 plugin versions with unexpected version number:

      https://moodle.org/plugins/pluginversion.php?id=1	invalid version: 201107282235
      https://moodle.org/plugins/pluginversion.php?id=32	invalid version: 1.4.5.39
      https://moodle.org/plugins/pluginversion.php?id=134	invalid version: 2.01
      https://moodle.org/plugins/pluginversion.php?id=136	invalid version: 2.1
      https://moodle.org/plugins/pluginversion.php?id=103	invalid version: v0.5.0
      https://moodle.org/plugins/pluginversion.php?id=715	invalid version: v1.2.3
      https://moodle.org/plugins/pluginversion.php?id=475	invalid version: 2
      https://moodle.org/plugins/pluginversion.php?id=102	invalid version: v0.1.0
      https://moodle.org/plugins/pluginversion.php?id=106	invalid version: 1.3
      https://moodle.org/plugins/pluginversion.php?id=341	invalid version: Moodle 1.9
      https://moodle.org/plugins/pluginversion.php?id=786	invalid version: 2012050200.00
      https://moodle.org/plugins/pluginversion.php?id=791	invalid version: 2012050300.00
      https://moodle.org/plugins/pluginversion.php?id=792	invalid version: 2012050300.00
      https://moodle.org/plugins/pluginversion.php?id=793	invalid version: 2012050300.00
      https://moodle.org/plugins/pluginversion.php?id=140	invalid version: 20111002
      https://moodle.org/plugins/pluginversion.php?id=193	invalid version: 20111019
      https://moodle.org/plugins/pluginversion.php?id=189	invalid version: 1
      https://moodle.org/plugins/pluginversion.php?id=226	invalid version: 2.1
      https://moodle.org/plugins/pluginversion.php?id=227	invalid version: 2.1
      https://moodle.org/plugins/pluginversion.php?id=260	invalid version: 20111207151800
      https://moodle.org/plugins/pluginversion.php?id=279	invalid version: 20111207151801
      https://moodle.org/plugins/pluginversion.php?id=454	invalid version: 20120126104701
      https://moodle.org/plugins/pluginversion.php?id=734	invalid version: 20120416000000
      https://moodle.org/plugins/pluginversion.php?id=335	invalid version: 1.8.0
      https://moodle.org/plugins/pluginversion.php?id=344	invalid version: 1.0
      https://moodle.org/plugins/pluginversion.php?id=345	invalid version: 1.0
      https://moodle.org/plugins/pluginversion.php?id=694	invalid version: 20120040310
      https://moodle.org/plugins/pluginversion.php?id=564	invalid version: 2012022200 
      https://moodle.org/plugins/pluginversion.php?id=819	invalid version: 201205170000
      https://moodle.org/plugins/pluginversion.php?id=1110	invalid version: 20120716
      https://moodle.org/plugins/pluginversion.php?id=1444	invalid version: 2012070500.00
      https://moodle.org/plugins/pluginversion.php?id=917	invalid version: 2012062100.01
      https://moodle.org/plugins/pluginversion.php?id=981	invalid version: 20120411
      https://moodle.org/plugins/pluginversion.php?id=1367	invalid version: 201206250000
      https://moodle.org/plugins/pluginversion.php?id=1406	invalid version: 201206250000
      https://moodle.org/plugins/pluginversion.php?id=1452	invalid version: 201210081201.01
      https://moodle.org/plugins/pluginversion.php?id=1563	invalid version: 201210081202
      https://moodle.org/plugins/pluginversion.php?id=2086	invalid version: 20131012900
      https://moodle.org/plugins/pluginversion.php?id=2101	invalid version: 2013013100.02
      https://moodle.org/plugins/pluginversion.php?id=1677	invalid version: 0.1
      https://moodle.org/plugins/pluginversion.php?id=1700	invalid version: 0.2
      https://moodle.org/plugins/pluginversion.php?id=1749	invalid version: 0.3
      https://moodle.org/plugins/pluginversion.php?id=1974	invalid version: 2012102400.00
      

      To get such output yourself, you can use the following scriptie that operates over the output of the local_plugins WS:

      <?php
       
      $p = file_get_contents('plugins.json');
       
      preg_match_all('~"id":([^,]+),"version":"([^"]+)"~', $p, $matches);
       
      foreach ($matches[2] as $i => $v) {
          if (!preg_match('~^2[0-9]{9}$~', $v)) {
              echo 'https://moodle.org/plugins/pluginversion.php?id='.$matches[1][$i]."\tinvalid version: ".$v.PHP_EOL;
          }
      }
      

      My suggestions are:

      1. Make version.php compulsory for all plugin types asap
      2. Validate the $plugin->version (or $module->version) very strictly in Moodle Plugins directory
      3. Do not allow users to modify the version specified in the ZIP's version.php via the Plugins UI.
      4. Come up with a solution for plugins that already have version like 20120416000000 and thence will have problems to "downgrade" to the expected version format (no idea how to achieve that).

      Attachments

        Issue Links

          Activity

            People

              nebgor Aparup Banerjee
              mudrd8mz David Mudrák (@mudrd8mz)
              David Mudrák (@mudrd8mz)
              Votes:
              2 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: