logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

cvs: pear-core /PEAR Installer.php: msg#00240

Subject: cvs: pear-core /PEAR Installer.php
cellog          Sat May 28 17:46:58 2005 EDT

  Modified files:              
    /pear-core/PEAR     Installer.php 
  Log:
  properly handle 0-length files with replacements
  
http://cvs.php.net/diff.php/pear-core/PEAR/Installer.php?r1=1.208&r2=1.209&ty=u
Index: pear-core/PEAR/Installer.php
diff -u pear-core/PEAR/Installer.php:1.208 pear-core/PEAR/Installer.php:1.209
--- pear-core/PEAR/Installer.php:1.208  Thu May 19 10:58:15 2005
+++ pear-core/PEAR/Installer.php        Sat May 28 17:46:58 2005
@@ -18,7 +18,7 @@
  * @author     Greg Beaver <cellog@xxxxxxx>
  * @copyright  1997-2005 The PHP Group
  * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
- * @version    CVS: $Id: Installer.php,v 1.208 2005/05/19 14:58:15 cellog Exp $
+ * @version    CVS: $Id: Installer.php,v 1.209 2005/05/28 21:46:58 cellog Exp $
  * @link       http://pear.php.net/package/PEAR
  * @since      File available since Release 0.1
  */
@@ -317,7 +317,10 @@
                                          PEAR_INSTALLER_FAILED);
             }
             $fp = fopen($orig_file, "r");
-            $contents = fread($fp, filesize($orig_file));
+            $contents = @fread($fp, filesize($orig_file));
+            if ($contents === false) {
+                $contents = '';
+            }
             fclose($fp);
             if (isset($atts['md5sum'])) {
                 $md5sum = md5($contents);
@@ -375,7 +378,7 @@
                 return $this->raiseError("failed to create $dest_file: 
$php_errormsg",
                                          PEAR_INSTALLER_FAILED);
             }
-            if (!fwrite($wp, $contents)) {
+            if (fwrite($wp, $contents) === false) {
                 return $this->raiseError("failed writing to $dest_file: 
$php_errormsg",
                                          PEAR_INSTALLER_FAILED);
             }
@@ -496,7 +499,10 @@
                                          PEAR_INSTALLER_FAILED);
             }
             $fp = fopen($orig_file, "r");
-            $contents = fread($fp, filesize($orig_file));
+            $contents = @fread($fp, filesize($orig_file)); // filesize can be 0
+            if ($contents === false) {
+                $contents = '';
+            }
             fclose($fp);
             if (isset($attribs['md5sum'])) {
                 $md5sum = md5($contents);
@@ -508,7 +514,7 @@
                 if (!$task->isScript()) { // scripts are only handled after 
installation
                     $task->init($raw, $attribs, 
$pkg->getLastInstalledVersion());
                     $res = $task->startSession($pkg, $contents, 
$final_dest_file);
-                    if (!$res) {
+                    if ($res === false) {
                         continue; // skip this file
                     }
                     if (PEAR::isError($res)) {
@@ -521,7 +527,7 @@
                     return $this->raiseError("failed to create $dest_file: 
$php_errormsg",
                                              PEAR_INSTALLER_FAILED);
                 }
-                if (!fwrite($wp, $contents)) {
+                if (fwrite($wp, $contents) === false) {
                     return $this->raiseError("failed writing to $dest_file: 
$php_errormsg",
                                              PEAR_INSTALLER_FAILED);
                 }

-- 
PEAR CVS Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




<Prev in Thread] Current Thread [Next in Thread>