Commit graph

278 commits

Author SHA1 Message Date
Niels Dossche
2b6c9b68bb
Fix GH-17900 and GH-8084
Calling the constructor twice has no real world benefit.
Block it to fix these two issues.
We also clean up the constructor code a bit:
- `in_ctor` implies `object` exist.
- We surround the instance check with ZEND_DEBUG to avoid a runtime
  penalty.

Closes GH-17900.
Closes GH-8084.
Closes GH-17908.
2025-02-24 19:25:08 +01:00
Gina Peter Bnayard
5853cdb73d Use "must not" instead of "cannot" wording 2024-08-21 21:12:17 +01:00
Gina Peter Bnayard
e7c4d54d65 Use new helper function for "cannot be empty" ValueErrors 2024-08-21 21:12:17 +01:00
Gina Peter Banyard
857ce2c9e0
ext/mysqli: Mark return type as zend_return (#15345) 2024-08-11 19:24:53 +01:00
Gina Peter Bnayard
0c827f6b25 ext/mysqli: Use an assertion for condition that is checked by ZPP 2024-08-11 17:27:09 +02:00
Arnaud Le Blanc
11accb5cdf
Preferably include from build dir (#13516)
* Include from build dir first

This fixes out of tree builds by ensuring that configure artifacts are included
from the build dir.

Before, out of tree builds would preferably include files from the src dir, as
the include path was defined as follows (ignoring includes from ext/ and sapi/) :

    -I$(top_builddir)/main
    -I$(top_srcdir)
    -I$(top_builddir)/TSRM
    -I$(top_builddir)/Zend
    -I$(top_srcdir)/main
    -I$(top_srcdir)/Zend
    -I$(top_srcdir)/TSRM
    -I$(top_builddir)/

As a result, an out of tree build would include configure artifacts such as
`main/php_config.h` from the src dir.

After this change, the include path is defined as follows:

    -I$(top_builddir)/main
    -I$(top_builddir)
    -I$(top_srcdir)/main
    -I$(top_srcdir)
    -I$(top_builddir)/TSRM
    -I$(top_builddir)/Zend
    -I$(top_srcdir)/Zend
    -I$(top_srcdir)/TSRM

* Fix extension include path for out of tree builds

* Include config.h with the brackets form

`#include "config.h"` searches in the directory containing the including-file
before any other include path. This can include the wrong config.h when building
out of tree and a config.h exists in the source tree.

Using `#include <config.h>` uses exclusively the include path, and gives
priority to the build dir.
2024-06-26 00:26:43 +02:00
Gina Peter Banyard
fd2d869642
Clean-up some more headers (#14416)
Remove unused headers (such as php_ini.h for extensions that don't define INI settings)
Use more specific headers when possible
2024-06-08 17:15:36 +01:00
Arnaud Le Blanc
fd73681c86
Fix GCC warning when using getThis() in a conditional (#13923)
Since GCC 12.x, using getThis() in a conditional yields a warning:

    <source>:12:22: warning: the comparison will always evaluate as 'true' for
                    the address of 'This' will never be NULL [-Waddress]
       12 |     return getThis() ? 2 : 3;
          |                      ^
2024-04-09 19:09:07 +02:00
David Carlier
90a39fd52c ext/mysqi: mysqli_poll raises a ValueError on absent 1st and 2ng arguments. 2023-03-15 17:49:31 +00:00
George Peter Banyard
f13d541ca6
Fix GCC 12 compiler warnings (#10713)
* Fix -Wunused-but-set-variable compiler warning in ext/mysqli

* Fix -Wstrict-prototypes compiler warning in ext/mysqlnd

* Fix -Wstrict-prototypes compiler warning in ext/soap

* Fix -Wunused-but-set-variable compiler warning in ext/exif

However, this code looks really sketchy...

* Fix -Wstrict-prototypes compiler warning in ext/openssl

* Fix -Wstrict-prototypes compiler warning in ext/dba

Add void to our bundled libraries

* Refactor bundled BCMath library

Fix -Wdeprecated-non-prototype compiler warnings
Use bool instead of char/int
Cleanup some useless header includes
2023-02-28 14:21:01 +00:00
Máté Kocsis
7936c8085e
Fix GH-8329 Print true/false instead of bool in error and debug messages (#8385) 2023-01-23 10:52:14 +01:00
Kamil Tekiela
646b8f6b5c
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Add NEWS entry for #9841
  Add a temporary fix for insufficient buffer size in mysqlnd (#9835)
  mysqli_query throws warning despite using silenced error mode (#9842)
2022-10-27 18:34:14 +01:00
Kamil Tekiela
ec1f58c871
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Add NEWS entry for #9841
  Add a temporary fix for insufficient buffer size in mysqlnd (#9835)
  mysqli_query throws warning despite using silenced error mode (#9842)
2022-10-27 18:31:38 +01:00
Kamil Tekiela
5b60370906
mysqli_query throws warning despite using silenced error mode (#9842) 2022-10-27 18:24:28 +01:00
Kamil Tekiela
d84dfa3292 Remove MYSQLI_USE_MYSQLND constant and all the code with it 2022-05-30 15:28:08 +01:00
David Carlier
15e7e570a5
Fix #81658: MYSQL_OPT_LOAD_DATA_LOCAL_DIR not available in MariaDB
This also introduces the boolean userland constant `MYSQLI_IS_MARIADB`.
2021-12-05 19:11:04 +01:00
Kamil Tekiela
15a2c8660b
mysqli_reap_async_query error reporting (#7629) 2021-11-09 18:16:36 +00:00
Máté Kocsis
01775fa104
Declare tentative return types for ext/mysqli (#6998) 2021-05-26 17:29:58 +02:00
Nikita Popov
b0961f2d04 Remove uses of TRUE/FALSE in mysqli/pdo_mysql
Replace with standard uses of true/false.
2021-05-26 15:07:23 +02:00
Nikita Popov
312b72908d Convert some instanceof checks to assertions
Again, $this must be instanceof self.
2021-05-26 10:44:56 +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
Kamil Tekiela
54222a6fe4
Implement mysqli_fetch_column (#6798)
* Implement mysqli_fetch_column
2021-05-01 20:11:47 +01:00
Kamil Tekiela
830d385351
Fix typos in fetch_all error message 2021-03-28 20:36:17 +01:00
Darek Slusarczyk
da011a312a Fix #80329: Add option to specify LOAD DATA LOCAL white list folder
* allow the user to specify a folder where files that can be sent
   via LOAD DATA LOCAL can exist
 * add mysqli.local_infile_directory for mysqli
   (ignored if mysqli.allow_local_infile is enabled)
 * add PDO::MYSQL_ATTR_LOCAL_INFILE_DIRECTORY for pdo_mysql
   (ignored if PDO::MYSQL_ATTR_LOCAL_INFILE is enabled)
 * add related tests
 * fixes for building with libmysql 8.x
 * small improvement in existing tests
 * update php.ini-[development|production] files

Closes GH-6448.

Co-authored-by: Nikita Popov <nikic@php.net>
2021-02-23 09:30:46 +01: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
Nikita Popov
037512cfce Move fetch_all implementation out of mysqlnd
There doesn't seem to be any compelling reason to implement this
in mysqlnd rather than mysqli. It's just a loop over fetch_into.

This makes the function available under libmysqlclient as well,
and thus fixes bug #79372.
2020-12-18 12:27:30 +01:00
Nikita Popov
33e904915e MySQLnd: Clean up and optimize mysqlnd result set handling
This is a larger overhaul of the mysqlnd result set infrastructure:

 * Drop support for two different types of buffered results sets
   ("c" and "zval"). Possibly these made sense at some earlier
   time, but now (with minor adjustments) one option is strictly
   worse than the other. Buffered result sets already buffer the
   full row packets, from which zvals can be decoded. The "zval"
   style additionally also buffered the decoded zvals. As result
   sets, even buffered ones, are generally only traversed once,
   this just ends up wasting memory. Now, a potentially useful
   variation here would be to buffer the decoded zvals instead of
   the row packets, but that's not what the code was doing.
 * To make it really strictly better, pre-allocate the zval row
   buffer and reuse it for all rows. Previously the "c" style always
   allocated a new buffer for each row.
 * The fetch_row API now provides a populated zval[]. The task of
   populating an array is deferred to fetch_row_into, which also
   avoids duplicating this code in multiple places. The fetch_row_c
   API is also implemented on top of fetch_row now, rather than
   duplicating large parts of the code.
 * The row fetching code for prepared statements and normal result
   sets has been mostly merged. These already used the same
   infrastructure, but prepared statements used separate row
   fetching functions that were nearly the same as the normal ones.
   This requires passing the stmt into the result set, rather than
   just a flag. The only part that remains separate is reading of
   unbuffered results in the presence of PS cursors.
2020-12-17 10:15:02 +01:00
Dharman
7e6b840778 Consistent error handling in mysqli_poll
This error condition should not actually be reachable, but change
it to be consistent with the other ones.

Also fix a memory leak.

Closes GH-6340.
2020-10-26 16:25:25 +01:00
Máté Kocsis
d6264b0966
Verify parameter names of function aliases
Closes GH-6335
2020-10-16 10:56:33 +02:00
Nikita Popov
d66e929915 Fix null handling in mysqli_begin_transaction()
We don't want an explicit null name hit the !name_len check.
2020-10-13 17:12:50 +02:00
Máté Kocsis
e950ca13ea
Consolidate the usage of "either" and "one of" in error messages
Closes GH-6173
2020-09-20 19:41:47 +02:00
Nikita Popov
b40ffa9bfd Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix #78179: mysqli/mysqlnd transaction extensions
2020-09-18 15:30:13 +02:00
Nikita Popov
f23164584e Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #78179: mysqli/mysqlnd transaction extensions
2020-09-18 15:30:06 +02:00
Daniel Black
740f0f6165 Fix #78179: mysqli/mysqlnd transaction extensions
MariaDB versioning created a mess with regarding testing
features based on version. We sidestep the problem here
by assuming the extensions are present, and if a syntax
error occurs with a SQL mode TRANS_START_READ_WRITE |
TRANS_START_READ_ONLY enabled, then output the same
warning as before.
2020-09-18 15:29:44 +02:00
Dharman
74d16999fc mysqli_set_charset now throws an mysqli_sql_exception when incorrect charset is provided
Closes GH-6142.
2020-09-18 14:57:59 +02:00
Nikita Popov
e9ac7d27ba Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix mysqli_release_savepoint() on mysqlnd
2020-09-17 16:09:41 +02:00
Nikita Popov
33069575d5 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix mysqli_release_savepoint() on mysqlnd
2020-09-17 16:03:26 +02:00
Nikita Popov
c3944c4c4f Fix mysqli_release_savepoint() on mysqlnd
mysqli_release_savepoint() was not actually releasing a savepoint...
2020-09-17 15:59:09 +02:00
Nikita Popov
3ad57f9f31 Merge branch 'PHP-7.4'
* PHP-7.4:
  pdo_mysql/mysqli (native) libmysqlclient_r no-longer used
  mysql: native mysql-8.0 uses _Bool
  mysqli: use native api
2020-09-17 11:35:03 +02:00
Nikita Popov
d591e1c4f5 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  pdo_mysql/mysqli (native) libmysqlclient_r no-longer used
  mysql: native mysql-8.0 uses _Bool
  mysqli: use native api
2020-09-17 11:32:01 +02:00
Daniel Black
202a0697f3 mysqli: use native api
Tested with:
* mysql-5.6.49-linux-glibc2.12-x86_64
* mysql-5.7.31-linux-glibc2.12-x86_64
* mysql-8.0.21-linux-glibc2.17-x86_64
* mariadb-10.5.6

configure --with-mysqli=/usr/local/$version/bin/mysql_config   --with-pdo-mysql=/usr/local/$version

MySQL-8.0 removed my_bool
Some options where deprecated in mysql-8.0

MY_CHARSET_INFO used with exposed api mysql_get_character_set_info
rather than internal structures.
2020-09-17 11:27:31 +02:00
George Peter Banyard
7a95e943d6 Promote warnings to Error in MySQLi extension
Closes GH-5803
2020-09-15 19:12:02 +02:00
Nikita Popov
6570fc2cf8 Remove dummy aliases for mysqli constructors
These are only available as methods. Directly declare them as
such instead of aliasing to functions that don't actually exist.
2020-08-14 11:12:41 +02:00
Nikita Popov
545928e4b8 Fix some clang warnings 2020-07-23 10:35:40 +02:00
Max Semenik
2b5de6f839
Remove proto comments from C files
Closes GH-5758
2020-07-06 21:13:34 +02:00
George Peter Banyard
82afcf4401 Fix [-Wundef] warning in MySQLi extension 2020-05-18 00:37:19 +02:00
Máté Kocsis
3ebce8e9fc
Fix UNKNOWN default values in various extensions
Closes GH-5514
2020-05-05 19:08:20 +02:00
Nikita Popov
8597ec00d4 Remove support for libmysqlclient 5.0
Closes GH-5391.
2020-04-23 10:38:20 +02:00
Nikita Popov
a866ef88ed Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix MySQL local infile / attr handling on big endian systems
2020-04-16 11:23:11 +02:00
Nikita Popov
f684553c2c Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix MySQL local infile / attr handling on big endian systems
2020-04-16 11:22:43 +02:00