Skip to content

Commit 7a8ac62

Browse files
committed
Migrate PEAR_Installer away from $php_errormsg
1 parent ac4abec commit 7a8ac62

File tree

1 file changed

+32
-21
lines changed

1 file changed

+32
-21
lines changed

PEAR/Installer.php

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,9 @@ function _installFile($file, $atts, $tmp_path, $options)
323323
}
324324

325325
if (!@copy($orig_file, $dest_file)) {
326-
return $this->raiseError("failed to write $dest_file: $php_errormsg",
327-
PEAR_INSTALLER_FAILED);
326+
return $this->raiseError(
327+
"failed to write $dest_file: " . error_get_last()["message"],
328+
PEAR_INSTALLER_FAILED);
328329
}
329330

330331
$this->log(3, "+ cp $orig_file $dest_file");
@@ -399,13 +400,15 @@ function _installFile($file, $atts, $tmp_path, $options)
399400

400401
$wp = @fopen($dest_file, "wb");
401402
if (!is_resource($wp)) {
402-
return $this->raiseError("failed to create $dest_file: $php_errormsg",
403-
PEAR_INSTALLER_FAILED);
403+
return $this->raiseError(
404+
"failed to create $dest_file: " . error_get_last()["message"],
405+
PEAR_INSTALLER_FAILED);
404406
}
405407

406408
if (@fwrite($wp, $contents) === false) {
407-
return $this->raiseError("failed writing to $dest_file: $php_errormsg",
408-
PEAR_INSTALLER_FAILED);
409+
return $this->raiseError(
410+
"failed writing to $dest_file: " . error_get_last()["message"],
411+
PEAR_INSTALLER_FAILED);
409412
}
410413

411414
fclose($wp);
@@ -452,7 +455,8 @@ function _installFile($file, $atts, $tmp_path, $options)
452455
$this->addFileOperation("chmod", array($mode, $dest_file));
453456
if (!@chmod($dest_file, $mode)) {
454457
if (!isset($options['soft'])) {
455-
$this->log(0, "failed to change mode of $dest_file: $php_errormsg");
458+
$this->log(0, "failed to change mode of $dest_file: " .
459+
error_get_last()["message"]);
456460
}
457461
}
458462
}
@@ -562,8 +566,9 @@ function _installFile2(&$pkg, $file, &$real_atts, $tmp_path, $options)
562566
}
563567

564568
if (!@copy($orig_file, $dest_file)) {
565-
return $this->raiseError("failed to write $dest_file: $php_errormsg",
566-
PEAR_INSTALLER_FAILED);
569+
return $this->raiseError(
570+
"failed to write $dest_file: " . error_get_last()["message"],
571+
PEAR_INSTALLER_FAILED);
567572
}
568573

569574
$this->log(3, "+ cp $orig_file $dest_file");
@@ -605,13 +610,15 @@ function _installFile2(&$pkg, $file, &$real_atts, $tmp_path, $options)
605610

606611
$wp = @fopen($dest_file, "wb");
607612
if (!is_resource($wp)) {
608-
return $this->raiseError("failed to create $dest_file: $php_errormsg",
609-
PEAR_INSTALLER_FAILED);
613+
return $this->raiseError(
614+
"failed to create $dest_file: " . error_get_last()["message"],
615+
PEAR_INSTALLER_FAILED);
610616
}
611617

612618
if (fwrite($wp, $contents) === false) {
613-
return $this->raiseError("failed writing to $dest_file: $php_errormsg",
614-
PEAR_INSTALLER_FAILED);
619+
return $this->raiseError(
620+
"failed writing to $dest_file: " . error_get_last()["message"],
621+
PEAR_INSTALLER_FAILED);
615622
}
616623

617624
fclose($wp);
@@ -667,7 +674,8 @@ function _installFile2(&$pkg, $file, &$real_atts, $tmp_path, $options)
667674
$this->addFileOperation("chmod", array($mode, $dest_file));
668675
if (!@chmod($dest_file, $mode)) {
669676
if (!isset($options['soft'])) {
670-
$this->log(0, "failed to change mode of $dest_file: $php_errormsg");
677+
$this->log(0, "failed to change mode of $dest_file: " .
678+
error_get_last()["message"]);
671679
}
672680
}
673681
}
@@ -854,7 +862,7 @@ function commitFileTransaction()
854862

855863
if (!@copy($data[0], $data[0] . '.bak')) {
856864
$this->log(1, 'Could not copy ' . $data[0] . ' to ' . $data[0] .
857-
'.bak ' . $php_errormsg);
865+
'.bak ' . error_get_last()["message"]);
858866
return false;
859867
}
860868
$this->log(3, "+ backup $data[0] to $data[0].bak");
@@ -889,7 +897,7 @@ function commitFileTransaction()
889897
$perms = @fileperms($data[0]);
890898
if (!@copy($data[0], $data[1])) {
891899
$this->log(1, 'Could not rename ' . $data[0] . ' to ' . $data[1] .
892-
' ' . $php_errormsg);
900+
' ' . error_get_last()["message"]);
893901
return false;
894902
}
895903

@@ -901,7 +909,7 @@ function commitFileTransaction()
901909
case 'chmod':
902910
if (!@chmod($data[1], $data[0])) {
903911
$this->log(1, 'Could not chmod ' . $data[1] . ' to ' .
904-
decoct($data[0]) . ' ' . $php_errormsg);
912+
decoct($data[0]) . ' ' . error_get_last()["message"]);
905913
return false;
906914
}
907915

@@ -912,7 +920,7 @@ function commitFileTransaction()
912920
if (file_exists($data[0])) {
913921
if (!@unlink($data[0])) {
914922
$this->log(1, 'Could not delete ' . $data[0] . ' ' .
915-
$php_errormsg);
923+
error_get_last()["message"]);
916924
return false;
917925
}
918926
$this->log(3, "+ rm $data[0]");
@@ -934,7 +942,7 @@ function commitFileTransaction()
934942
closedir($testme);
935943
if (!@rmdir($data[0])) {
936944
$this->log(1, 'Could not rmdir ' . $data[0] . ' ' .
937-
$php_errormsg);
945+
error_get_last()["message"]);
938946
return false;
939947
}
940948
$this->log(3, "+ rmdir $data[0]");
@@ -1553,7 +1561,9 @@ function _compileSourceFiles($savechannel, &$filelist)
15531561
}
15541562

15551563
if (!@copy($ext['file'], $copyto)) {
1556-
return $this->raiseError("failed to write $copyto ($php_errormsg)", PEAR_INSTALLER_FAILED);
1564+
return $this->raiseError(
1565+
"failed to write $copyto (" . error_get_last()["message"] . ")",
1566+
PEAR_INSTALLER_FAILED);
15571567
}
15581568

15591569
$this->log(3, "+ cp $ext[file] $copyto");
@@ -1562,7 +1572,8 @@ function _compileSourceFiles($savechannel, &$filelist)
15621572
$mode = 0666 & ~(int)octdec($this->config->get('umask'));
15631573
$this->addFileOperation('chmod', array($mode, $copyto));
15641574
if (!@chmod($copyto, $mode)) {
1565-
$this->log(0, "failed to change mode of $copyto ($php_errormsg)");
1575+
$this->log(0, "failed to change mode of $copyto (" .
1576+
error_get_last()["message"] . ")");
15661577
}
15671578
}
15681579
}

0 commit comments

Comments
 (0)