Commit bf14be2e authored by Patrick Schmalstig's avatar Patrick Schmalstig
Browse files

Fixed MANTIS-5807 (Quick installer does not run install_env health checks)

parent 19e8e4a2
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -168,7 +168,7 @@ if (!array_key_exists('step', $_GET)) {
    $_GET['step'] = '1';
}

if (intval($_GET['step']) == 1) { // Language
if (intval($_GET['step']) == 1) { // Language and integrity checks
    $content = step_1();
}

@@ -344,7 +344,7 @@ function step_1() : object
    }

    global $DATADOTCMS_FILE;
    if (!@is_resource($DATADOTCMS_FILE)) { // Do an integrity check - missing corrupt files
    if (!@is_resource($DATADOTCMS_FILE)) { // Do an integrity check if running the manual installer - missing corrupt files
        $sdc = get_param_integer('skip_disk_checks', null);
        if (($sdc === 1) || (($sdc !== 0) && (file_exists(get_file_base() . '/.git')))) {
            if (!file_exists(get_file_base() . '/.git')) {
@@ -441,11 +441,12 @@ function step_1() : object
            $warnings->attach(do_template('INSTALLER_NOTICE', ['_GUID' => '2f22076de944028f70f40388c43fb96e', 'MESSAGE' => do_lang_tempcode('RECURSIVE_SERVER')]));
        }
    }

    if ((file_exists(get_file_base() . '/_config.php')) && (!cms_is_writable(get_file_base() . '/_config.php')) && (cms_strtoupper_ascii(substr(PHP_OS, 0, 3)) == 'WIN')) {
        $warnings->attach(do_template('INSTALLER_WARNING', ['_GUID' => '368fe19bba96ef38027e7822e1a0a432', 'MESSAGE' => do_lang_tempcode('TROUBLESOME_WINDOWS_SERVER', escape_html(get_tutorial_url('tut_install_permissions')))]));
    }

    // Some sanity checks
    // Some sanity checks on manual installer
    if (!@is_array($FILE_ARRAY)) { // Secondary to the file-by-file check. Aims to give more specific information
        if ((file_exists(get_file_base() . '/themes/default/templates/ANCHOR.tpl')) && (!file_exists(get_file_base() . '/themes/default/templates/COMCODE_TABULAR_INLINE_BLOCKS.tpl'))) {
            warn_exit(do_lang_tempcode('CORRUPT_FILES_CROP'));
@@ -461,8 +462,7 @@ function step_1() : object
    }

    // Language selection...

    if (file_exists('lang_custom/langs.ini')) {
    if ((@is_array($FILE_ARRAY) && file_array_exists('lang_custom/langs.ini')) || file_exists('lang_custom/langs.ini')) {
        $lookup = cms_parse_ini_file_fast(get_custom_file_base() . '/lang_custom/langs.ini');
    } else {
        $lookup = cms_parse_ini_file_fast(get_file_base() . '/lang/langs.ini');
+3 −0
Original line number Diff line number Diff line
@@ -42,10 +42,13 @@ function has_ttf() : bool
        return $result;
    }

    // Actually this is a problematic check because it fails on the quick installer (fonts not extracted) and we're testing for server ttf support, not if this file exists / can be processed
    /*
    if (@imagettfbbox(26.0, 0.0, get_file_base() . '/data/fonts/NotoSans-Regular.ttf', 'test') === false) {
        $result = false;
        return $result;
    }
    */

    $result = true;
    return $result;
+15 −3
Original line number Diff line number Diff line
@@ -1761,10 +1761,18 @@ function addon_installed(string $addon_name, bool $check_hookless = false, bool

    // Check addon_registry hook
    $addon_name = filter_naughty($addon_name, true);
    global $FILE_ARRAY;
    if (@is_array($FILE_ARRAY)) { // quick installer
        $answer = file_array_exists('sources/hooks/systems/addon_registry/' . $addon_name . '.php');
        if ((!$answer) && ($check_custom)) {
            $answer = file_array_exists('sources_custom/hooks/systems/addon_registry/' . $addon_name . '.php');
        }
    } else {
        $answer = is_file(get_file_base() . '/sources/hooks/systems/addon_registry/' . $addon_name . '.php');
        if ((!$answer) && ($check_custom)) {
            $answer = is_file(get_file_base() . '/sources_custom/hooks/systems/addon_registry/' . $addon_name . '.php');
        }
    }

    // Check addons table
    if ((!$GLOBALS['IN_MINIKERNEL_VERSION']) && ($check_custom) && (!$GLOBALS['DEV_MODE']/*stuff maybe changed during dev*/)) {
@@ -4145,6 +4153,10 @@ function get_zone_default_page(string $zone_name, bool &$zone_missing = false) :
            }
        }
        if ($_zone_default_page === null) {
            if (running_script('install')) { // Can't run $SITE_DB in installer
                $ZONE_DEFAULT_PAGES_CACHE[$zone_name] = DEFAULT_ZONE_PAGE_NAME;
                return DEFAULT_ZONE_PAGE_NAME;
            }
            $_zone_default_page = $GLOBALS['SITE_DB']->query_select('zones', ['zone_name', 'zone_default_page', 'zone_title'], []/*Load multiple so we can cache for performance ['zone_name' => $zone_name]*/, 'ORDER BY zone_title', 50/*reasonable limit; zone_title is sequential for default zones*/);
        }
        foreach ($_zone_default_page as $zone_row) {
+5 −2
Original line number Diff line number Diff line
@@ -195,16 +195,19 @@ class Hook_health_check_install_env extends Hook_Health_Check
            return;
        }

        $installing = ($check_context == CHECK_CONTEXT__INSTALL);

        if (file_exists(get_file_base() . '/data/empty.php')) {
            $test_url = get_base_url() . '/data/empty.php'; // Should normally exist, simple static URL call
        } elseif ($installing) {
            $test_url = get_base_url() . '/install.php'; // But this definitely must exist if running the installer
        } else {
            $test_url = static_evaluate_tempcode(build_url(['page' => ''], '', [], false, false, true)); // But this definitely must exist
            $test_url = static_evaluate_tempcode(build_url(['page' => ''], '', [], false, false, true)); // This absolutely must exist otherwise
        }

        $test = cms_http_request($test_url, ['byte_limit' => 1, 'trigger_error' => false, 'no_redirect' => true]); // Should return a 200 blank, not an HTTP error or a redirect; actual data would be a software error

        $has_www = (strpos(get_base_url(), '://www.') !== false);
        $installing = ($check_context == CHECK_CONTEXT__INSTALL);

        if (in_array($test->message, ['200'])) {
            // Is okay
+6 −0
Original line number Diff line number Diff line
@@ -250,6 +250,12 @@ class Hook_health_check_integrity extends Hook_Health_Check
                return;
            }

            global $FILE_ARRAY;
            if (@is_array($FILE_ARRAY)) {
                $this->log('Skipped; not necessary in quick installer.');
                return;
            }

            /*Actually CMSPermissionsScannerSimplified will be used which is safer if (strpos(PHP_OS, 'WIN') !== false) {
                if ($sdc === null) {
                    return; // Too unreliable/slow, so has to be explicitly enabled
Loading