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

\core_component::get_component_classes_in_namespace() gets wrong results

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      All branches:

      1. Unit tests should pass
      2. Behat should pass as well but CI bot will test it for you (will test the mod_forum change)

      31 and master:

      1. Setup global search (https://docs.moodle.org/31/en/Global_search)
      2. Reindex your site contents if they were already indexed
      3. Check that global search works (no need to test anything in particular, if there is something wrong with this patch I doubt you would even be able to reindex)
      Show
      All branches: Unit tests should pass Behat should pass as well but CI bot will test it for you (will test the mod_forum change) 31 and master: Setup global search ( https://docs.moodle.org/31/en/Global_search ) Reindex your site contents if they were already indexed Check that global search works (no need to test anything in particular, if there is something wrong with this patch I doubt you would even be able to reindex)
    • Affected Branches:
      MOODLE_30_STABLE, MOODLE_31_STABLE, MOODLE_32_STABLE
    • Fixed Branches:
      MOODLE_30_STABLE, MOODLE_31_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-55237_master

      Description

      The method \core_component::get_component_classes_in_namespace() uses a regular expression to find classes in a given namespace.
      But it uses the given namespace just as part of a namespace and not as the namespace itself.

      example:
      You have a plugin named "local_my_plugin". In this plugin you have a class "\local_my_plugin\search_form".
      If you call $result = \core_component::get_component_classes_in_namespace('local_my_plugin', 'search');
      It gets you the result:

      Array
      (
      [local_my_plugin\search_form] => Array
      (
      [0] => local_my_plugin\search
      )
      )

      That is obviously wrong.
      In my case it broke a pluginin which uses a class like that.
      The regex is built like that:
      $regex = '/^' . $component . '\\\\' . $namespace . '/';
      So the given namespace is just the first part of a namespace.
      Mayby it should look like that:
      $regex = '/^' . $component . '\\\\' . $namespace . '\\\\/';
      But I don't know if the RegexIterator is working correctly after that.

      Best regards Andreas

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                12/Sep/16