Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
f1fc4e8
Fix GH-16957: Assertion failure in array_shift with self-referencing …
nielsdos Nov 27, 2024
ab7c3b1
Merge branch 'PHP-8.3' into PHP-8.4
nielsdos Nov 29, 2024
563da1b
Merge branch 'PHP-8.4'
nielsdos Nov 29, 2024
1668a16
Improve php-src docs sphinx build, also on *nix (GH-16743)
hakre Nov 29, 2024
94fa2a4
Fix potential OOB read in zend_dirname() on Windows
cmb69 Nov 29, 2024
65070bb
Merge branch 'PHP-8.2' into PHP-8.3
cmb69 Nov 29, 2024
ba7dee5
Merge branch 'PHP-8.3' into PHP-8.4
cmb69 Nov 29, 2024
fdd3839
Merge branch 'PHP-8.4'
cmb69 Nov 29, 2024
8b68274
Fix method calls for PHP objects wrapped in variant
cmb69 Nov 26, 2024
be69262
gen_stub: drop support for `@refcount 0` with scalar return (#16505)
DanielEScherzer Nov 30, 2024
b06f2bc
Improve documentation generation
kocsismate Nov 30, 2024
aab7842
Fix GH-16998: UBSAN warning in rfc1867
nielsdos Nov 30, 2024
4eaa6f9
Merge branch 'PHP-8.2' into PHP-8.3
nielsdos Dec 1, 2024
c06a1a4
Merge branch 'PHP-8.3' into PHP-8.4
nielsdos Dec 1, 2024
51aee38
Merge branch 'PHP-8.4'
nielsdos Dec 1, 2024
73ebc92
Fix GH-16959: snmpget modifies the `object_id` (as array).
devnexen Nov 27, 2024
60eca67
Merge branch 'PHP-8.2' into PHP-8.3
devnexen Dec 1, 2024
6419ae4
Merge branch 'PHP-8.3' into PHP-8.4
devnexen Dec 1, 2024
917e120
Merge branch 'PHP-8.4'
devnexen Dec 1, 2024
d7a37cc
Add missing backslash for TokenList interfaces in stub (#17009)
nielsdos Dec 1, 2024
514cd20
Merge branch 'PHP-8.4'
nielsdos Dec 1, 2024
1d2c544
Refactor disp_invokeex() to avoid superfluous recheck (GH-17001)
cmb69 Dec 1, 2024
03bb112
Fix GH-16984: function JIT overflow bug (#17015)
dstogov Dec 2, 2024
7c4ed6a
Merge branch 'PHP-8.4'
dstogov Dec 2, 2024
bc7902d
Added mysqlnd.collect_memory_statistics to ini quick reference (#16819)
hauk92 Nov 15, 2024
c2d3734
Fix GH-15964: printf() can strip sign of -INF
divinity76 Sep 21, 2024
3b517e0
Merge branch 'PHP-8.4'
cmb69 Dec 2, 2024
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
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,7 @@ max_line_length = 80

[*.patch]
trim_trailing_whitespace = false

[*.rst]
indent_style = space
max_line_length = 100
4 changes: 2 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ jobs:
- name: git checkout
uses: actions/checkout@v4
- name: Install dependencies
run: pip install sphinx-design sphinxawesome-theme rstfmt
run: pip install -r docs/requirements.txt
- name: Check formatting
run: rstfmt --check -w 100 docs/source
run: make -C docs check-formatting
- name: Publish
if: github.event_name == 'push'
uses: sphinx-notes/pages@v3
Expand Down
7 changes: 6 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ PHP NEWS
?? ??? ????, PHP 8.5.0alpha1

- COM:
. Fix property access of PHP objects wrapped in variant. (cmb)
. Fixed property access of PHP objects wrapped in variant. (cmb)
. Fixed method calls for PHP objects wrapped in variant. (cmb)

- Core:
. Fixed bug GH-16665 (\array and \callable should not be usable in
Expand All @@ -20,6 +21,10 @@ PHP NEWS
- Intl:
. Bumped ICU requirement to ICU >= 57.1. (cmb)

- MySQLnd:
. Added mysqlnd.collect_memory_statistics to ini quick reference.
(hauk92)

- OPcache:
. Fixed ZTS OPcache build on Cygwin. (cmb)
. Added opcache.file_cache_read_only. (Samuel Melrose)
Expand Down
6 changes: 3 additions & 3 deletions Zend/zend_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -2196,7 +2196,7 @@ ZEND_API size_t zend_dirname(char *path, size_t len)
}

/* Strip trailing slashes */
while (end >= path && IS_SLASH_P(end)) {
while (end >= path && IS_SLASH_P_EX(end, end == path)) {
end--;
}
if (end < path) {
Expand All @@ -2207,7 +2207,7 @@ ZEND_API size_t zend_dirname(char *path, size_t len)
}

/* Strip filename */
while (end >= path && !IS_SLASH_P(end)) {
while (end >= path && !IS_SLASH_P_EX(end, end == path)) {
end--;
}
if (end < path) {
Expand All @@ -2218,7 +2218,7 @@ ZEND_API size_t zend_dirname(char *path, size_t len)
}

/* Strip slashes which came before the file name */
while (end >= path && IS_SLASH_P(end)) {
while (end >= path && IS_SLASH_P_EX(end, end == path)) {
end--;
}
if (end < path) {
Expand Down
5 changes: 5 additions & 0 deletions Zend/zend_virtual_cwd.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,11 @@ typedef unsigned short mode_t;
#define DEFAULT_SLASH '\\'
#define DEFAULT_DIR_SEPARATOR ';'
#define IS_SLASH(c) ((c) == '/' || (c) == '\\')
// IS_SLASH_P() may read the previous char on Windows, which may be OOB; use IS_SLASH_P_EX() instead
#define IS_SLASH_P(c) (*(c) == '/' || \
(*(c) == '\\' && !IsDBCSLeadByte(*(c-1))))
#define IS_SLASH_P_EX(c, first_byte) (*(c) == '/' || \
(*(c) == '\\' && ((first_byte) || !IsDBCSLeadByte(*(c-1)))))

/* COPY_WHEN_ABSOLUTE is 2 under Win32 because by chance both regular absolute paths
in the file system and UNC paths need copying of two characters */
Expand Down Expand Up @@ -110,7 +113,9 @@ typedef unsigned short mode_t;
#endif

#define IS_SLASH(c) ((c) == '/')
// IS_SLASH_P() may read the previous char on Windows, which may be OOB; use IS_SLASH_P_EX() instead
#define IS_SLASH_P(c) (*(c) == '/')
#define IS_SLASH_P_EX(c, first_byte) IS_SLASH_P(c)

#endif

Expand Down
31 changes: 17 additions & 14 deletions build/gen_stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -1159,8 +1159,7 @@ class ReturnInfo {
const REFCOUNT_1 = "1";
const REFCOUNT_N = "N";

const REFCOUNTS = [
self::REFCOUNT_0,
const REFCOUNTS_NONSCALAR = [
self::REFCOUNT_1,
self::REFCOUNT_N,
];
Expand Down Expand Up @@ -1204,16 +1203,14 @@ private function setRefcount(?string $refcount): void
return;
}

if (!in_array($refcount, ReturnInfo::REFCOUNTS, true)) {
throw new Exception("@refcount must have one of the following values: \"0\", \"1\", \"N\", $refcount given");
}

if ($isScalarType && $refcount !== self::REFCOUNT_0) {
throw new Exception('A scalar return type of "' . $type->__toString() . '" must have a refcount of "' . self::REFCOUNT_0 . '"');
if ($isScalarType) {
throw new Exception(
"@refcount on functions returning scalar values is redundant and not permitted"
);
}

if (!$isScalarType && $refcount === self::REFCOUNT_0) {
throw new Exception('A non-scalar return type of "' . $type->__toString() . '" cannot have a refcount of "' . self::REFCOUNT_0 . '"');
if (!in_array($refcount, ReturnInfo::REFCOUNTS_NONSCALAR, true)) {
throw new Exception("@refcount must have one of the following values: \"1\", \"N\", $refcount given");
}

$this->refcount = $refcount;
Expand Down Expand Up @@ -2613,7 +2610,7 @@ protected function getFieldSynopsisDefaultLinkend(): string
{
$className = str_replace(["\\", "_"], ["-", "-"], $this->name->class->toLowerString());

return "$className.constants." . strtolower(str_replace(["__", "_"], ["", "-"], $this->name->getDeclarationName()));
return "$className.constants." . strtolower(str_replace("_", "-", trim($this->name->getDeclarationName(), "_")));
}

protected function getFieldSynopsisName(): string
Expand Down Expand Up @@ -3055,7 +3052,7 @@ protected function getFieldSynopsisDefaultLinkend(): string
{
$className = str_replace(["\\", "_"], ["-", "-"], $this->name->class->toLowerString());

return "$className.props." . strtolower(str_replace(["__", "_"], ["", "-"], $this->name->getDeclarationName()));
return "$className.props." . strtolower(str_replace("_", "-", trim($this->name->getDeclarationName(), "_")));
}

protected function getFieldSynopsisName(): string
Expand Down Expand Up @@ -6427,8 +6424,14 @@ function(?ArgInfo $aliasArg, ?ArgInfo $aliasedArg) use ($aliasFunc, $aliasedFunc
}

foreach ($methodSynopses as $filename => $content) {
if (!file_exists("$manualTarget/$filename")) {
if (file_put_contents("$manualTarget/$filename", $content)) {
$path = "$manualTarget/$filename";

if (!file_exists($path)) {
if (!file_exists(dirname($path))) {
mkdir(dirname($path));
}

if (file_put_contents($path, $content)) {
echo "Saved $filename\n";
}
}
Expand Down
36 changes: 36 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Makefile for php-src/docs
# Copyright (c) The PHP Group

# If people set these on the make command line, use 'em

SPHINXBUILD ?= sphinx-build

SOURCEDIR = source
BUILDDIR = build
RSTFMT = rstfmt
RSTFMTFLAGS = -w 100

rwildcard = $(foreach d,$(wildcard $(1:=/*)),$(call rwildcard,$d,$2) $(filter $(subst *,%,$2),$d))
FILES = $(call rwildcard,$(SOURCEDIR),*.rst)

all : html

.PHONY : check-formatting clean html preflight
.SUFFIXES : # Disable legacy behavior

check-formatting :
$(RSTFMT) $(RSTFMTFLAGS) --check $(SOURCEDIR)

clean :
rm -rf -- $(wildcard $(SOURCEDIR)/.~ $(BUILDDIR))

html : preflight
$(SPHINXBUILD) -M $@ $(SOURCEDIR) $(BUILDDIR)
@printf 'Browse the \e]8;;%s\e\\%s\e]8;;\e\\.\n' \
"file://$(abspath $(BUILDDIR))/$@/index.$@" "php-src html docs locally"

preflight : $(SOURCEDIR)/.~

$(SOURCEDIR)/.~ : $(FILES)
$(RSTFMT) $(RSTFMTFLAGS) $?
touch $@
19 changes: 12 additions & 7 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# php-src docs

This is the home of the php-src internal documentation, hosted at
[php.github.io/php-src/](https://php.github.io/php-src/). It is in very early stages, but is
intended to become the primary place where new information about php-src is documented. Over time,
it is expected to replace various mediums like:
[php.github.io/php-src/](https://php.github.io/php-src/). It is in very early
stages, but is intended to become the primary place where new information about
php-src is documented. Over time, it is expected to replace various mediums
like:

* https://www.phpinternalsbook.com/
* https://wiki.php.net/internals
Expand All @@ -14,11 +15,15 @@ it is expected to replace various mediums like:
`python` 3 and `pip` are required.

```bash
pip install sphinx sphinx-design sphinxawesome-theme
cd docs
# Recommended: Initialize and activate a Python virtual environment
pip install --upgrade pip
pip install -r requirements.txt
make html
```

That's it! You can view the documentation under `./build/html/index.html` in your browser.
That's it! You can view the documentation under `./build/html/index.html` in
your browser.

## Formatting

Expand All @@ -29,5 +34,5 @@ The files in this documentation are formatted using the
rstfmt -w 100 source
```

This tool is not perfect. It breaks on custom directives, so we might switch to either a fork or
something else in the future.
This tool is not perfect. It breaks on custom directives, so we might switch to
either a fork or something else in the future.
35 changes: 0 additions & 35 deletions docs/make.bat

This file was deleted.

4 changes: 4 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Sphinx
sphinx-design
sphinxawesome-theme
rstfmt
1 change: 0 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
author = 'The PHP Group'
extensions = [
'sphinx_design',
'sphinxawesome_theme.highlighting',
]
templates_path = ['_templates']
html_theme = 'sphinxawesome_theme'
Expand Down
45 changes: 21 additions & 24 deletions ext/com_dotnet/com_wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,39 +256,34 @@ static HRESULT STDMETHODCALLTYPE disp_invokeex(

/* TODO: if PHP raises an exception here, we should catch it
* and expose it as a COM exception */

if (wFlags & DISPATCH_PROPERTYGET) {
retval = zend_read_property(Z_OBJCE(disp->object), Z_OBJ(disp->object), Z_STRVAL_P(name), Z_STRLEN_P(name), 1, &rv);
ret = S_OK;
} else if (wFlags & DISPATCH_PROPERTYPUT) {
zend_fcall_info_cache fcc;
if (wFlags & DISPATCH_PROPERTYPUT) {
zend_update_property(Z_OBJCE(disp->object), Z_OBJ(disp->object), Z_STRVAL_P(name), Z_STRLEN_P(name), &params[0]);
ret = S_OK;
} else if (wFlags & DISPATCH_METHOD) {
} else if (wFlags & DISPATCH_METHOD && zend_is_callable_ex(name, Z_OBJ(disp->object), 0, NULL, &fcc, NULL)) {
zend_try {
retval = &rv;
if (SUCCESS == call_user_function(NULL, &disp->object, name,
retval, pdp->cArgs, params)) {
ret = S_OK;
trace("function called ok\n");

/* Copy any modified values to callers copy of variant*/
for (i = 0; i < pdp->cArgs; i++) {
php_com_dotnet_object *obj = CDNO_FETCH(&params[i]);
VARIANT *srcvar = &obj->v;
VARIANT *dstvar = &pdp->rgvarg[ pdp->cArgs - 1 - i];
if ((V_VT(dstvar) & VT_BYREF) && obj->modified ) {
trace("percolate modified value for arg %u VT=%08x\n", i, V_VT(dstvar));
php_com_copy_variant(dstvar, srcvar);
}
zend_call_known_fcc(&fcc, retval, pdp->cArgs, params, NULL);
ret = S_OK;
trace("function called ok\n");

/* Copy any modified values to callers copy of variant*/
for (i = 0; i < pdp->cArgs; i++) {
php_com_dotnet_object *obj = CDNO_FETCH(&params[i]);
VARIANT *srcvar = &obj->v;
VARIANT *dstvar = &pdp->rgvarg[ pdp->cArgs - 1 - i];
if ((V_VT(dstvar) & VT_BYREF) && obj->modified ) {
trace("percolate modified value for arg %u VT=%08x\n", i, V_VT(dstvar));
php_com_copy_variant(dstvar, srcvar);
}
} else {
trace("failed to call func\n");
ret = DISP_E_EXCEPTION;
}
} zend_catch {
trace("something blew up\n");
ret = DISP_E_EXCEPTION;
} zend_end_try();
} else if (wFlags & DISPATCH_PROPERTYGET) {
retval = zend_read_property(Z_OBJCE(disp->object), Z_OBJ(disp->object), Z_STRVAL_P(name), Z_STRLEN_P(name), 1, &rv);
ret = S_OK;
} else {
trace("Don't know how to handle this invocation %08x\n", wFlags);
}
Expand All @@ -307,7 +302,9 @@ static HRESULT STDMETHODCALLTYPE disp_invokeex(
VariantInit(pvarRes);
php_com_variant_from_zval(pvarRes, retval, COMG(code_page));
}
// zval_ptr_dtor(retval); // TODO needed for function calls?
if (retval == &rv) {
zval_ptr_dtor(retval);
}
} else if (pvarRes) {
VariantInit(pvarRes);
}
Expand Down
41 changes: 41 additions & 0 deletions ext/com_dotnet/tests/variant_variation3.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
--TEST--
Testing reading properties and calling functions
--EXTENSIONS--
com_dotnet
--FILE--
<?php
class MyClass {
public $foo = "property";
public $bar = "bar";
public function foo() {
return "method";
}
public function stdClass() {
return new stdclass();
}
}

$o = new MyClass();
$v = new variant($o);
var_dump($v->foo);
var_dump($v->foo());
var_dump($v->bar);
var_dump($v->bar());
var_dump($v->stdclass);
var_dump($v->stdclass());
try {
var_dump($v->qux);
} catch (com_exception $ex) {
echo $ex->getMessage(), "\n";
}
?>
--EXPECTF--
string(6) "method"
string(6) "method"
string(3) "bar"
string(3) "bar"
object(variant)#%d (0) {
}
object(variant)#%d (0) {
}
Unable to lookup `qux': %s
Loading