Skip to content

Commit

Permalink
MDL-58746 core: Add environment check for finfo
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed May 1, 2017
1 parent 6b2d3d3 commit 943c9c3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
5 changes: 5 additions & 0 deletions admin/environment.xml
Expand Up @@ -2043,6 +2043,11 @@
<ON_CHECK message="incompleteunicodesupport" />
</FEEDBACK>
</CUSTOM_CHECK>
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_finfo" level="required">
<FEEDBACK>
<ON_ERROR message="finforequired" />
</FEEDBACK>
</CUSTOM_CHECK>
</CUSTOM_CHECKS>
</MOODLE>
</COMPATIBILITY_MATRIX>
1 change: 1 addition & 0 deletions lang/en/admin.php
Expand Up @@ -599,6 +599,7 @@
It is recommended to install local copy of free GeoLite City database from MaxMind.<br />
IP address location is displayed on simple map or using Google Maps. Please note that you need to have a Google account and apply for free Google Maps API key to enable interactive maps.';
$string['iplookupmaxmindnote'] = 'This product includes GeoLite data created by MaxMind, available from <a href="http://www.maxmind.com/">http://www.maxmind.com/</a>.';
$string['finforequired'] = 'The finfo PHP extension is now required by Moodle, in order to improve mimetype decoding.';
$string['keeptagnamecase'] = 'Keep tag name casing';
$string['lang'] = 'Default language';
$string['langcache'] = 'Cache language menu';
Expand Down
17 changes: 17 additions & 0 deletions lib/upgradelib.php
Expand Up @@ -2479,3 +2479,20 @@ function check_libcurl_version(environment_results $result) {

return null;
}

/**
* Check if the finfo class is present.
*
* @param environment_results $result object to update, if relevant.
* @return environment_results|null updated results or null.
*/
function check_finfo(environment_results $result) {
if (!class_exists('finfo')) {
$result->setInfo('finfo extension not enabled');
$result->setStatus(false);

return $result;
}

return null;
}

0 comments on commit 943c9c3

Please sign in to comment.