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
6 changes: 2 additions & 4 deletions .github/actions/freebsd/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ runs:
pkgconf \
webp \
libavif \
`#sqlite3` \
sqlite3 \
curl \
$OPCACHE_TLS_TESTS_DEPS
Expand All @@ -57,9 +57,7 @@ runs:
--enable-debug \
--enable-option-checking=fatal \
--enable-fpm \
`#--with-pdo-sqlite` \
--without-sqlite3 \
--without-pdo-sqlite \
--with-pdo-sqlite \
--without-pear \
--with-bz2 \
--with-avif \
Expand Down
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ PHP NEWS
(ilutov)
. Fixed bug GH-21362 (ReflectionMethod::invoke/invokeArgs() did not verify
Closure instance identity for Closure::__invoke()). (Ilia Alshanetsky)
. Added ReflectionParameter::getDocComment(). (chschneider)

- Session:
. Fixed bug 71162 (updateTimestamp never called when session data is empty).
Expand Down Expand Up @@ -141,6 +142,7 @@ PHP NEWS
. Fixed bug GH-13204 (glob() fails if square bracket is in current directory).
(ndossche)
. Add array size maximum to array_diff(). (ndossche)
. Add enum SortDirection. (timwolla)

- Streams:
. Added so_keepalive, tcp_keepidle, tcp_keepintvl and tcp_keepcnt stream
Expand Down
6 changes: 6 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ PHP 8.6 UPGRADE NOTES
. ReflectionConstant::inNamespace()
. Added ReflectionProperty::isReadable() and ReflectionProperty::isWritable().
RFC: https://wiki.php.net/rfc/isreadable-iswriteable
. Added ReflectionParameter::getDocComment().
RFC: https://wiki.php.net/rfc/parameter-doccomments

- Intl:
. `grapheme_strrev()` returns strrev for grapheme cluster unit.
Expand All @@ -161,6 +163,10 @@ PHP 8.6 UPGRADE NOTES
7. New Classes and Interfaces
========================================

- Standard:
. enum SortDirection
RFC: https://wiki.php.net/rfc/sort_direction_enum

========================================
8. Removed Extensions and SAPIs
========================================
Expand Down
1 change: 1 addition & 0 deletions Zend/zend_API.c
Original file line number Diff line number Diff line change
Expand Up @@ -2997,6 +2997,7 @@ ZEND_API void zend_convert_internal_arg_info(zend_arg_info *new_arg_info, const
new_arg_info->name = NULL;
new_arg_info->default_value = NULL;
}
new_arg_info->doc_comment = NULL;
new_arg_info->type = arg_info->type;
zend_convert_internal_arg_info_type(&new_arg_info->type, persistent);
}
Expand Down
2 changes: 2 additions & 0 deletions Zend/zend_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -8027,6 +8027,7 @@ static void zend_compile_params(zend_ast *ast, zend_ast *return_type_ast, uint32
} else {
arg_infos->type = (zend_type) ZEND_TYPE_INIT_CODE(fallback_return_type, 0, 0);
}
arg_infos->doc_comment = NULL;
arg_infos++;
op_array->fn_flags |= ZEND_ACC_HAS_RETURN_TYPE;

Expand Down Expand Up @@ -8125,6 +8126,7 @@ static void zend_compile_params(zend_ast *ast, zend_ast *return_type_ast, uint32
arg_info->name = zend_string_copy(name);
arg_info->type = (zend_type) ZEND_TYPE_INIT_NONE(0);
arg_info->default_value = NULL;
arg_info->doc_comment = doc_comment_ast ? zend_string_copy(zend_ast_get_str(doc_comment_ast)) : NULL;

if (attributes_ast) {
zend_compile_attributes(
Expand Down
1 change: 1 addition & 0 deletions Zend/zend_compile.h
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,7 @@ typedef struct _zend_arg_info {
zend_string *name;
zend_type type;
zend_string *default_value;
zend_string *doc_comment;
} zend_arg_info;

/* the following structure repeats the layout of zend_internal_arg_info,
Expand Down
6 changes: 3 additions & 3 deletions Zend/zend_language_parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -821,9 +821,9 @@ parameter:
{ $$ = zend_ast_create_ex(ZEND_AST_PARAM, $1 | $3 | $4, $2, $5, NULL,
NULL, $6 ? zend_ast_create_zval_from_str($6) : NULL, $7); }
| optional_cpp_modifiers optional_type_without_static
is_reference is_variadic T_VARIABLE backup_doc_comment '=' expr optional_property_hook_list
{ $$ = zend_ast_create_ex(ZEND_AST_PARAM, $1 | $3 | $4, $2, $5, $8,
NULL, $6 ? zend_ast_create_zval_from_str($6) : NULL, $9); }
is_reference is_variadic T_VARIABLE '=' expr backup_doc_comment optional_property_hook_list
{ $$ = zend_ast_create_ex(ZEND_AST_PARAM, $1 | $3 | $4, $2, $5, $7,
NULL, $8 ? zend_ast_create_zval_from_str($8) : NULL, $9); }
;

optional_type_without_static:
Expand Down
3 changes: 3 additions & 0 deletions Zend/zend_opcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,9 @@ ZEND_API void destroy_op_array(zend_op_array *op_array)
if (arg_info[i].name) {
zend_string_release_ex(arg_info[i].name, 0);
}
if (arg_info[i].doc_comment) {
zend_string_release_ex(arg_info[i].doc_comment, 0);
}
zend_type_release(arg_info[i].type, /* persistent */ false);
}
efree(arg_info);
Expand Down
2 changes: 1 addition & 1 deletion ext/opcache/jit/zend_jit.c
Original file line number Diff line number Diff line change
Expand Up @@ -2891,7 +2891,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
if (i == end
&& (opline->result_type & (IS_SMART_BRANCH_JMPZ|IS_SMART_BRANCH_JMPNZ)) != 0) {
/* smart branch split across basic blocks */
if (!zend_jit_set_cond(&ctx, opline + 2, opline->result.var)) {
if (!zend_jit_set_cond(&ctx, opline, opline + 2, opline->result.var)) {
goto jit_failure;
}
}
Expand Down
5 changes: 3 additions & 2 deletions ext/opcache/jit/zend_jit_ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -3967,11 +3967,12 @@ static int zend_jit_cond_jmp(zend_jit_ctx *jit, const zend_op *next_opline, int
return 1;
}

static int zend_jit_set_cond(zend_jit_ctx *jit, const zend_op *next_opline, uint32_t var)
static int zend_jit_set_cond(zend_jit_ctx *jit, const zend_op *opline, const zend_op *next_opline, uint32_t var)
{
ir_ref ref;

ref = ir_ADD_U32(ir_ZEXT_U32(jit_CMP_IP(jit, IR_EQ, next_opline)), ir_CONST_U32(IS_FALSE));
ir_op op = (opline->result_type & IS_SMART_BRANCH_JMPZ) ? IR_EQ : IR_NE;
ref = ir_ADD_U32(ir_ZEXT_U32(jit_CMP_IP(jit, op, next_opline)), ir_CONST_U32(IS_FALSE));

// EX_VAR(var) = ...
ir_STORE(ir_ADD_OFFSET(jit_FP(jit), var + offsetof(zval, u1.type_info)), ref);
Expand Down
49 changes: 49 additions & 0 deletions ext/opcache/tests/jit/gh21593.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
--TEST--
GH-21593: Function JIT JMPNZ smart branch
--CREDITS--
paulmhh
--EXTENSIONS--
opcache
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.jit=function
--FILE--
<?php

function test1($a) {
if (isset($a?->a)) {
echo "1\n";
}
}

function test2($a) {
if (!isset($a?->a)) {
echo "2\n";
}
}

function test3($a) {
if (empty($a?->a)) {
echo "3\n";
}
}

function test4($a) {
if (!empty($a?->a)) {
echo "4\n";
}
}

$a = new stdClass;
$a->a = 'a';

test1($a);
test2($a);
test3($a);
test4($a);

?>
--EXPECT--
1
4
3 changes: 3 additions & 0 deletions ext/opcache/zend_persist.c
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,9 @@ static void zend_persist_op_array_ex(zend_op_array *op_array, zend_persistent_sc
zend_accel_store_interned_string(arg_info[i].name);
}
zend_persist_type(&arg_info[i].type);
if (arg_info[i].doc_comment) {
zend_accel_store_interned_string(arg_info[i].doc_comment);
}
}
if (op_array->fn_flags & ZEND_ACC_HAS_RETURN_TYPE) {
arg_info++;
Expand Down
3 changes: 3 additions & 0 deletions ext/opcache/zend_persist_calc.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,9 @@ static void zend_persist_op_array_calc_ex(zend_op_array *op_array)
ADD_INTERNED_STRING(arg_info[i].name);
}
zend_persist_type_calc(&arg_info[i].type);
if (arg_info[i].doc_comment) {
ADD_INTERNED_STRING(arg_info[i].doc_comment);
}
}
}

Expand Down
6 changes: 3 additions & 3 deletions ext/openssl/openssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,9 @@ void php_openssl_store_errors(void)
errors = OPENSSL_G(errors);

do {
errors->top = (errors->top + 1) % ERR_NUM_ERRORS;
errors->top = (errors->top + 1) % PHP_OPENSSL_ERR_BUFFER_SIZE;
if (errors->top == errors->bottom) {
errors->bottom = (errors->bottom + 1) % ERR_NUM_ERRORS;
errors->bottom = (errors->bottom + 1) % PHP_OPENSSL_ERR_BUFFER_SIZE;
}
errors->buffer[errors->top] = error_code;
} while ((error_code = ERR_get_error()));
Expand Down Expand Up @@ -4042,7 +4042,7 @@ PHP_FUNCTION(openssl_error_string)
RETURN_FALSE;
}

OPENSSL_G(errors)->bottom = (OPENSSL_G(errors)->bottom + 1) % ERR_NUM_ERRORS;
OPENSSL_G(errors)->bottom = (OPENSSL_G(errors)->bottom + 1) % PHP_OPENSSL_ERR_BUFFER_SIZE;
val = OPENSSL_G(errors)->buffer[OPENSSL_G(errors)->bottom];

if (val) {
Expand Down
4 changes: 3 additions & 1 deletion ext/openssl/php_openssl.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ extern zend_module_entry openssl_module_entry;
#define PHP_OPENSSL_API_VERSION 0x30200
#endif

#define PHP_OPENSSL_ERR_BUFFER_SIZE 16

#define OPENSSL_RAW_DATA 1
#define OPENSSL_ZERO_PADDING 2
#define OPENSSL_DONT_ZERO_PAD_KEY 4
Expand Down Expand Up @@ -65,7 +67,7 @@ extern zend_module_entry openssl_module_entry;
#endif

struct php_openssl_errors {
int buffer[ERR_NUM_ERRORS];
int buffer[PHP_OPENSSL_ERR_BUFFER_SIZE];
int top;
int bottom;
};
Expand Down
1 change: 1 addition & 0 deletions ext/pdo_pgsql/config.w32
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ if (PHP_PDO_PGSQL != "no") {
CHECK_HEADER("libpq-fe.h", "CFLAGS_PDO_PGSQL", PHP_PDO_PGSQL + "\\include;" + PHP_PHP_BUILD + "\\include\\pgsql;" + PHP_PHP_BUILD + "\\include\\libpq;")) {
EXTENSION("pdo_pgsql", "pdo_pgsql.c pgsql_driver.c pgsql_statement.c pgsql_sql_parser.c");

AC_DEFINE('HAVE_PG_RESULT_MEMORY_SIZE', 1, "Define to 1 if libpq has the 'PQresultMemorySize' function (PostgreSQL 12 or later).");
AC_DEFINE('HAVE_PDO_PGSQL', 1, "Define to 1 if the PHP extension 'pdo_pgsql' is available.");

ADD_EXTENSION_DEP('pdo_pgsql', 'pdo');
Expand Down
8 changes: 4 additions & 4 deletions ext/pdo_sqlite/tests/bug38334.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ pdo_sqlite

$db = new PDO('sqlite::memory:');
$db->exec('CREATE TABLE test_38334 (i INTEGER , f DOUBLE, s VARCHAR(255))');
$db->exec('INSERT INTO test_38334 VALUES (42, 46.7, "test")');
$db->exec("INSERT INTO test_38334 VALUES (42, 46.7, 'test')");
var_dump($db->query('SELECT * FROM test_38334')->fetch(PDO::FETCH_ASSOC));

// Check handling of integers larger than 32-bit.
$db->exec('INSERT INTO test_38334 VALUES (10000000000, 0.0, "")');
$db->exec("INSERT INTO test_38334 VALUES (10000000000, 0.0, '')");
$i = $db->query('SELECT i FROM test_38334 WHERE f = 0.0')->fetchColumn(0);
if (PHP_INT_SIZE >= 8) {
var_dump($i === 10000000000);
Expand All @@ -20,8 +20,8 @@ if (PHP_INT_SIZE >= 8) {
}

// Check storing of strings into integer/float columns.
$db->exec('INSERT INTO test_38334 VALUES ("test", "test", "x")');
var_dump($db->query('SELECT * FROM test_38334 WHERE s = "x"')->fetch(PDO::FETCH_ASSOC));
$db->exec("INSERT INTO test_38334 VALUES ('test', 'test', 'x')");
var_dump($db->query("SELECT * FROM test_38334 WHERE s = 'x'")->fetch(PDO::FETCH_ASSOC));

?>
--EXPECT--
Expand Down
2 changes: 1 addition & 1 deletion ext/pdo_sqlite/tests/bug_42589.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if(!in_array('ENABLE_COLUMN_METADATA', $options, true))
$db = new PDO("sqlite::memory:");

$db->exec('CREATE TABLE test_42589 (field1 VARCHAR(10))');
$db->exec('INSERT INTO test_42589 VALUES("test")');
$db->exec("INSERT INTO test_42589 VALUES('test')");

$result = $db->query('SELECT * FROM test_42589 t1 LEFT JOIN test_42589 t2 ON t1.field1 = t2.field1');
$meta1 = $result->getColumnMeta(0);
Expand Down
2 changes: 1 addition & 1 deletion ext/pdo_sqlite/tests/pdo_sqlite_createaggregate.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ $db = new PDO('sqlite::memory:');

$db->query('CREATE TABLE test_pdo_sqlite_createaggregate (id INT AUTO INCREMENT, name TEXT)');

$db->query('INSERT INTO test_pdo_sqlite_createaggregate VALUES (NULL, "PHP"), (NULL, "PHP6")');
$db->query("INSERT INTO test_pdo_sqlite_createaggregate VALUES (NULL, 'PHP'), (NULL, 'PHP6')");

$db->sqliteCreateAggregate('testing', function(&$a, $b) { $a .= $b; return $a; }, function(&$v) { return $v; });

Expand Down
2 changes: 1 addition & 1 deletion ext/pdo_sqlite/tests/pdo_sqlite_createcollation.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

$db->query('CREATE TABLE test_pdo_sqlite_createcollation (id INT AUTO INCREMENT, name TEXT)');

$db->query('INSERT INTO test_pdo_sqlite_createcollation VALUES (NULL, "1"), (NULL, "2"), (NULL, "10")');
$db->query("INSERT INTO test_pdo_sqlite_createcollation VALUES (NULL, '1'), (NULL, '2'), (NULL, '10')");

$db->sqliteCreateCollation('MYCOLLATE', function($a, $b) { return strnatcmp($a, $b); });

Expand Down
2 changes: 1 addition & 1 deletion ext/pdo_sqlite/tests/pdo_sqlite_createfunction.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ $db = new PDO('sqlite::memory:');

$db->query('CREATE TABLE test_pdo_sqlite_createfunction (id INT AUTO INCREMENT, name TEXT)');

$db->query('INSERT INTO test_pdo_sqlite_createfunction VALUES (NULL, "PHP"), (NULL, "PHP6")');
$db->query("INSERT INTO test_pdo_sqlite_createfunction VALUES (NULL, 'PHP'), (NULL, 'PHP6')");


$db->sqliteCreateFunction('testing', function($v) { return strtolower($v); });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ $db = new PDO('sqlite::memory:');

$db->query('CREATE TABLE test_pdo_sqlite_createfunction_with_flags (id INT AUTO INCREMENT, name TEXT)');

$db->query('INSERT INTO test_pdo_sqlite_createfunction_with_flags VALUES (NULL, "PHP"), (NULL, "PHP6")');
$db->query("INSERT INTO test_pdo_sqlite_createfunction_with_flags VALUES (NULL, 'PHP'), (NULL, 'PHP6')");


$db->sqliteCreateFunction('testing', function($v) { return strtolower($v); }, 1, Pdo\Sqlite::DETERMINISTIC);
Expand Down
27 changes: 27 additions & 0 deletions ext/pdo_sqlite/tests/pdo_sqlite_dqs.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
--TEST--
PDO_sqlite: Testing DQS support
--EXTENSIONS--
pdo_sqlite
--SKIPIF--
<?php
$db = new PDO('sqlite::memory:');
try {
$db->exec('SELECT "test"');
} catch (\PDOException) {
die('skip SQLite is lacking DQS');
}
?>
--FILE--
<?php
$db = new PDO('sqlite::memory:');
$db->exec('CREATE TABLE test (s1 VARCHAR(255), s2 VARCHAR(255))');
$db->exec('INSERT INTO test VALUES (\'test\', "test")');
var_dump($db->query('SELECT * FROM test')->fetch(PDO::FETCH_ASSOC));
?>
--EXPECT--
array(2) {
["s1"]=>
string(4) "test"
["s2"]=>
string(4) "test"
}
2 changes: 1 addition & 1 deletion ext/pdo_sqlite/tests/pdo_sqlite_lastinsertid.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pdo_sqlite

$db = new PDO('sqlite::memory:');
$db->query('CREATE TABLE test_pdo_sqlite_lastinsertid (id INT AUTO INCREMENT, name TEXT)');
$db->query('INSERT INTO test_pdo_sqlite_lastinsertid VALUES (NULL, "PHP"), (NULL, "PHP6")');
$db->query("INSERT INTO test_pdo_sqlite_lastinsertid VALUES (NULL, 'PHP'), (NULL, 'PHP6')");
var_dump($db->query('SELECT * FROM test_pdo_sqlite_lastinsertid'));
var_dump($db->errorInfo());
var_dump($db->lastInsertId());
Expand Down
19 changes: 17 additions & 2 deletions ext/pdo_sqlite/tests/pdo_sqlite_parser.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ foreach ($queries as $k => $query) {
// One parameter
$queries = [
"SELECT * FROM {$table} WHERE '1' = ?",
"SELECT * FROM {$table} WHERE \"?\" IN (?, \"?\")",
"SELECT * FROM {$table} WHERE '?' IN (?, '?')",
"SELECT * FROM {$table} WHERE `a``?` = ?",
"SELECT * FROM {$table} WHERE \"a`?\" = ?",
"SELECT * FROM {$table} WHERE [a`?] = ?",
];

Expand All @@ -43,6 +42,22 @@ foreach ($queries as $k => $query) {
var_dump($stmt->fetch(PDO::FETCH_NUM) === [0 => 1]);
}

// Check if DQS are enabled.
$dqs = true;
try {
$db->exec('SELECT "test"');
} catch (\PDOException) {
$dqs = false;
}

if ($dqs) {
$stmt = $db->prepare("SELECT * FROM {$table} WHERE \"a`?\" = ?");
$stmt->execute([1]);
var_dump($stmt->fetch(PDO::FETCH_NUM) === [0 => 1]);
} else {
var_dump(true);
}

?>
--CLEAN--
<?php
Expand Down
Loading