Commit Graph

515 Commits

Author SHA1 Message Date
Fabien Villepinte
bbf7b8dd69 Add missing SKIPIF (sqlite) 2019-09-04 08:39:15 +02:00
Nikita Popov
d59aac58b3 Report errors from stream read and write operations
The php_stream_read() and php_stream_write() functions now return
an ssize_t value, with negative results indicating failure. Functions
like fread() and fwrite() will return false in that case.

As a special case, EWOULDBLOCK and EAGAIN on non-blocking streams
should not be regarded as error conditions, and be reported as
successful zero-length reads/writes instead. The handling of EINTR
remains unclear and is internally inconsistent (e.g. some code-paths
will automatically retry on EINTR, while some won't).

I'm landing this now to make sure the stream wrapper ops API changes
make it into 7.4 -- however, if the user-facing changes turn out to
be problematic we have the option of clamping negative returns to
zero in php_stream_read() and php_stream_write() to restore the
old behavior in a relatively non-intrusive manner.
2019-07-22 17:17:28 +02:00
Peter Kokot
f5227c5863 Move HAVE_SQLITE3_CLOSE_V2 to pdo_sqlite
Closes GH-4444
2019-07-21 00:40:59 +02:00
Peter Kokot
6de97402b5 Remove unused sqlite symbols
- HAVE_SQLITE3_KEY is no longer used in php-src
- SQLITE_ENABLE_COLUMN_METADATA is no longer used in php-src

Closes GH-4443
2019-07-20 00:27:10 +02:00
Peter Kokot
e39296d10b Remove unsed zts check for sqlite3
This check was relevant with bundled sqlite library. Removed via
6083a387a8

Closes GH-4403
2019-07-14 21:06:15 +02:00
Robert Kopack
b546ae986a Implement SQLite extended result code functionality 2019-07-02 13:03:35 +02:00
Nikita Popov
8277acefbd Fix leak on sqlite3 open error
sqlite3_open creates the database object even if the operation
fails.
2019-06-25 14:28:58 +02:00
BohwaZ
ce22ccc77b Implement SQLite3 backup API 2019-06-17 23:34:51 +02:00
Dmitry Stogov
457392fa64 Cheaper checks for exceptions thrown from __toString() 2019-06-06 01:47:22 +03:00
Nikita Popov
a31f46421d Allow exceptions in __toString()
RFC: https://wiki.php.net/rfc/tostring_exceptions

And convert some object to string conversion related recoverable
fatal errors into Error exceptions.

Improve exception safety of internal code performing string
conversions.
2019-06-05 14:25:07 +02:00
Dmitry Stogov
83804519df Replace ZVAL_COPY() and ZVAL_COPY_VALUE() for IS_OBJECT by cheaper macros 2019-05-28 20:10:02 +03:00
Stanislav Malyshev
ffc15e913c Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix bug #77967 - Bypassing open_basedir restrictions via file uris
2019-05-27 21:36:10 -07:00
Stanislav Malyshev
9d473f1eac Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Fix bug #77967 - Bypassing open_basedir restrictions via file uris
2019-05-27 21:36:05 -07:00
Stanislav Malyshev
fbb6a27212 Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1:
  Fix bug #77967 - Bypassing open_basedir restrictions via file uris
2019-05-27 21:36:00 -07:00
Stanislav Malyshev
c34895e837 Fix bug #77967 - Bypassing open_basedir restrictions via file uris 2019-05-27 18:48:48 -07:00
Remi Collet
24206783c3 fix typo breaking shared build 2019-05-21 14:25:55 +02:00
Christoph M. Becker
c982a4c3f9 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  use {TMP} placeholder in phpt tests
2019-05-21 09:03:20 +02:00
Christoph M. Becker
11740abd6b Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  use {TMP} placeholder in phpt tests
2019-05-21 09:03:01 +02:00
Holly Li (WIPRO LIMITED)
202e6936d6 use {TMP} placeholder in phpt tests 2019-05-21 09:02:37 +02:00
Nikita Popov
3f19f5112a Add RETURN_EMPTY_ARRAY() / RETVAL_EMPTY_ARRAY()
The usual wrappers around ZVAL_EMPTY_ARRAY()...
2019-05-14 14:59:10 +02:00
Peter Kokot
47350ba6e7 Use pkg-config for sqlite3 and pdo_sqlite
Following other migrations to pkg-config usage for the *nix build system
this migrates also sqlite3 and pdo_sqlite extensions.
2019-05-14 03:14:33 +02:00
Peter Kokot
75fb74860d Normalize comments in *nix build system m4 files
Normalization include:
- Use dnl for everything that can be ommitted when configure is built in
  favor of the shell comment character # which is visible in the output.
- Line length normalized to 80 columns
- Dots for most of the one line sentences
- Macro definitions include similar pattern header comments now
2019-05-12 18:43:03 +02:00
Nikita Popov
339b0af429 Avoid misc uninitialized variable warnings 2019-04-12 15:12:39 +02:00
Fabien Villepinte
26dfce7f36 Replace dirname(__FILE__) by __DIR__ in tests 2019-03-15 22:55:30 +01:00
Dmitry Stogov
f1b306fe11 Switch to use ZTS cache 2019-03-12 14:15:47 +03:00
bohwaz
58c25bf679
SQLite3: add DEFENSIVE config for SQLite >= 3.26.0 as a mitigation strategy against potential security flaws 2019-03-11 18:02:03 +01:00
Christoph M. Becker
aefe0dfd61 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  SQLite3: add DEFENSIVE config for SQLite >= 3.26.0 as a mitigation strategy against potential security flaws
2019-03-11 16:31:26 +01:00
Christoph M. Becker
e7ce7c6bb2 Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  SQLite3: add DEFENSIVE config for SQLite >= 3.26.0 as a mitigation strategy against potential security flaws
2019-03-11 16:30:16 +01:00
bohwaz
e93259bb23 SQLite3: add DEFENSIVE config for SQLite >= 3.26.0 as a mitigation strategy against potential security flaws 2019-03-11 16:26:15 +01:00
Gabriel Caruso
6c4e2079c0 Use EXPECT when possible
EXPECTF logic in run-tests.php is considerable, so let's avoid it.
2019-03-11 00:05:44 -03:00
Nikita Popov
59dd1979ef More zpp error/variation test removals 2019-03-08 13:46:39 +01:00
Peter Kokot
9df6a1e4dd Add AS_HELP_STRING to *nix build configure options
The Autoconf's default AS_HELP_STRING macro can properly format help
strings [1] so watching out if columns are aligned manually is not
anymore.

[1] https://www.gnu.org/software/autoconf/manual/autoconf.html#Pretty-Help-Strings
2019-03-07 20:36:59 +01:00
Peter Kokot
92ac598aab Remove local variables
This patch removes the so called local variables defined per
file basis for certain editors to properly show tab width, and
similar settings. These are mainly used by Vim and Emacs editors
yet with recent changes the once working definitions don't work
anymore in Vim without custom plugins or additional configuration.
Neither are these settings synced across the PHP code base.

A simpler and better approach is EditorConfig and fixing code
using some code style fixing tools in the future instead.

This patch also removes the so called modelines for Vim. Modelines
allow Vim editor specifically to set some editor configuration such as
syntax highlighting, indentation style and tab width to be set in the
first line or the last 5 lines per file basis. Since the php test
files have syntax highlighting already set in most editors properly and
EditorConfig takes care of the indentation settings, this patch removes
these as well for the Vim 6.0 and newer versions.

With the removal of local variables for certain editors such as
Emacs and Vim, the footer is also probably not needed anymore when
creating extensions using ext_skel.php script.

Additionally, Vim modelines for setting php syntax and some editor
settings has been removed from some *.phpt files.  All these are
mostly not relevant for phpt files neither work properly in the
middle of the file.
2019-02-03 21:03:00 +01:00
Zeev Suraski
0cf7de1c70 Remove yearly range from copyright notice 2019-01-30 11:03:12 +02:00
Christoph M. Becker
3815a03117 Remove superfluous variable
This has been missed when libsqlite3 has been unbundled.
2019-01-21 15:32:34 +01:00
BohwaZ
82af24f2b2 Implement SQLite3Stmt::getSQL method, returning the original statement SQL, eventually expanded 2018-12-15 17:27:33 +01:00
BohwaZ
abd9f08752 SQLite3: Separating parameters binding in a function 2018-12-07 15:17:20 +01:00
Christoph M. Becker
a757ebb5b5 Require SQLite ≥ 3.7.4 for ext/sqlite3
`SQLite3::readOnly()` uses `sqlite3_stmt_readonly()` which is only
available as of libsqlite 3.7.4.  For older SQLite3 versions we return
always `false`, which can be confusing.  Instead of sticking with this
behavior, or even undefining the method for old SQLite3 versions, we
lift the requirements to SQLite 3.7.4 (released on 2010-12-08),
according to a respective discussion[1].

Since pdo_sqlite doesn't use `sqlite3_stmt_readonly()`, we stick with
the minimum requirement of SQLite 3.5.0.

[1] <https://github.com/php/php-src/pull/3614>
2018-11-29 15:10:39 +01:00
Christoph M. Becker
525d3ae858 Handle potential sqlite3_bind_*() call failures
Since bug 77051 has been fixed, it is unlikely that any of the
 `sqlite3_bind_*` calls will ever fail, but we add respective checks
nonetheless, and call `php_sqlite3_error()` in case of bind failures.
2018-11-29 13:19:26 +01:00
Christoph M. Becker
0d3799dedc Merge branch 'PHP-7.3'
* PHP-7.3:
  Fix #77051: Issue with re-binding on SQLite3
2018-11-29 02:20:20 +01:00
Christoph M. Becker
471eb0dd95 Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Fix #77051: Issue with re-binding on SQLite3
2018-11-29 02:18:56 +01:00
BohwaZ
94ec262fca Fix #77051: Issue with re-binding on SQLite3
We have to call `sqlite3_reset()` before re-binding the parameters.
2018-11-29 02:16:57 +01:00
Christoph M. Becker
035de21d77 Deny (un)serialization of SQLite3, SQLite3Stmt and SQLite3Result
Serializing `SQLite3`, `SQLite3Stmt` and `SQLite3Result` instances is
possible but pointless, since unserializing results in uninitialized
instances, which will bail out of any method call.  Therefore, we deny
serialization and unserialization in the first place.
2018-11-29 01:08:03 +01:00
Fabien Villepinte
2b9ceffb41 Fix typo in tests 2018-11-19 22:17:58 +01:00
Dmitry Stogov
0f7f1498be Use ZEND_THIS macro to hide implementation details in extensions code. 2018-11-15 19:54:19 +03:00
Dmitry Stogov
c6ad0b92b7 Replace getThis() by EX(This), when additional check is not necessary. 2018-11-14 02:44:25 +03:00
Christoph M. Becker
86c6b3bdcd Support SQLite3 @name notation
Besides the common `:param` notation to designate named parameters in
prepared statements, SQLite3 also supports `@param` and `$param`.
While the latter is mostly to support the Tcl programming language, and
would be confusing for PHP's sqlite3 binding due to the similarity with
string interpolation, the former is common under .NET and raises no
such issue.  Therefore we add support for it.

This patch has been developed in cooperation with @BohwaZ.
2018-11-11 14:55:34 +01:00
Mizunashi Mana
705a31b4e5 Skip SQLite3::loadExtension tests if SQLITE_OMIT_LOAD_EXTENSION defined 2018-11-08 14:27:12 +01:00
Christoph M. Becker
b7b3a65e1d Avoid needless string duplication
Cf. <https://github.com/php/php-src/pull/3636#issuecomment-436638833>.
2018-11-07 17:10:35 +01:00
Peter Kokot
d679f02295 Sync leading and final newlines in *.phpt sections
This patch adds missing newlines, trims multiple redundant final
newlines into a single one, and trims redundant leading newlines in all
*.phpt sections.

According to POSIX, a line is a sequence of zero or more non-' <newline>'
characters plus a terminating '<newline>' character. [1] Files should
normally have at least one final newline character.

C89 [2] and later standards [3] mention a final newline:
"A source file that is not empty shall end in a new-line character,
which shall not be immediately preceded by a backslash character."

Although it is not mandatory for all files to have a final newline
fixed, a more consistent and homogeneous approach brings less of commit
differences issues and a better development experience in certain text
editors and IDEs.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206
[2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2
[3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2
2018-10-15 04:33:09 +02:00