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

"Invalid installation files detected" message may be confusing

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.3
    • Fix Version/s: 2.3.2
    • Component/s: Installation
    • Labels:
      None

      Description

      The message "Invalid installation files detected, upgrade cannot continue", is not helpful as it includes no indication of which files are blocking the upgrade.

      To reproduce the problem

      • add a file at /admin/generator.php
      • decrement Moodle version number in database

        UPDATE mdl_config SET value=(value-1) WHERE name='version'

      • log in to Moodle as admin to initiate upgrade process
      • notice that upgrade "Invalid installation files detected" message does not include any indication of which files are blocking the upgrade.

      The following modifications will report a list of files and folders that are blocking the upgrade and allow the server admin to take remedial action:

      lib/upgradelib

      • around line 319
      • upgrade_stale_php_files_present()
      • return an array of stale files or false

        upgrade_stale_php_files_present() in lib/upgradelib.php

        function upgrade_stale_php_files_present() {
            global $CFG;
         
            $files = array();
         
            $someexamplesofremovedfiles = array(
                /* list of files goes here */
            );
         
            foreach ($someexamplesofremovedfiles as $file) {
                if (file_exists($CFG->dirroot.$file)) {
                    $files[] = $file;
                }
            }
         
            if (count($files)) {
                return $files;
            } else {
                return false;
            }
        }

      admin/renderer.php

      • around line 66
      • upgrade_stale_php_files_page() method
      • optionally accept and display an array of file/folder paths

        upgrade_stale_php_files_page() in admin/renderer.php

        public function upgrade_stale_php_files_page($files = false) {
         
            /* start output as before */
            $output .= get_string('upgradestalefilesinfo', 'admin', get_docs_url('Upgrading'));
            if ($files) {
                $output .= html_writer::start_tag('ul');
                foreach ($files as $file) {
                    $output .= html_writer::tag('li', $file);
                }
                $output .= html_writer::end_tag('ul');
            } else {
                $output .= html_writer::empty_tag('br');
            }
            /* finish output as before */
        }

      admin/index.php

      • around line 203
      • pass list of stale files from upgrade_stale_php_files_present() to $output->upgrade_stale_php_files_page($files)

        admin/index.php

        if ($files = upgrade_stale_php_files_present()) {
            $PAGE->set_title($stradministration);
            $PAGE->set_cacheable(false);
         
            $output = $PAGE->get_renderer('core', 'admin');
            echo $output->upgrade_stale_php_files_page($files);
            die();
        }

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

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

                  Dates

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