Commit graph

387 commits

Author SHA1 Message Date
SakiTakamachi
e0aadc1c0d
Fix GH-11587 PDO::ATTR_STRINGIFY_FETCHES should return strings even in if PDO::ATTR_EMULATE_PREPARES is enabled
This also includes a fix for the MySQL ND driver to actually respect the user decided behaviour.

Closes GH-11622

Signed-off-by: George Peter Banyard <girgias@php.net>
2023-07-17 07:08:45 +01:00
Stanislav Malyshev
a6a80eefe0 Improve fix for bug #81740 2022-12-18 23:20:29 -07:00
Nikita Popov
c02aa46126 Fix leak when persistent PDO connection fails
As we don't register the resource, the resource dtor is not called
and will not decrement the refcount.
2021-11-16 16:14:29 +01:00
Joe Watkins
570d9b63e9
Not serializable flag permeation 2021-07-20 12:28:35 +02:00
Nikita Popov
9d2a466c4b Remove explicit assignments of zend_objects_destroy_object
This is the default handler, no need to set it explicitly. This
makes it easier to see which objects really have a custom dtor_obj.
2021-06-09 11:29:50 +02:00
KsaR
01b3fc03c3
Update http->https in license (#6945)
1. Update: http://www.php.net/license/3_01.txt to https, as there is anyway server header "Location:" to https.
2. Update few license 3.0 to 3.01 as 3.0 states "php 5.1.1, 4.1.1, and earlier".
3. In some license comments is "at through the world-wide-web" while most is without "at", so deleted.
4. fixed indentation in some files before |
2021-05-06 12:16:35 +02:00
Máté Kocsis
e2ad44357e
Merge branch 'PHP-8.0'
* Fix the default value of $mode in PDOStatement::fetch*()
2021-05-03 13:08:36 +02:00
Máté Kocsis
30d3062c9b
Fix the default value of $mode in PDOStatement::fetch*()
Closes GH-6933
2021-05-03 13:06:38 +02:00
George Peter Banyard
e3403d80af Use ZEND_FALLTHROUGH instead of a comment in PDO 2021-04-19 13:59:18 +01:00
Nikita Popov
19775afab3 Merge branch 'PHP-8.0'
* PHP-8.0:
  PDO: Respect connection transaction state for dtor rollback
2021-04-12 12:39:50 +02:00
Nikita Popov
8effbd1cb0 PDO: Respect connection transaction state for dtor rollback
As mentioned in bug #80949, if a transaction is implicitly
committed, then PDO may still issue a ROLLBACK when the PDO
object is destroyed, as the transaction is still marked as active
in PDO's (inaccurate) transaction emulation.

Make sure we use the connection transaction state also for that
final ROLLBACK. A caveat here is that the connection might have
been dropped already, which may be the case for some drivers if
construction fails. Make sure we don't crash in that case.
2021-04-12 12:39:44 +02:00
George Peter Banyard
ebaeb93c3f Add API to fetch bool value for PDO attribute values
Closes GH-6766
2021-03-17 00:58:01 +00:00
George Peter Banyard
32fb9b6fd1 Validate string is numeric for integer PDO attribute value 2021-03-17 00:58:00 +00:00
George Peter Banyard
f89f600d4f Add comment explaining empty default case 2021-03-15 16:39:40 +00:00
George Peter Banyard
6cc0d7c0ec Boolify pdo_dbh_attribute_set() 2021-03-15 14:48:33 +00:00
George Peter Banyard
3e6940fe29 Boolify pdo_hash_methods() 2021-03-15 14:48:33 +00:00
George Peter Banyard
262744ff0d Boolify pdo_stmt_describe_columns() 2021-03-15 14:48:33 +00:00
Nikita Popov
f7751f2d8b Use zend_objects_not_comparable in PDO 2021-03-15 13:01:42 +01:00
Máté Kocsis
af56982a5e
Generate class entries from stubs for oci8, odbc, openssl, pcntl, pdo, pgsql
Closes GH-6691
2021-02-14 23:19:21 +01:00
George Peter Banyard
a78aea8948 Refactor PDO's last inserted ID handler to use and return zend_string
Closes GH-6617
2021-01-19 11:54:25 +00:00
George Peter Banyard
94ea8e247b Refactor PDO doer handler to use zend_string 2021-01-19 11:42:39 +00:00
Nikita Popov
3e01f5afb1 Replace zend_bool uses with bool
We're starting to see a mix between uses of zend_bool and bool.
Replace all usages with the standard bool type everywhere.

Of course, zend_bool is retained as an alias.
2021-01-15 12:33:06 +01:00
George Peter Banyard
63cda0fea8 Refactor PDO's quoter handler to return a zend_string
Closes GH-6547
2021-01-07 15:53:48 +00:00
George Peter Banyard
1a58611ae5 Voidify PDO's fetch_error handler 2021-01-06 10:20:57 +00:00
George Peter Banyard
d04adf60be Boolify PDO's transaction handlers
This includes begin(), commit(), rollBack(), and inTransaction()
2021-01-06 10:20:57 +00:00
George Peter Banyard
ca5fcb83bf Add/expand comments for PDO handlers 2021-01-06 10:20:57 +00:00
Nikita Popov
2d51c203f0 PDO: Store/pass query_string as zend_string
Rather than storing char* + size_t, use a zend_string*. Also
avoid various copies of the query string.
2020-12-14 10:43:28 +01:00
Nikita Popov
d6c3b8baab Merge branch 'PHP-8.0'
* PHP-8.0:
  Allow drivers to omit error code
2020-12-10 16:04:48 +01:00
Nikita Popov
a5527577e7 Allow drivers to omit error code
And thus generate error messages that match what PDO emulation
would generate.

This fixes the error message regression from the previous commit.
2020-12-10 16:04:33 +01:00
Nikita Popov
bd555b6cca Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #66528
2020-10-28 12:18:26 +01:00
Nikita Popov
39be0df2ed Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #66528
2020-10-28 12:18:17 +01:00
Nikita Popov
68dcaa29d8 Fixed bug #66528
Report errors in commit, rollback and autocommit handlers.
2020-10-28 12:18:02 +01:00
Nikita Popov
ab0ec3f24a Check for null dbh methods in get_gc
Methods may not be set at the point where get_gc is called. Fixes
a segfault in Laravel.
2020-10-28 10:44:13 +01:00
Nikita Popov
18d373e8c3 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix inconsistency in PDO transaction state
2020-10-26 17:01:25 +01:00
Nikita Popov
7b9519a792 Fix inconsistency in PDO transaction state
This addresses an issue introduced by #4996 and reported in
https://bugs.php.net/bug.php?id=80260.

Now that PDO::inTransaction() reports the real transaction state
of the connection, there may be a mismatch with PDOs internal
transaction state (in_tcx). This is compounded by the fact that
MySQL performs implicit commits for DDL queries.

This patch fixes the issue by making beginTransaction/commit/rollBack
work on the real transaction state provided by the driver as well
(or falling back to in_tcx if the driver does not support it).

This does mean that writing something like

    $pdo->beginTransaction();
    $pdo->exec('CREATE DATABASE ...');
    $pdo->rollBack(); // <- illegal

will now result in an error, because the CREATE DATABASE already
committed the transaction. I believe this behavior is both correct
and desired -- otherwise, there is no indication that the code did
not behave correctly and the rollBack() was effectively ignored.
However, this is also a BC break.

Closes GH-6355.
2020-10-26 17:01:18 +01:00
Nikita Popov
d7a16bf2da Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix default value handling of mysqli_fetch_object()
2020-10-20 16:48:28 +02:00
Máté Kocsis
d5f92baad0 Fix default value handling of mysqli_fetch_object()
Make [] acceptable both for classes without constructors and
classes with a constructor that takes no arguments.

Closes GH-6336.
2020-10-20 16:48:12 +02:00
Nikita Popov
e735de6eae Add GC support for PDO driver data
Add a get_gc method that can be implemented by drivers, which can
be used to add additional zvals to the GC buffer.

Implement GC support for PDO SQLite callbacks in particular.

Closes GH-6262.
2020-10-12 13:00:41 +02:00
George Peter Banyard
7553c696c3 Another pass making some failure states unconditional erros in PDO
Also make internal function return type more accurate to inform usage
2020-09-28 19:35:31 +01:00
George Peter Banyard
a5cf82802d Make various failure conditions in PDO unconditional errors
This includes TypeErrors, ValueErrors, Error for uninitialized objects
and invalid user classes/callable instanciation

Closes GH-6212
2020-09-28 18:51:36 +01:00
George Peter Banyard
1b2ec73c1d Drop various unused macros/APIs
Also convert_libmagic_pattern() to return a zend_string*

Closes GH-6029
2020-08-26 12:59:43 +02:00
Nikita Popov
898bb97706 Drop php_pdo_get_exception_base() function
This API is more confusing than helpful.
2020-08-11 17:40:39 +02:00
Nikita Popov
33028bf014 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix #64705 errorInfo property of PDOException is null when PDO::__construct() fails
2020-08-11 17:16:38 +02:00
Nikita Popov
981af26d7b Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #64705 errorInfo property of PDOException is null when PDO::__construct() fails
2020-08-11 17:13:28 +02:00
Ahmed Abdou
2fe2e5b48f Fix #64705 errorInfo property of PDOException is null when PDO::__construct() fails
PDO driver constructors are throwing PdoException without setting
errorInfo, so create a new reusable function that throws exceptions
for PDO and will also set the errorInfo. Use this function in
pdo_mysql, pdo_sqlite, and pdo_pgsql.
2020-08-11 17:12:48 +02:00
Nikita Popov
8b77c58130 Accept zend_object* in zend_update_property 2020-08-07 16:40:27 +02:00
Nikita Popov
d92229d8c7 Implement named parameters
From an engine perspective, named parameters mainly add three
concepts:

 * The SEND_* opcodes now accept a CONST op2, which is the
   argument name. For now, it is looked up by linear scan and
   runtime cached.
 * This may leave UNDEF arguments on the stack. To avoid having
   to deal with them in other places, a CHECK_UNDEF_ARGS opcode
   is used to either replace them with defaults, or error.
 * For variadic functions, EX(extra_named_params) are collected
   and need to be freed based on ZEND_CALL_HAS_EXTRA_NAMED_PARAMS.

RFC: https://wiki.php.net/rfc/named_params

Closes GH-5357.
2020-07-31 15:53:36 +02:00
Nikita Popov
7eec281b5e Avoid UNKNOWN default in PDO::query() 2020-07-24 11:44:47 +02:00
Nikita Popov
7d3e530f4e Use zpp for PDO fetch mode
Also changing the function signatures to accept variadic args
for the fetch params. If we're already breaking Doctrine anyway,
we may as well do it properly.
2020-07-20 16:05:33 +02:00
Nikita Popov
302933daea Remove no_separation flag 2020-07-07 09:30:24 +02:00