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

Improve .phpstorm.meta.php

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Minor Minor
    • 4.4.3
    • 4.4, 4.5
    • General

      Maybe I misunderstood something about MDL-81233, but I have a few issues with that change. The main one being that it ignores this override in .phpstorm.meta.php:

          override(
          // Virtual function to indicate that all SQL
          // injections will have the following replacement rules.
              sql_injection_subst(),
              map([
                  '{' => "mdl_", // all `{` in injected SQL strings will be replaced with a prefix
                  '}' => '',        // all `}` will be replaced with an empty string
              ]));
      

      It is documented explicitly here that developers are encouraged to use this and it works really well at fixing SQL-related inspection errors/warnings.

      But more broadly, I don't particularly like that you are forcing one configuration on all developers. Having this file in the repository means I cannot add my own metadata changes at the root level. For example, I won't be able to define my own DB table prefix in a separate meta file as mentioned above.

      PHPStorm allows you to use a .phpstorm.meta.php/ directory with arbitrarily named files in it that will be combined into one metadata configuration. I think a better solution would be to put those overrides from the current meta file into a .phpstorm.meta.php/moodle.php file for example and tell git to un-ignore that particular file, but ignore everything else in that directory.

      That way the current metadata shipped by Moodle can stay as is and developers can add as many of their own files such as .phpstorm.meta.php/custom.php as they like. Again, this is especially relevant for the DB table prefix since that may be different for any given installation.

      I have a branch ready to go here. I successfully tested these changes with PHPStorm 2024.1.4 and I would appreciate any feedback.

        1. on phpstorm.png
          on phpstorm.png
          528 kB
        2. onvscode.png
          onvscode.png
          212 kB

            daniil-berg Daniil Fajnberg
            daniil-berg Daniil Fajnberg
            Andrew Lyons Andrew Lyons
            Jun Pataleta Jun Pataleta
            Jun Pataleta Jun Pataleta
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 12 minutes
                12m

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