Skip to content

Commit

Permalink
Merge branch 'MDL-69071-400' of https://github.com/paulholden/moodle
Browse files Browse the repository at this point in the history
…into MOODLE_400_STABLE
  • Loading branch information
sarjona committed Dec 28, 2022
2 parents c6c7755 + 1aba16c commit 54cffd7
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions lib/componentlib.class.php
Expand Up @@ -302,9 +302,10 @@ public function install() {

$zipfile= $CFG->tempdir.'/'.$this->zipfilename;

if($contents = download_file_content($source)) {
$contents = download_file_content($source, null, null, true);
if ($contents->results && (int) $contents->status === 200) {
if ($file = fopen($zipfile, 'w')) {
if (!fwrite($file, $contents)) {
if (!fwrite($file, $contents->results)) {
fclose($file);
$this->errorstring='cannotsavezipfile';
return COMPONENT_ERROR;
Expand All @@ -319,7 +320,7 @@ public function install() {
return COMPONENT_ERROR;
}
/// Calculate its md5
$new_md5 = md5($contents);
$new_md5 = md5($contents->results);
/// Compare it with the remote md5 to check if we have the correct zip file
if (!$remote_md5 = $this->get_component_md5()) {
return COMPONENT_ERROR;
Expand Down Expand Up @@ -508,9 +509,10 @@ function get_all_components_md5() {
/// Not downloaded, let's do it now
$availablecomponents = array();

if ($contents = download_file_content($source)) {
$contents = download_file_content($source, null, null, true);
if ($contents->results && (int) $contents->status === 200) {
/// Split text into lines
$lines=preg_split('/\r?\n/',$contents);
$lines = preg_split('/\r?\n/', $contents->results);
/// Each line will be one component
foreach($lines as $line) {
$availablecomponents[] = explode(',', $line);
Expand Down Expand Up @@ -705,8 +707,9 @@ public function get_remote_list_of_languages() {
$source = 'https://download.moodle.org/langpack/' . $this->version . '/languages.md5';
$availablelangs = array();

if ($content = download_file_content($source)) {
$alllines = explode("\n", $content);
$contents = download_file_content($source, null, null, true);
if ($contents->results && (int) $contents->status === 200) {
$alllines = explode("\n", $contents->results);
foreach($alllines as $line) {
if (!empty($line)){
$availablelangs[] = explode(',', $line);
Expand Down

0 comments on commit 54cffd7

Please sign in to comment.