Bug #55195 [Com]: PharData::buildFromDirectory does not seem to close the file after archiving

2012-06-26 Thread ralph at ralphschindler dot com
Edit report at https://bugs.php.net/bug.php?id=55195&edit=1

 ID: 55195
 Comment by: ralph at ralphschindler dot com
 Reported by:kedomingo at gmail dot com
 Summary:PharData::buildFromDirectory does not seem to close
 the file after archiving
 Status: Open
 Type:   Bug
 Package:PHAR related
 Operating System:   Windows 7 Professional 32bit
 PHP Version:5.3.6
 Block user comment: N
 Private report: N

 New Comment:

Why should you be able to delete the currently open phar?

It seems to me that $file2 is still open for modification in PHP, for example, 
you can call setStub(), or add new files or metadata to the $phar you have 
open.  
Since this is the case,

Even unlinkArchive() seems to imply in its documentation that the $phar needs 
to 
have the reference removed before you can unlink it:

http://www.php.net/manual/en/phar.unlinkarchive.php

I am inclined to say that this is not an issue.


Previous Comments:

[2012-04-21 20:23:19] michaelmotes at email dot com

I worked around this bug by simply destroying the phar object, unset($phar).


[2011-07-12 22:37:59] kedomingo at gmail dot com

Description:

While I can create a file, write to it, close it, and delete it via unlink, I 
can't delete a file created by the buildFromDirectory function of PharData. I 
suspect that the file has been left open.

Test script:
---
\n";
if( !fwrite($f, 'test') )   echo "Could not write to $file \n";
if( !fclose($f) )   echo "Could not close $file \n";
if( !unlink($file) )echo "Could not delete $file \n";

if( !is_dir( $dir = dirname(__FILE__) . '/phartest' ) ) { /// Create test 
directory for PharData
mkdir( dirname(__FILE__) . '/phartest' );
for($i = 0; $i < 3; $i++) { $f = fopen($dir . "/file$i.txt", 'w'); 
fwrite($f, $i); fclose($f); };
}

$file2 = uniqid().".zip"; /// Create test archive in the same directory as the 
demo file
$phar = new PharData($file2);
if( $phar->buildFromDirectory($dir) )
if(!unlink($file2)) /// Did phar close the file? Can we delete it?
echo "Could not delete $file2!";
?>

Expected result:

I expect that the call to unlink($file2) will delete the newly created archive 
(with filename $file2)

Actual result:
--
Warning: unlink(<$file2>): Permission denied in C:\htdocs\phartest.php on line 
17 
Could not delete <$file2>!






-- 
Edit this bug report at https://bugs.php.net/bug.php?id=55195&edit=1


Bug #52406 [Com]: spl_autoload support phar with namespace

2011-10-28 Thread ralph at ralphschindler dot com
Edit report at https://bugs.php.net/bug.php?id=52406&edit=1

 ID: 52406
 Comment by: ralph at ralphschindler dot com
 Reported by:jinmoku at hotmail dot com
 Summary:spl_autoload support phar with namespace
 Status: Open
 Type:   Bug
 Package:PHAR related
 Operating System:   XP, OSX
 PHP Version:5.3.3
 Block user comment: N
 Private report: N

 New Comment:

This is not an issue, spl_autoload() is working as described, and furthermore, 
this is not a PHAR issue.

Can someone close?

-ralph


Previous Comments:

[2011-02-10 21:50:16] jinmoku at hotmail dot com

it's more a PHAR problem


[2011-02-10 21:49:24] jinmoku at hotmail dot com

Add detect_unicode to off for OSX :

ini_set('detect_unicode', false);


I think all the files should be automatically put in lowercase.


[2011-02-09 10:37:10] jinmoku at hotmail dot com

Only way to work :

$phar->addFromString(strtolower('index.php'), $index);
$phar->addFromString(strtolower('Framework/Test.php'), $contents);

or maybe do it in internal


[2010-07-23 11:11:51] jinmoku at hotmail dot com

Ok, I retry on XP and it's work, even if it isn't simple, a filename in project 
is not always in lowercase...

Unfortunately it's doesn't work on osx, we see : set_include_path('phar://' . 
__FILE__ . PATH_SEPARATOR . get_include_path());

but after the require_once the phar path's gone, i'll check on other system and 
I come back

;)


[2010-07-23 01:59:42] fel...@php.net

What I am saying is:

- Using require_once you might use (lowercase not required):
$phar->addFromString('Framework/Test.php', $contents);
require_once 'Framework/Test.php'; // the search is non-lowercased

- Using spl_autoload() you must use (lowercase required):
$phar->addFromString('framework/test.php', $contents);
$test = new Framework\Test(); // spl_autoload() searchs for the lowercased 
namespace/classname.php




The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

https://bugs.php.net/bug.php?id=52406


-- 
Edit this bug report at https://bugs.php.net/bug.php?id=52406&edit=1


[PHP-BUG] Bug #60164 [NEW]: Stubs of a specific length break phar_open_from_fp scanning for __HALT_COMPILER

2011-10-28 Thread ralph at ralphschindler dot com
From: 
Operating system: All
PHP version:  5.3SVN-2011-10-28 (snap)
Package:  PHAR related
Bug Type: Bug
Bug description:Stubs of a specific length break phar_open_from_fp scanning for 
__HALT_COMPILER

Description:

Stubs who's content before the __HALT_COMPILER(); registers between 1007 -
1023 
bytes (or an interval thereof) will force the function phar_open_from_fp()
to 
incorrectly throw an MAPPHAR_ALLOC_FAIL() or:

Fatal error: Uncaught exception 'UnexpectedValueException' with message
'internal 
corruption of phar "xxx/test.phar" (__HALT_COMPILER(); not found)' in 
xxx/test.php:5

This is due to an incorrect index in the memmove() call inside the function
that 
shifts the buffer to inspect the contents for the __HALT_COMPILER() token.

THis bug is exposed when opening a phar and iterating the contents.

Attached is a sample phar, test script, and patch

Test script:
---



Expected result:

Iterate the results.

Actual result:
--
Fatal error: Uncaught exception 'UnexpectedValueException' with message
'internal 
corruption of phar "xxx/test.phar" (__HALT_COMPILER(); not found)' in 
xxx/test.php:5

-- 
Edit bug report at https://bugs.php.net/bug.php?id=60164&edit=1
-- 
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=60164&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=60164&r=trysnapshot53
Try a snapshot (trunk):  
https://bugs.php.net/fix.php?id=60164&r=trysnapshottrunk
Fixed in SVN:
https://bugs.php.net/fix.php?id=60164&r=fixed
Fixed in SVN and need be documented: 
https://bugs.php.net/fix.php?id=60164&r=needdocs
Fixed in release:
https://bugs.php.net/fix.php?id=60164&r=alreadyfixed
Need backtrace:  
https://bugs.php.net/fix.php?id=60164&r=needtrace
Need Reproduce Script:   
https://bugs.php.net/fix.php?id=60164&r=needscript
Try newer version:   
https://bugs.php.net/fix.php?id=60164&r=oldversion
Not developer issue: 
https://bugs.php.net/fix.php?id=60164&r=support
Expected behavior:   
https://bugs.php.net/fix.php?id=60164&r=notwrong
Not enough info: 
https://bugs.php.net/fix.php?id=60164&r=notenoughinfo
Submitted twice: 
https://bugs.php.net/fix.php?id=60164&r=submittedtwice
register_globals:
https://bugs.php.net/fix.php?id=60164&r=globals
PHP 4 support discontinued:  
https://bugs.php.net/fix.php?id=60164&r=php4
Daylight Savings:https://bugs.php.net/fix.php?id=60164&r=dst
IIS Stability:   
https://bugs.php.net/fix.php?id=60164&r=isapi
Install GNU Sed: 
https://bugs.php.net/fix.php?id=60164&r=gnused
Floating point limitations:  
https://bugs.php.net/fix.php?id=60164&r=float
No Zend Extensions:  
https://bugs.php.net/fix.php?id=60164&r=nozend
MySQL Configuration Error:   
https://bugs.php.net/fix.php?id=60164&r=mysqlcfg



Bug #60164 [Com]: Stubs of a specific length break phar_open_from_fp scanning for __HALT_COMPILER

2011-10-28 Thread ralph at ralphschindler dot com
Edit report at https://bugs.php.net/bug.php?id=60164&edit=1

 ID: 60164
 Comment by: ralph at ralphschindler dot com
 Reported by:ralph at ralphschindler dot com
 Summary:Stubs of a specific length break phar_open_from_fp
 scanning for __HALT_COMPILER
 Status: Open
 Type:   Bug
 Package:PHAR related
 Operating System:   All
 PHP Version:5.3SVN-2011-10-28 (snap)
 Block user comment: N
 Private report: N

 New Comment:

This is the fix for the issue:

https://github.com/ralphschindler/php-
src/commit/5bf57e28b7090aaf0428a984b90a11d25c12b22e

I will prepare a patch for trunk/5_3/5_4 along with tests.


Previous Comments:

[2011-10-28 19:46:37] ralph at ralphschindler dot com

Description:

Stubs who's content before the __HALT_COMPILER(); registers between 1007 - 1023 
bytes (or an interval thereof) will force the function phar_open_from_fp() to 
incorrectly throw an MAPPHAR_ALLOC_FAIL() or:

Fatal error: Uncaught exception 'UnexpectedValueException' with message 
'internal 
corruption of phar "xxx/test.phar" (__HALT_COMPILER(); not found)' in 
xxx/test.php:5

This is due to an incorrect index in the memmove() call inside the function 
that 
shifts the buffer to inspect the contents for the __HALT_COMPILER() token.

THis bug is exposed when opening a phar and iterating the contents.

Attached is a sample phar, test script, and patch

Test script:
---



Expected result:

Iterate the results.

Actual result:
--
Fatal error: Uncaught exception 'UnexpectedValueException' with message 
'internal 
corruption of phar "xxx/test.phar" (__HALT_COMPILER(); not found)' in 
xxx/test.php:5






-- 
Edit this bug report at https://bugs.php.net/bug.php?id=60164&edit=1