Fix #71592: External entity processing never fails
If the callback set via `xml_set_external_entity_ref_handler()` returns
a falsy value, parsing is supposed to stop and the error number set to
`XML_ERROR_EXTERNAL_ENTITY_HANDLING`. This is already correctly done
by the libexpat binding, but the libxml2 binding ignores the return
value. We fix this by calling `xmlStopParser()` which is available as
of libxml 2.1.0[1] (PHP-7.1 requires at least libxml 2.6.11 anyway),
and setting the desired `errNo` ourselves.
Dmitry Stogov [Thu, 25 Oct 2018 17:30:51 +0000 (20:30 +0300)]
Improved shared interned strings handling. The previous implementation worked incorrectly in ZTS build. It changed strings only in function/class tables of one thread. Now all threads gets the same shared interned strings. Also, on shutdown, we don't try to replace SHM interned strings back to process strings, but delay dettachment of SHM instead.
Peter Kokot [Wed, 24 Oct 2018 15:06:21 +0000 (17:06 +0200)]
Remove ext/json parser files generated by bison
The parser files for ext/json are generated by bison from the *.y file.
Parser files in Zend and sapi/phpdbg already follow such approach of
these files being ignored from tracking in the Git repository and they
are shipped via the release packages later on. This way the end users
still don't need to have bison dependency installed to install PHP.
The genfiles script was refactored to generate the ext/json parser and
lexer files.
Peter Kokot [Fri, 19 Oct 2018 23:05:00 +0000 (01:05 +0200)]
Fix run-tests.php for running phpdbg and certain test sections
Certain sections, such as --EXTENSIONS--, --SKIPIF--, and --CLEAN--
require to be executed using only PHP CLI or PHP CGI SAPIs and cannot be
processed with the phpdbg.
Peter Kokot [Thu, 18 Oct 2018 06:56:38 +0000 (08:56 +0200)]
Normalize .gitignore
Changes:
- Added introductory paragraph to explain the file for newcomers and
where to ignore local editor configurations as a common practice
when using Git.
- Patterns organized into several main context sections for a better
overview of the php-src directory structure and which files get
generated where.
- Added comments describing reasons for ignoring particular file(s).
- Patterns normalized according to Git ignore blob patterns. Absolute
paths are different than relative paths and similar fixes.
- Folders patterns have appended ending slash for readability to
distinguish them from files.
Removed ignore patterns:
- Removed `sapi/phpdbg/build` pattern since it doesn't seem to be
relevant anymore in the php-src repository.
- The `acconfig.h` pattern removed in favor of the more recent Autoconf
versions.
- Removed patterns for `.FBCIndex` `.FBCLockFolder` folders. These were
generated on old Mac OS systems [1] using the Sherlock [2] software
and can be today ignored using a global gitignore file if needed.
Newer macOS systems don't generate these anymore.
- Removed `php_version.h` pattern since the `main/php_version.h` file is
tracked by Git.
- Removed `*.mk` pattern since few *.mk files are tracked by Git and new
ones aren't generated during build process.
- Removed `**/tests/**/*.txt` pattern. This has been refactored via 595a395cb911a4ef54cbaf11cd0056d38316c87c and current tests also clean
the generated `*.txt` files as soon as they are executed. Since there
are several `*.txt` files in the repository tracked by Git already and
renaming them would be counter productive so the pattern is now removed.
In case there will be a need to adjust it, we can rename the generated
`*.txt` into something else instead (ideally into `*.tmp`) to not
conflict with already tracked `*.txt` files in tests.
- Removed `ext/*/scan_makefile_in.awk` and `scan_makefile_in.awk` patterns
since these are already included in the `/ext/*/build/` pattern.
- Removed the `/ext/*/libs.mk` pattern since these auxilary Makefiles
have been used in previous build system and made obsolete via the commit 9d9d39a0de3bec962c343051011f5a2ed7d7b242.
- Removed pattern for configuration header `ext/pdo_sqlite/sqlite3.h` since
it is not generated anymore in the current code.
- Removed `main/streams/build-defs.h` pattern since this file is not
generated.
- Removed `test.php3` pattern. These don't seem to be present in the current
PHP source code nor used since PHP 3.
- Removed `/ext/oci8/tests/*.vglog` pattern since the tests don't seem to
produce these files.
- Removed pattern for Visual Studio's `*.ncb` files. Since the Visual
Studio 2010 they are no longer used.
- Removed `ext/sqlite3/tests/phpsql*` pattern. It was part of the `ext/sqlite/tests`.
- Removed `shlibtool` pattern since the shlibtool file is not generated
anymore. It was once part of the libtool usage and customized naming
used in the previous build system in Makefiles. Such naming was later
removed and only libtool was used.
- Removed `meta_ccld` pattern since it is no longer relevant via a5b55416f4bf48e475b30bb86b120c83efccca53
- Pattern `meta_cc` has been removed via e5176fe60a9ffbe211ee016acdcddb18118e4487.
- Pattern `dynlib.m4` removed since the file is no longer generated via 9d9d39a0de3bec962c343051011f5a2ed7d7b242
- Pattern `debug.log` removed since the Autoconf Macro PHP_DEBUG_MACRO
is not called anymore and this file not generated anymore.
- Pattern `results.txt` removed. It was once part of the logging results
of test files by Netware and previous Windows builds.
- Removed `_libs` pattern in favor of only `.libs`. These directories
were once generated by Automake and Libtool on systems that didn't
support the dot folder `.libs` (MS-DOS).
- Removed `*.opt` pattern since it was used by Visual Studio 6. Later
versions of Visual Studio don't use these anymore.
- Removed `*.plg` pattern. It was build log generated by Visual Studio 6.
- Removed `core` pattern since it was probably related to commit fd7153b0f3047e6a96344dc3b4ca2632d5acc898 and is today not used.
- Removed ˙*.˙, ˙diff`, and ˙*.tgz` patterns since they don't seem to be
generated in the current code on the first glance. In case these will be
one day required to ignore again, they can be simply added back again.
- Removed Emacs specific interlock files pattern `.#*`. The number of
editors and IDEs specific files is very big. Emacs editors also produce
some other files such as `#*#` for autosave feature, which were previously
not ignored. To fully and properly support all additional patterns these
could be added to .gitignore files. A much more sustainable and better
practice is to use a global gitignore file on the local system or the
`.git/info/exclude` per repository basis for these in particular.
Added patterns:
- Added new pattern for `*.obj` standard object files in the Windows
section. These are generated by Visual Studio.
- Added `/ext/*/run-tests.php` patterns for extensions.
- Reversed patterns for particular tracked `/win32/build/Makefile`, `config.h`
files and `.patch` files.
- Added patterns for generated dtrace files `/ext/oci8/oci8_dtrace_gen.h`
Other changes:
- All `conftest*` patterns merged into a single one.
- Pattern `*.mem` made more specific where the memory check files get
generated by `run-tests.php -m`, i.e. `**/tests/**/*.mem`.
- Fixed `/Zend/zend_dtrace_gen.h.bak` `hbak` typo.
Peter Kokot [Sat, 20 Oct 2018 20:06:04 +0000 (22:06 +0200)]
Remove phpdbg parser files generated by bison
The parser files for phpdbg are generated by bison from the *.y file.
Parser files in Zend already follows such approach of these files being
ignored from tracking in the Git repository and they are shipped via
the release packages. This way the end user still don't need to have
bison dependency installed to install PHP.
The genfiles script was refactored to generate the phpdbg parser and lexer
files.
Empty comment in phpdbg parser y template file has been changed to the
YACC compliant /* empty */ instead of custom one.
Since we allow ext/xmlrpc to be built against a system libxmlrpc(-epi),
we must not `efree` memory which has been allocated via `malloc`. To
distinguish bundled and system libxmlrpc(-epi) we introduce the macro
`HAVE_XMLRPC_BUNDLED` (analogous to how it is done by ext/gd). We
deliberately keep the ugly `#ifdef`s, instead of tucking them away in
an `XMLRPC_FREE()` macro, to not forget that it is a bad idea to fork
and bundle a library, but to also allow building against an unpatched
system lib.
Peter Kokot [Sat, 6 Oct 2018 06:43:50 +0000 (08:43 +0200)]
Fix .gitattributes
The `crlf` Git attribute has been long deprecated and made obsolete. A
replacement for using `-crlf` is `-text`. That way Git doesn't do
newlines normalization on any system.
Since the phpt files don't need specific line endings in any files
except for some special CR characters in some, this can be also removed
and line normalization can happen on all phpt files. The run-tests.php
file converts the CRLF to LF before running the test.
This patch also sets a `diff` attributes for all *.phpt files. It
helps showing diffs for some phpt files with special characters such
as ASCII control characters which makes Git recognize them as binary and
stops showing commit diffs otherwise
Some additional short info about used Git attributes has been also added
as comments for easier understanding.