Skip to content

Commit

Permalink
Merge branch 'MDL-72312_310' of https://github.com/stronk7/moodle int…
Browse files Browse the repository at this point in the history
…o MOODLE_310_STABLE
  • Loading branch information
andrewnicols committed Aug 26, 2021
2 parents d56f166 + 525b10b commit 5549586
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/push.yml
Expand Up @@ -55,9 +55,16 @@ jobs:
include:
- os: ubuntu-18.04
php: 7.2
# Need to disable both redis and memcached (both are optional) in order to keep igbinary installed.
# (there are dependencies that become broken if we just switch the igbinary version).
# Need to do this for php 7.2 because of a bug with current default igbinary
# versions used by GHA being >= 3.2.2 and <= 3.2.4 (buggy ones).
# TODO: MDL-72399 - Revert this patch once igbinary 3.2.5 or up is the default @ GHA.
extensions: :redis, :memcached, igbinary-3.2.6
db: mysqli
- os: ubuntu-18.04
php: 7.4
extensions:
db: pgsql

steps:
Expand Down Expand Up @@ -88,6 +95,7 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: ${{ matrix.extensions }}
coverage: none

- name: Checking out code from ${{ env.GITHUB_REF_SLUG }}
Expand Down
10 changes: 10 additions & 0 deletions admin/environment.xml
Expand Up @@ -3163,6 +3163,11 @@
<ON_CHECK message="sixtyfourbitswarning" />
</FEEDBACK>
</CUSTOM_CHECK>
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_igbinary322_version" level="optional">
<FEEDBACK>
<ON_CHECK message="igbinary322buggyversion" />
</FEEDBACK>
</CUSTOM_CHECK>
</CUSTOM_CHECKS>
</MOODLE>
<MOODLE version="3.10" requires="3.5">
Expand Down Expand Up @@ -3345,6 +3350,11 @@
<ON_CHECK message="sixtyfourbitswarning" />
</FEEDBACK>
</CUSTOM_CHECK>
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_igbinary322_version" level="optional">
<FEEDBACK>
<ON_CHECK message="igbinary322buggyversion" />
</FEEDBACK>
</CUSTOM_CHECK>
</CUSTOM_CHECKS>
</MOODLE>
<MOODLE version="3.11" requires="3.6">
Expand Down
1 change: 1 addition & 0 deletions lang/en/admin.php
Expand Up @@ -685,6 +685,7 @@
$string['choosefiletoedit'] = 'Choose file to edit';
$string['h5pgetcontenttypestask'] = 'Download available H5P content types from h5p.org';
$string['iconvrequired'] = 'Installing ICONV extension is required.';
$string['igbinary322buggyversion'] = 'The php-igbinary extension installed on the site can lead to problems when running with PHP 7.2. You are recommended to either upgrade to php-igbinary 3.2.5 or later, or alternatively to upgrade to PHP 7.3 or later.';
$string['ignore'] = 'Ignore';
$string['includemoduleuserdata'] = 'Include module user data';
$string['incompatibleblocks'] = 'Incompatible blocks';
Expand Down
53 changes: 53 additions & 0 deletions lib/upgradelib.php
Expand Up @@ -2427,6 +2427,59 @@ function check_sixtyfour_bits(environment_results $result) {
return null;
}

/**
* Check if the igbinary extension installed is buggy one
*
* There are a few php-igbinary versions that are buggy and
* return any unserialised array with wrong index. This defeats
* key() and next() operations on them.
*
* This library is used by MUC and also by memcached and redis
* when available.
*
* Let's inform if there is some problem when:
* - php 7.2 is being used (php 7.3 and up are immune).
* - the igbinary extension is installed.
* - the version of the extension is between 3.2.2 and 3.2.4.
* - the buggy behaviour is reproduced.
*
* @param environment_results $result object to update, if relevant.
* @return environment_results|null updated results or null.
*/
function check_igbinary322_version(environment_results $result) {

// No problem if using PHP version 7.3 and up.
$phpversion = normalize_version(phpversion());
if (version_compare($phpversion, '7.3', '>=')) {
return null;
}

// No problem if igbinary is not installed..
if (!function_exists('igbinary_serialize')) {
return null;
}

// No problem if using igbinary < 3.2.2 or > 3.2.4.
$igbinaryversion = normalize_version(phpversion('igbinary'));
if (version_compare($igbinaryversion, '3.2.2', '<') or version_compare($igbinaryversion, '3.2.4', '>')) {
return null;
}

// Let's verify the real behaviour to see if the bug is around.
// Note that we need this extra check because they released 3.2.5 with 3.2.4 version number, so
// over the paper, there are 3.2.4 working versions (3.2.5 ones with messed reflection version).
$data = [1, 2, 3];
$data = igbinary_unserialize(igbinary_serialize($data));
if (key($data) === 0) {
return null;
}

// Arrived here, we are using PHP 7.2 and a buggy verified igbinary version, let's inform and don't allow to continue.
$result->setInfo('igbinary version problem');
$result->setStatus(false);
return $result;
}

/**
* Assert the upgrade key is provided, if it is defined.
*
Expand Down

0 comments on commit 5549586

Please sign in to comment.