ZipArchive create problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I am working on a class def to wrap ZipArchive in.

I have hit a snag that I cannot seem to solve.

I have the page issue an async request that calls this code
The result indicates that the zip archive was created successful
>>> But no zip file shows up where it should. <<<
I tried setting the write permission to prevent the archive from being
written and I get the expected result ( at newArch line indicated by // <<<<)
Result that is printed is at line marked //??<<<<

Note:
Regarding issue with ZipArchive::open not returning errors until close()
is called (manually or automatically), I think I coded it to catch the return
value of ZipArchive::open. But if the return value === TRUE, there is no
err code to catch.

I often hit on a syntax and/or logic solution to a problem such as this while I am
composing a query, such as this. That is not the case so far here.

I have posted a demo for highlighting the files involved at
www.jekillen.com/demos/ ->  Issue with ZipArchive::open

I did try to file a bug report after searching similar bugs and finding none.
But the bug report page timed out while I was composing the demo:
The bug report form did not want more that 20 lines of code in the form
fields. I use "performance issue", but I don't know that that label is intended
for this type of issue.

Here is the relevant code
4/12/2015
from Firefox console record of get request:
http://localhost/dev_lab/lab_8/?test=g&newArch=test_2.zip
(I also tried it with newArch=test.zip with no better result)

calling script in index.php:
else if($_GET['newArch'])
     {
      $_input = array();
      $_input['name'] = $_GET['newArch'];
      $_retStr = $_zip->run('newArch', $_input);
     }

__construct method
public function __construct($_cwd)
              {
               self::$_class = get_class($this);
               self::$_zipper = new ZipArchive;
               require_once("php/zpArchConst.php");
               self::$_zipErCodes = $_constER;
               self::$_cwd = $_cwd;
              }

code use in $_zip->run():

 public function run($_what, $_with)
              {
               $_out = array();
               $_errHead = self::$_class.'->'.__FUNCTION__;
               switch($_what)
                 {
                  case 'newArch': // create an archive
                  $_out = self::newArch($_with);
                  return $_out;
                  break;
                  // ..etc..

private function newArch($_input) //string: name with path relative to script
                {
                 $_out = array();
                 $_errHead = self::$_class.'->'.__FUNCTION__;
                 $_name = $_input['name'];
                 $_parent = dirname(getcwd().'/'.$_name);
                 if(!is_writable($_parent))
                   {
$_out['error'] = $_errHead.' error: '.$_parent.' does not have write permissions'; //<<<<
                    return $_out;
                   }
$_retStr = self::$_zipper->open($_name, ZIPARCHIVE::CREATE);
                 $_ret = self::$_zipper->close();
                 if($_retStr === TRUE && $_ret === true)
                   {
                    $_out['success'] = true;
                   }
                 else if($_retStr > 0)
                   {
$_out['error'] = $_errHead." error: ".self:: $_zipErCodes[$_retStr];
                   }
                 return $_out;
                }

What the index page does with the result:
else if($_GET['newArch'])
     {
      if($_retStr['error'])
        {
print $_GET['test']."\n".$_GET['newArch'].': '. $_retStr['error'];
        }
      else if($_retStr['success'])
        {
print $_GET['test']."\n".$_GET['newArch'].': archive created'; //??<<<<
        }
     }

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux