Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 453... Línea 453...
453
 */
453
 */
454
function upgrade_stale_php_files_present(): bool {
454
function upgrade_stale_php_files_present(): bool {
455
    global $CFG;
455
    global $CFG;
Línea 456... Línea 456...
456
 
456
 
-
 
457
    $someexamplesofremovedfiles = [
-
 
458
        // Removed in 5.0.
-
 
459
        '/admin/process_email.php',
-
 
460
        '/badges/preferences_form.php',
-
 
461
        '/lib/ajax/setuserpref.php',
-
 
462
        '/lib/cronlib.php',
-
 
463
        '/question/classes/local/bank/action_column_base.php',
-
 
464
        // Removed in 4.5.
-
 
465
        '/backup/util/ui/classes/copy/copy.php',
-
 
466
        '/backup/util/ui/yui/build/moodle-backup-backupselectall/moodle-backup-backupselectall.js',
-
 
467
        '/cache/classes/interfaces.php',
-
 
468
        '/cache/disabledlib.php',
457
    $someexamplesofremovedfiles = [
469
        '/cache/lib.php',
458
        // Removed in 4.4.
470
        // Removed in 4.4.
459
        '/README.txt',
471
        '/README.txt',
460
        '/lib/dataformatlib.php',
472
        '/lib/dataformatlib.php',
461
        '/lib/horde/readme_moodle.txt',
473
        '/lib/horde/readme_moodle.txt',
Línea 2456... Línea 2468...
2456
    }
2468
    }
2457
    return null;
2469
    return null;
2458
}
2470
}
Línea 2459... Línea 2471...
2459
 
2471
 
2460
/**
-
 
2461
 * Check if the igbinary extension installed is buggy one
-
 
2462
 *
-
 
2463
 * There are a few php-igbinary versions that are buggy and
-
 
2464
 * return any unserialised array with wrong index. This defeats
-
 
2465
 * key() and next() operations on them.
-
 
2466
 *
-
 
2467
 * This library is used by MUC and also by memcached and redis
-
 
2468
 * when available.
-
 
2469
 *
-
 
2470
 * Let's inform if there is some problem when:
-
 
2471
 *   - php 7.2 is being used (php 7.3 and up are immune).
-
 
2472
 *   - the igbinary extension is installed.
-
 
2473
 *   - the version of the extension is between 3.2.2 and 3.2.4.
-
 
2474
 *   - the buggy behaviour is reproduced.
-
 
2475
 *
-
 
2476
 * @param environment_results $result object to update, if relevant.
-
 
2477
 * @return environment_results|null updated results or null.
-
 
2478
 */
-
 
2479
function check_igbinary322_version(environment_results $result) {
-
 
2480
 
-
 
2481
    // No problem if using PHP version 7.3 and up.
-
 
2482
    $phpversion = normalize_version(phpversion());
-
 
2483
    if (version_compare($phpversion, '7.3', '>=')) {
-
 
2484
        return null;
-
 
2485
    }
-
 
2486
 
-
 
2487
    // No problem if igbinary is not installed..
-
 
2488
    if (!function_exists('igbinary_serialize')) {
-
 
2489
        return null;
-
 
2490
    }
-
 
2491
 
-
 
2492
    // No problem if using igbinary < 3.2.2 or > 3.2.4.
-
 
2493
    $igbinaryversion = normalize_version(phpversion('igbinary'));
-
 
2494
    if (version_compare($igbinaryversion, '3.2.2', '<') or version_compare($igbinaryversion, '3.2.4', '>')) {
-
 
2495
        return null;
-
 
2496
    }
-
 
2497
 
-
 
2498
    // Let's verify the real behaviour to see if the bug is around.
-
 
2499
    // Note that we need this extra check because they released 3.2.5 with 3.2.4 version number, so
-
 
2500
    // over the paper, there are 3.2.4 working versions (3.2.5 ones with messed reflection version).
-
 
2501
    $data = [1, 2, 3];
-
 
2502
    $data = igbinary_unserialize(igbinary_serialize($data));
-
 
2503
    if (key($data) === 0) {
-
 
2504
        return null;
-
 
2505
    }
-
 
2506
 
-
 
2507
    // Arrived here, we are using PHP 7.2 and a buggy verified igbinary version, let's inform and don't allow to continue.
-
 
2508
    $result->setInfo('igbinary version problem');
-
 
2509
    $result->setStatus(false);
-
 
2510
    return $result;
-
 
2511
}
-
 
2512
 
-
 
2513
/**
2472
/**
2514
 * This function checks that the database prefix ($CFG->prefix) is <= xmldb_table::PREFIX_MAX_LENGTH
2473
 * This function checks that the database prefix ($CFG->prefix) is <= xmldb_table::PREFIX_MAX_LENGTH
2515
 *
2474
 *
2516
 * @param environment_results $result
2475
 * @param environment_results $result
2517
 * @return environment_results|null updated results object, or null if the prefix check is passing ok.
2476
 * @return environment_results|null updated results object, or null if the prefix check is passing ok.
Línea 2547... Línea 2506...
2547
 
2506
 
2548
    if (isset($CFG->config_php_settings['upgradekey'])) {
2507
    if (isset($CFG->config_php_settings['upgradekey'])) {
2549
        if ($upgradekeyhash === null or $upgradekeyhash !== sha1($CFG->config_php_settings['upgradekey'])) {
2508
        if ($upgradekeyhash === null or $upgradekeyhash !== sha1($CFG->config_php_settings['upgradekey'])) {
2550
            if (!$PAGE->headerprinted) {
2509
            if (!$PAGE->headerprinted) {
-
 
2510
                $PAGE->set_title(get_string('upgradekeyreq', 'admin'));
-
 
2511
                $PAGE->requires->js_call_amd('core/togglesensitive', 'init', ['upgradekey']);
-
 
2512
 
2551
                $PAGE->set_title(get_string('upgradekeyreq', 'admin'));
2513
                /** @var core_admin_renderer $output */
2552
                $output = $PAGE->get_renderer('core', 'admin');
2514
                $output = $PAGE->get_renderer('core', 'admin');
2553
                echo $output->upgradekey_form_page(new moodle_url('/admin/index.php', array('cache' => 0)));
2515
                echo $output->upgradekey_form_page(new moodle_url('/admin/index.php', array('cache' => 0)));
2554
                die();
2516
                die();
2555
            } else {
2517
            } else {
Línea 2731... Línea 2693...
2731
function check_max_input_vars(environment_results $result) {
2693
function check_max_input_vars(environment_results $result) {
2732
    $max = (int)ini_get('max_input_vars');
2694
    $max = (int)ini_get('max_input_vars');
2733
    if ($max < 5000) {
2695
    if ($max < 5000) {
2734
        $result->setInfo('max_input_vars');
2696
        $result->setInfo('max_input_vars');
2735
        $result->setStatus(false);
2697
        $result->setStatus(false);
2736
        if (PHP_VERSION_ID >= 80000) {
-
 
2737
            // For PHP8 this check is required.
-
 
2738
            $result->setLevel('required');
2698
        $result->setLevel('required');
2739
            $result->setFeedbackStr('settingmaxinputvarsrequired');
2699
        $result->setFeedbackStr('settingmaxinputvarsrequired');
2740
        } else {
-
 
2741
            // For PHP7 this check is optional (recommended).
-
 
2742
            $result->setFeedbackStr('settingmaxinputvars');
-
 
2743
        }
-
 
2744
        return $result;
2700
        return $result;
2745
    }
2701
    }
2746
    return null;
2702
    return null;
2747
}
2703
}
Línea 2824... Línea 2780...
2824
 
2780
 
2825
    return null;
2781
    return null;
Línea 2826... Línea 2782...
2826
}
2782
}
2827
 
2783
 
2828
/**
-
 
2829
 * Check whether the Oracle database is currently being used and warn if so.
-
 
2830
 *
-
 
2831
 * The Oracle database support will be removed in a future version (4.5) as it is no longer supported by PHP.
-
 
2832
 *
-
 
2833
 * @param environment_results $result object to update, if relevant
2784
/**
2834
 * @return environment_results|null updated results or null if the current database is not Oracle.
2785
 * Check if asynchronous backups are enabled.
-
 
2786
 *
2835
 *
2787
 * @param environment_results $result
2836
 * @see https://tracker.moodle.org/browse/MDL-80166 for further information.
2788
 * @return environment_results|null
2837
 */
2789
 */
Línea 2838... Línea -...
2838
function check_oracle_usage(environment_results $result): ?environment_results {
-
 
2839
    global $CFG;
2790
function check_async_backup(environment_results $result): ?environment_results {
2840
 
2791
    global $CFG;
2841
    // Checking database type.
2792
 
2842
    if ($CFG->dbtype === 'oci') {
2793
    if (!during_initial_install() && empty($CFG->enableasyncbackup)) { // Have to use $CFG as config table may not be available.
2843
        $result->setInfo('oracle_database_usage');
2794
        $result->setInfo('Asynchronous backups disabled');
Línea 2844... Línea 2795...
2844
        $result->setFeedbackStr('oracledatabaseinuse');
2795
        $result->setFeedbackStr('asyncbackupdisabled');
2845
        return $result;
2796
        return $result;
Línea 2846... Línea 2797...
2846
    }
2797
    }
2847
 
2798
 
2848
    return null;
2799
    return null;
-
 
2800
}
-
 
2801
 
2849
}
2802
/**
2850
 
2803
 * Checks if the current database vendor is Aurora MySQL.
2851
/**
2804
 *
2852
 * Check if asynchronous backups are enabled.
2805
 * If the database vendor is 'auroramysql', this function sets additional information.
2853
 *
2806
 *
Línea 2854... Línea 2807...
2854
 * @param environment_results $result
2807
 * @param environment_results $result The environment results object to update.
2855
 * @return environment_results|null
2808
 * @return environment_results|null The updated environment results object if Aurora is detected, or null otherwise.
2856
 */
2809
 */
2857
function check_async_backup(environment_results $result): ?environment_results {
2810
function check_aurora_version(environment_results $result): ?environment_results {
2858
    global $CFG;
2811
    global $CFG;
Línea 2859... Línea 2812...
2859
 
2812
 
2860
    if (!during_initial_install() && empty($CFG->enableasyncbackup)) { // Have to use $CFG as config table may not be available.
2813
    if ($CFG->dbtype === 'auroramysql') {