Skip to content

Commit

Permalink
Merge pull request #147 from ashnazg/master
Browse files Browse the repository at this point in the history
Fix tests 8.1+
  • Loading branch information
ashnazg authored Nov 24, 2024
2 parents 9b19afc + 5ad5baf commit 0870209
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 6 deletions.
5 changes: 1 addition & 4 deletions PEAR/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -1070,10 +1070,7 @@ function _readConfigDataFrom($file)
}

if ($version && version_compare("$version", '1', '<')) {
// no '@', it is possible that unserialize
// raises a notice but it seems to block IO to
// STDOUT if a '@' is used and a notice is raise
$data = unserialize($contents);
$data = @unserialize($contents);

if (!is_array($data) && !$data) {
if ($contents == serialize(false)) {
Expand Down
2 changes: 1 addition & 1 deletion PEAR/DependencyDB.php
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ function _getDepDB()

clearstatcache();
fclose($fp);
$data = unserialize(file_get_contents($this->_depdb));
$data = @unserialize(file_get_contents($this->_depdb));
$this->_cache = $data;
return $data;
}
Expand Down
2 changes: 1 addition & 1 deletion PEAR/Registry.php
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,7 @@ function _packageInfo($package = null, $key = null, $channel = 'pear.php.net')
clearstatcache();
$this->_closePackageFile($fp);
$data = file_get_contents($this->_packageFileName($package, $channel));
$data = unserialize($data);
$data = @unserialize($data);
if ($key === null) {
return $data;
}
Expand Down
56 changes: 56 additions & 0 deletions tests/PEAR_RunTest/test_bug10092post_raw1-81.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
--TEST--
PEAR_RunTest --POST_RAW-- normal
--SKIPIF--
<?php
if (!getenv('PHP_PEAR_RUNTESTS')) {
echo 'skip';
}
if (version_compare(PHP_VERSION, '8.1.0', '<')) {
echo 'skip';
}
?>
--POST_RAW--
Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737
-----------------------------20896060251896012921717172737
Content-Disposition: form-data; name="submitter"

testname
-----------------------------20896060251896012921717172737
Content-Disposition: form-data; name="pics"; filename="bug37276.txt"
Content-Type: text/plain

bug37276

-----------------------------20896060251896012921717172737--
--FILE--
<?php
var_dump($_FILES);
var_dump($_POST);
$fp = fopen('php://input', 'r');
$a = fread($fp, 8192);
fclose($fp);
var_dump($a);
?>
--EXPECTF--
array(1) {
["pics"]=>
array(6) {
["name"]=>
string(12) "bug37276.txt"
["full_path"]=>
string(12) "bug37276.txt"
["type"]=>
string(10) "text/plain"
["tmp_name"]=>
string(%d) "%s"
["error"]=>
int(0)
["size"]=>
int(%d)
}
}
array(1) {
["submitter"]=>
string(8) "testname"
}
string(0) ""
3 changes: 3 additions & 0 deletions tests/PEAR_RunTest/test_bug10092post_raw1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ PEAR_RunTest --POST_RAW-- normal
if (!getenv('PHP_PEAR_RUNTESTS')) {
echo 'skip';
}
if (version_compare(PHP_VERSION, '8.1.0', '>=')) {
echo 'skip';
}
?>
--POST_RAW--
Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737
Expand Down
65 changes: 65 additions & 0 deletions tests/PEAR_RunTest/test_bug10092upload-81.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
--TEST--
PEAR_RunTest --UPLOAD--
--SKIPIF--
<?php
if (!getenv('PHP_PEAR_RUNTESTS')) {
echo 'skip';
}
if (version_compare(PHP_VERSION, '8.1.0', '<')) {
echo 'skip';
}
?>
--POST--
hi=there&fool=you
--UPLOAD--
file1.txt=setup.php.inc
myfile2.txt=test_bug9971.phpt
--FILE--
<?php
var_dump($_FILES);
var_dump($_POST);
$fp = fopen('php://input', 'r');
$a = fread($fp, 8192);
fclose($fp);
var_dump($a);
?>
--EXPECTF--
array(2) {
["file1_txt"]=>
array(6) {
["name"]=>
string(13) "setup.php.inc"
["full_path"]=>
string(13) "setup.php.inc"
["type"]=>
string(10) "text/plain"
["tmp_name"]=>
string(%d) "%s"
["error"]=>
int(0)
["size"]=>
int(%d)
}
["myfile2_txt"]=>
array(6) {
["name"]=>
string(17) "test_bug9971.phpt"
["full_path"]=>
string(17) "test_bug9971.phpt"
["type"]=>
string(10) "text/plain"
["tmp_name"]=>
string(%d) "%s"
["error"]=>
int(0)
["size"]=>
int(%d)
}
}
array(2) {
["hi"]=>
string(5) "there"
["fool"]=>
string(3) "you"
}
string(0) ""
3 changes: 3 additions & 0 deletions tests/PEAR_RunTest/test_bug10092upload.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ PEAR_RunTest --UPLOAD--
if (!getenv('PHP_PEAR_RUNTESTS')) {
echo 'skip';
}
if (version_compare(PHP_VERSION, '8.1.0', '>=')) {
echo 'skip';
}
?>
--POST--
hi=there&fool=you
Expand Down

0 comments on commit 0870209

Please sign in to comment.