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

Add endpoint to provide the Moodle version

XMLWordPrintable

    • MOODLE_311_STABLE
    • MOODLE_311_STABLE
    • MDL-73582-master-nocache
    • Hide

      Setup

      1. Create a directory called “static” in the public root of the webserver.
      2. Generate OpenSSL RSA Key Pair from the Command Line in the static directory. You can use the openssl command:

        # Private key
        $ openssl genrsa -out private.pem 2048
        # Extract public key
        $ openssl rsa -in private.pem -outform PEM -pubout -out statspubkey.pem
        

      3. Verify that you can display the public key in the browser at http://localhost/static/statspubkey.pem. You'll see something like:

        --{}{}BEGIN PUBLIC KEY{}{}--
        MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA6M9kHnoQOpvI
        ...
        OHswYc JwIDAQAB
        --{}{}END PUBLIC KEY{}{}--

      4. Add the following code somewhere before the final lib/setup.php inclusion in your config.php:

        const HUB_STATSPUBLICKEY = 'http://localhost/static/statspubkey.pem'; 

      5. In Site administration > General > Security > HTTP Security remove "localhost" and "127.0.0.1" from the "cURL blocked hosts list" if present.
      6. Download the attached file get_moodle_version.php.

      Test 1 - Moodle instance with the patch applied

      1. Run the script:

        $ php get_moodle_version.php
        

      2. Confirm that the scripts returns the Moodle version, something like Moodle version: 4.0dev+ (Build: 20220208).

      Test 2 - Moodle instance without the patch applied

      1. Repeat step 1 from Test 1, but this time introduce the URL of a Moodle instance without the patch, like https://stats.moodle.org.
      2. Confirm you get the message "Endpoint doesn't exist".
      Show
      Setup Create a directory called “static” in the public root of the webserver. Generate OpenSSL RSA Key Pair from the Command Line in the static directory. You can use the openssl command: # Private key $ openssl genrsa -out private.pem 2048 # Extract public key $ openssl rsa - in private.pem -outform PEM -pubout -out statspubkey.pem Verify that you can display the public key in the browser at http://localhost/static/statspubkey.pem . You'll see something like: -- { }{ }BEGIN PUBLIC KEY{ }{ } -- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA6M9kHnoQOpvI ... OHswYc JwIDAQAB -- { }{ }END PUBLIC KEY{ }{ } -- Add the following code somewhere before the final lib/setup.php inclusion in your config.php: const HUB_STATSPUBLICKEY = 'http://localhost/static/statspubkey.pem' ; In  Site administration > General > Security > HTTP Security remove "localhost" and "127.0.0.1" from the "cURL blocked hosts list" if present. Download the attached file get_moodle_version.php . Test 1 - Moodle instance with the patch applied Run the script: $ php get_moodle_version.php Enter the URL of the site to test, like https://localhost/stable_master/moodle Enter the relative/absolute path to the private key created in the Setup section, like static/private.pem . Confirm that the scripts returns the Moodle version, something like Moodle version: 4.0dev+ (Build: 20220208) . Test 2 - Moodle instance without the patch applied Repeat step 1 from Test 1, but this time introduce the URL of a Moodle instance without the patch, like https://stats.moodle.org . Confirm you get the message "Endpoint doesn't exist".

      As a consequence of MDL-69333 the Moodle linkchecker is no longer able to detect Moodle site version based on parsing contents of certain files.

      After discussion (MDLSITE-6486), it was agreed to add a new endpoint in LMS that returns the Moodle version.

            vmdef Victor Déniz Falcón
            vmdef Victor Déniz Falcón
            David Mudrák (@mudrd8mz) David Mudrák (@mudrd8mz)
            Andrew Lyons Andrew Lyons
            Gladys Basiana Gladys Basiana
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 4 hours, 25 minutes
                4h 25m

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