Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ PHP NEWS
. Fixed ZTS OPcache build on Cygwin. (cmb)
. Added opcache.file_cache_read_only. (Samuel Melrose)
. Updated default value of opcache.jit_hot_loop. (Arnaud)
. Log a warning when opcache lock file permissions could not be changed.
(Taavi Eomäe)

- Output:
. Fixed calculation of aligned buffer size. (cmb)
Expand Down
16 changes: 9 additions & 7 deletions Zend/tests/generators/clone.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ function gen() {
yield;
}

$gen = gen();
clone $gen;

try {
$gen = gen();
clone $gen;
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}

?>
--EXPECTF--
Fatal error: Uncaught Error: Trying to clone an uncloneable object of class Generator in %s:%d
Stack trace:
#0 {main}
thrown in %s on line %d
--EXPECT--
Error: Trying to clone an uncloneable object of class Generator
13 changes: 7 additions & 6 deletions ext/dom/tests/modern/token_list/clone.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ dom

$dom = DOM\XMLDocument::createFromString('<root class="a b c"><child/></root>');
$element = $dom->documentElement;
clone $element->classList;
try {
clone $element->classList;
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}

?>
--EXPECTF--
Fatal error: Uncaught Error: Trying to clone an uncloneable object of class Dom\TokenList in %s:%d
Stack trace:
#0 {main}
thrown in %s on line %d
--EXPECT--
Error: Trying to clone an uncloneable object of class Dom\TokenList
11 changes: 6 additions & 5 deletions ext/gd/tests/gdimage_prevent_cloning.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ gd
--FILE--
<?php

try {
$img_src = imagecreatetruecolor(32, 32);
$img_dst = clone $img_src;
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}

?>
--EXPECTF--
Fatal error: Uncaught Error: Trying to clone an uncloneable object of class GdImage in %s:%d
Stack trace:
#0 {main}
thrown in %s on line %d
--EXPECT--
Error: Trying to clone an uncloneable object of class GdImage
14 changes: 8 additions & 6 deletions ext/mysqli/tests/mysqli_driver_unclonable.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ Trying to clone mysqli_driver object
mysqli
--FILE--
<?php

try {
$driver = new mysqli_driver;
$driver_clone = clone $driver;
print "done!";
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}

?>
--EXPECTF--
Fatal error: Uncaught Error: Trying to clone an uncloneable object of class mysqli_driver in %s:%d
Stack trace:
#0 {main}
thrown in %s on line %d
--EXPECT--
Error: Trying to clone an uncloneable object of class mysqli_driver
14 changes: 7 additions & 7 deletions ext/mysqli/tests/mysqli_result_unclonable.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ require_once 'skipifconnectfailure.inc';
if (!($res = mysqli_query($link, "SELECT 'good' AS morning")))
printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));

$res_clone = clone $res;
print "done!";
try {
$res_clone = clone $res;
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}
?>
--EXPECTF--
Fatal error: Uncaught Error: Trying to clone an uncloneable object of class mysqli_result in %s:%d
Stack trace:
#0 {main}
thrown in %s on line %d
--EXPECT--
Error: Trying to clone an uncloneable object of class mysqli_result
15 changes: 7 additions & 8 deletions ext/mysqli/tests/mysqli_stmt_unclonable.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ require_once 'skipifconnectfailure.inc';
if (!$stmt = mysqli_stmt_init($link))
printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));

/* no, still bails out */
$stmt_clone = clone $stmt;
print "done!";
try {
$stmt_clone = clone $stmt;
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}
?>
--EXPECTF--
Fatal error: Uncaught Error: Trying to clone an uncloneable object of class mysqli_stmt in %s:%d
Stack trace:
#0 {main}
thrown in %s on line %d
--EXPECT--
Error: Trying to clone an uncloneable object of class mysqli_stmt
15 changes: 7 additions & 8 deletions ext/mysqli/tests/mysqli_unclonable.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ require_once 'skipifconnectfailure.inc';
printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);

$link_clone = clone $link;
mysqli_close($link);
try {
$link_clone = clone $link;
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}

print "done!";
?>
--EXPECTF--
Fatal error: Uncaught Error: Trying to clone an uncloneable object of class mysqli in %s:%d
Stack trace:
#0 {main}
thrown in %s on line %d
--EXPECT--
Error: Trying to clone an uncloneable object of class mysqli
4 changes: 3 additions & 1 deletion ext/opcache/zend_shared_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ void zend_shared_alloc_create_lock(char *lockfile_path)
zend_accel_error_noreturn(ACCEL_LOG_FATAL, "Unable to create opcache lock file in %s: %s (%d)", lockfile_path, strerror(errno), errno);
}

fchmod(lock_file, 0666);
if (fchmod(lock_file, 0666) == -1) {
zend_accel_error(ACCEL_LOG_WARNING, "Unable to change opcache lock file permissions in %s: %s (%d)", lockfile_path, strerror(errno), errno);
}

val = fcntl(lock_file, F_GETFD, 0);
val |= FD_CLOEXEC;
Expand Down
1 change: 1 addition & 0 deletions ext/openssl/openssl_backend_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,7 @@ X509_STORE *php_openssl_setup_verify(zval *calist, uint32_t arg_num)
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(calist), item) {
zend_string *str = zval_try_get_string(item);
if (UNEXPECTED(!str)) {
X509_STORE_free(store);
return NULL;
}

Expand Down
22 changes: 22 additions & 0 deletions ext/openssl/tests/memory_leak_x509_store.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--TEST--
Memory leak of X509_STORE in php_openssl_setup_verify() on failure
--EXTENSIONS--
openssl
--FILE--
<?php

class MyStringable{
public function __toString(): string {
throw new Error('stop');
}
}

try {
openssl_pkcs7_verify("does not matter", 0, "does not matter", [new MyStringable]);
} catch (Error $e) {
echo $e->getMessage(), "\n";
}

?>
--EXPECT--
stop
13 changes: 7 additions & 6 deletions ext/pdo/tests/bug_77849.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.dirname(__FILE_
require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';

$db = PDOTest::factory();
$db2 = clone $db;
try {
$db2 = clone $db;
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}
?>
--EXPECTF--
Fatal error: Uncaught Error: Trying to clone an uncloneable object of class PDO in %s
Stack trace:
#0 {main}
thrown in %s on line %d
--EXPECT--
Error: Trying to clone an uncloneable object of class PDO
17 changes: 9 additions & 8 deletions ext/pdo/tests/bug_77849_2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ PDO Common: Bug #77849 (inconsistent state of cloned statament object)
pdo
--FILE--
<?php
$stmt = new PDOStatement();

clone $stmt;
?>
--EXPECTF--
Fatal error: Uncaught Error: Trying to clone an uncloneable object of class PDOStatement in %s:4
Stack trace:
#0 {main}
thrown in %s on line 4
try {
$stmt = new PDOStatement();
clone $stmt;
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}

?>
--EXPECT--
Error: Trying to clone an uncloneable object of class PDOStatement
13 changes: 7 additions & 6 deletions ext/reflection/tests/ReflectionClass_CannotClone_basic.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ TestFest PHP|Tek
--FILE--
<?php
$rc = new ReflectionClass("stdClass");
$rc2 = clone($rc);
try {
$rc2 = clone($rc);
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}
?>
--EXPECTF--
Fatal error: Uncaught Error: Trying to clone an uncloneable object of class ReflectionClass in %s:%d
Stack trace:
#0 {main}
thrown in %s on line %d
--EXPECT--
Error: Trying to clone an uncloneable object of class ReflectionClass
14 changes: 7 additions & 7 deletions ext/reflection/tests/ReflectionClass_isCloneable_001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,14 @@ $obj = new ReflectionClass('xmlwriter');
var_dump($obj->isCloneable());
$obj = new ReflectionObject(new XMLWriter);
var_dump($obj->isCloneable());
$h = clone new xmlwriter;
try {
$h = clone new xmlwriter;
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}

?>
--EXPECTF--
--EXPECT--
User class
bool(true)
bool(true)
Expand All @@ -68,8 +72,4 @@ bool(true)
Internal class - XMLWriter
bool(false)
bool(false)

Fatal error: Uncaught Error: Trying to clone an uncloneable object of class XMLWriter in %s:%d
Stack trace:
#0 {main}
thrown in %s on line %d
Error: Trying to clone an uncloneable object of class XMLWriter
16 changes: 8 additions & 8 deletions ext/xml/tests/bug78563.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ xml
--FILE--
<?php

$parser = xml_parser_create();
clone $parser;
try {
$parser = xml_parser_create();
clone $parser;
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}

?>
===DONE===
--EXPECTF--
Fatal error: Uncaught Error: Trying to clone an uncloneable object of class XMLParser in %s:%d
Stack trace:
#0 {main}
thrown in %s on line %d
--EXPECT--
Error: Trying to clone an uncloneable object of class XMLParser
21 changes: 10 additions & 11 deletions ext/xmlreader/tests/bug51936.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,19 @@ Bug #51936 (Crash with clone XMLReader)
xmlreader
--FILE--
<?php
echo "Test\n";

$xmlreader = new XMLReader();
$xmlreader->xml("<a><b/></a>");

$xmlreader->next();
$xmlreader2 = clone $xmlreader;
$xmlreader2->next();
?>
Done
--EXPECTF--
Test

Fatal error: Uncaught Error: Trying to clone an uncloneable object of class XMLReader in %s:%d
Stack trace:
#0 {main}
thrown in %s on line %d
try {
$xmlreader2 = clone $xmlreader;
$xmlreader2->next();
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}

?>
--EXPECT--
Error: Trying to clone an uncloneable object of class XMLReader
17 changes: 8 additions & 9 deletions tests/classes/factory_and_singleton_007.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ class test {
}
}

$obj = new test;
$clone = clone $obj;
$obj = NULL;
try {
$obj = new test;
$clone = clone $obj;
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}

echo "Done\n";
?>
--EXPECTF--
Fatal error: Uncaught Error: Call to protected test::__clone() from global scope in %s:%d
Stack trace:
#0 {main}
thrown in %s on line %d
--EXPECT--
Error: Call to protected test::__clone() from global scope
17 changes: 8 additions & 9 deletions tests/classes/factory_and_singleton_008.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ class test {
}
}

$obj = new test;
$clone = clone $obj;
$obj = NULL;
try {
$obj = new test;
$clone = clone $obj;
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}

echo "Done\n";
?>
--EXPECTF--
Fatal error: Uncaught Error: Call to private test::__clone() from global scope in %s:%d
Stack trace:
#0 {main}
thrown in %s on line %d
--EXPECT--
Error: Call to private test::__clone() from global scope