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

\core_component::get_component_classes_in_namespace() gets wrong results

XMLWordPrintable

    • MOODLE_30_STABLE, MOODLE_31_STABLE, MOODLE_32_STABLE
    • MOODLE_30_STABLE, MOODLE_31_STABLE
    • MDL-55237_master
    • 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)

      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

            dmonllao David Monllaó
            grabs Andreas Grabs
            Eric Merrill Eric Merrill
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            cameron1729 cameron1729
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

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