Uploaded image for project: 'Plugins'
  1. Plugins
  2. CONTRIB-7421

Start checking that config.php is only included via require()

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Deferred
    • 3.1.13, 3.2.9, 3.3.6, 3.4.4, 3.5.1, 3.6
    • None
    • Local: Code checker
    • None
    • MOODLE_31_STABLE, MOODLE_32_STABLE, MOODLE_33_STABLE, MOODLE_34_STABLE, MOODLE_35_STABLE, MOODLE_36_STABLE

    Description

      Reviewing MDL-61238 and looking for some historic issues like MDL-18582 or MDLSITE-2716 that leaded to current coding style:

      https://docs.moodle.org/dev/Coding_style#Require_.2F_include

      "For library files in normal usage, require_once should be used (this is different from config.php which should always use 'require' as above)"

      This about to add a new sniff to the codechecker ensuring that the correct require() alternative is used when including config.php

      We already look for its inclusion in the MoodleInternalSniff but both are allowed there. Surely better to create a separate Sniff to make it a separate error.

      Also, docs should be changed everywhere, right now the incorrect require_once(config.php) is ubiquitous (but coding style page).

      Current (quick grep) occurrences are incorrect require_once => 36000 vs correct require => 18000. This is not about to changing all them but about to prevent new ones and progressively go reducing the incorrect ones.

      Ciao

      Attachments

        Issue Links

          Activity

            People

              moodle.com moodle.com
              stronk7 Eloy Lafuente (stronk7)
              moodle.com, Eloy Lafuente (stronk7)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: