Commit graph

1236 commits

Author SHA1 Message Date
Nikita Popov
8957260094 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix bug #72413: Segfault with get_result and PS cursors
2020-10-29 16:41:09 +01:00
Dharman
b5481defe6 Fix bug #72413: Segfault with get_result and PS cursors
We cannot simply switch to use_result here, because the fetch_row
methods in get_result mode and in use_result/store_result mode
are different: In one case it accepts a statement, in the other
a return value zval. Thus, doing a switch to use_result results
in a segfault when trying to fetch a row.

Actually supporting get_result with cursors would require adding
cursor support in mysqlnd_result, not just mysqlnd_ps. That would
be a significant amount of effort and, given the age of the issue,
does not appear to be particularly likely to happen soon.

As such, we simply generate an error when using get_result()
with cursors, which is much better than causing a segfault.
Instead, parameter binding needs to be used.
2020-10-29 16:34:08 +01:00
Nikita Popov
d928c58281 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Handle mysqli errors in more cases
  Sync test with master
2020-10-28 11:37:37 +01:00
Dharman
990bb34891 Handle mysqli errors in more cases
Report errors autocommit, commit, rollback and mysqli_stmt_attr_set.

Additionally, copy the error from conn to stmt when preparing fails,
so these errors are also handled by mysqli_stmt_prepare.

Closes GH-6157.
2020-10-28 11:33:50 +01:00
Nikita Popov
fe55fe1f54 Sync test with master
Sync ext/mysqli/tests/mysqli_report.phpt with PHP-8.0/master, as
the current difference in indentation makes it hard to merge.
2020-10-28 11:30:22 +01:00
Nikita Popov
793bf12f8c Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix bug #79375
2020-10-28 11:04:32 +01:00
Dharman
b03776adb5 Fix bug #79375
Make sure deadlock errors are properly propagated and reports in
a number of places in mysqli and PDO MySQL.

This also fixes a memory and a segfault that can occur under these
conditions.
2020-10-28 11:01:47 +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
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
Máté Kocsis
d6264b0966
Verify parameter names of function aliases
Closes GH-6335
2020-10-16 10:56:33 +02:00
Matteo Beccati
d411ea26f1 Fixed test for MySQL < 5.6
Refs GH-6172.
2020-09-28 08:52:21 +02:00
Nikita Popov
8138ed73d7 Make mysqli_warning constructor private
The constructor was already effectively inaccessible (protected
on a final class). This just makes it more obvious and removes
the implementation in favor of directly throwing.

Per the removed test, this was an unfinished feature, and I don't
think it makes a lot of sense to finish it -- the
mysqli_stmt::get_warnings() interface makes more sense than
direct construction.

Closes GH-6208.
2020-09-27 22:08:24 +02:00
Larry Garfield
02dc9ce6e5 Rename mysqli parameters to be more logical
Closes GH-6172.
2020-09-27 21:28:29 +02:00
Máté Kocsis
41b096b392
Promote a few forgotten warnings to exceptions
Closes GH-6211
2020-09-25 12:08:15 +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
19314ff887 Fix some tests for libmysql 2020-09-18 18:01:04 +02:00
Nikita Popov
2d002258b8 Drop skipifemb.inc
And drop the last remaining uses of it.
2020-09-18 15:49:35 +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
2abea9c3bb Merge branch 'PHP-7.4'
* PHP-7.4:
  Use MyISAM engine for new test
2020-09-18 14:50:11 +02:00
Nikita Popov
d87c393a18 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Use MyISAM engine for new test
2020-09-18 14:50:02 +02:00
Nikita Popov
77f43e48ff Use MyISAM engine for new test
Travis on 7.3 is showing this error:

> The size of BLOB/TEXT data inserted in one transaction is greater
> than 10% of redo log size. Increase the redo log size using
> innodb_log_file_size.

Force MyISAM engine to avoid this.
2020-09-18 14:49:43 +02:00
Nikita Popov
c5401854fc Run tidy
This should fix most of the remaining issues with tabs and spaces
being mixed in tests.
2020-09-18 14:28:32 +02:00
Nikita Popov
0582c40907 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix bug #80107: Handling of large compressed packets
  Bug #80107 Add test for mysqli_query() fails for ~16 MB long query when compression is enabled
2020-09-18 12:59:10 +02:00
Nikita Popov
5e7c5a82a5 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix bug #80107: Handling of large compressed packets
  Bug #80107 Add test for mysqli_query() fails for ~16 MB long query when compression is enabled
2020-09-18 12:57:50 +02:00
Nikita Popov
ecd9c42f9e Fix bug #80107: Handling of large compressed packets
There's two layers of packet splitting going on. First, packets
need to be split into having a payload of exactly 2^24-1 bytes or
being the last packet. If the split packet has size between 2^24-5
and 2^24-1 bytes, the compressed packets also needs to be split,
though the choice of split doesn't matter here. I'm splitting off
the first 8192 bytes, as that's what I observe libmysqlclient to be
doing.
2020-09-18 12:55:44 +02:00
Máté Kocsis
c7ceebc42c Bug #80107 Add test for mysqli_query() fails for ~16 MB long query when compression is enabled 2020-09-18 12:42:08 +02:00
Nikita Popov
a03c1ed7aa Remove vestiges of embedded mysql from tests 2020-09-17 19:02:20 +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
86e002729f Fix some tests for libmysql 2020-09-17 15:27:02 +02:00
Nikita Popov
e2b3c0e291 Remove checks for old libmysqlclient versions in tests 2020-09-17 15:02:35 +02:00
Dharman
8f56b7a755 mysqli: Promote warning in field_seek
Aligning the behaviour of fetch_field and field_seek.
2020-09-17 09:42:42 +02:00
Dharman
0d99a5618f Changed the wording of the error message
"cannot be used in MYSQLI_USE_RESULT mode" sounds more correct than "cannot be used with MYSQLI_USE_RESULT"

Closes GH-6137.
2020-09-16 11:10:11 +02:00
Matteo Beccati
3b2410ebf6 Fix test
follow-up to 7a95e94 for MySQL < 5.6
2020-09-16 10:06:19 +02:00
George Peter Banyard
7a95e943d6 Promote warnings to Error in MySQLi extension
Closes GH-5803
2020-09-15 19:12:02 +02:00
Máté Kocsis
2408991fc5
Remove unintendedly committed test 2020-09-15 14:49:30 +02:00
Máté Kocsis
c37a1cd650
Promote a few remaining errors in ext/standard
Closes GH-6110
2020-09-15 14:26:16 +02:00
Máté Kocsis
9975986b7e
Improve error messages mentioning parameters instead of arguments
Closes GH-5999
2020-09-09 10:47:43 +02:00
Christoph M. Becker
5072321c55 Improve test portability
We have to ensure that the attempted connection to the MySQL server
fails, and do that by passing an unknown host instead of falling back
to localhost.
2020-08-14 15:33:02 +02:00
Christoph M. Becker
64368f4786 Fix newly introduced test for Windows
The warning message is rather different there, but since that is
irrelevant for this test case, we just suppress the warning.
2020-08-14 14:36:32 +02:00
Nikita Popov
ce38d3a919 Don't assert mysql->mysql is non-null
There is an edge case in constructor behavior where we can end up
with mysql->mysql being NULL (rather than mysql itself already being
NULL). I think that ultimately that's a bug in the constructor code,
and we should probably be destroying the outer structure on
construction failure as well. However it's pretty hard to unravel
with when considering all the construction permutations.
2020-08-14 12:44:13 +02:00
Nikita Popov
f5e6f9bd27 Avoid fatal error on not found class in mysqli_fetch_object()
Instead use C zpp modifier and throw TypeError.
2020-08-13 16:13:02 +02:00
Máté Kocsis
7aacc705d0
Add many missing closing PHP tags to tests
Closes GH-5958
2020-08-09 22:03:36 +02:00
George Peter Banyard
c74001997f Drop '#if 0' in mysqlnd_debug() from the MySQLnd extension
Closes GH-5587
2020-08-07 18:17:33 +02:00
Máté Kocsis
d30cd7d7e7
Review the usage of apostrophes in error messages
Closes GH-5590
2020-07-10 21:05:28 +02:00
Tiffany
48eb635a0f [skip-ci] Add README for ext/mysqli tests
Closes GH-5804
2020-07-06 14:35:53 +02:00
Fabien Villepinte
0c6d06ecfa Replace EXPECTF when possible
Closes GH-5779
2020-06-29 21:31:44 +02:00
Ayesh Karunaratne
d114812faf [ci skip] Various typo fixes in stub comments and CHANGES file 2020-06-25 23:32:40 +02:00
Nikita Popov
ff19ec2df3 Introduce InternalIterator
Userland classes that implement Traversable must do so either
through Iterator or IteratorAggregate. The same requirement does
not exist for internal classes: They can implement the internal
get_iterator mechanism, without exposing either the Iterator or
IteratorAggregate APIs. This makes them usable in get_iterator(),
but incompatible with any Iterator based APIs.

A lot of internal classes do this, because exposing the userland
APIs is simply a lot of work. This patch alleviates this issue by
providing a generic InternalIterator class, which acts as an
adapater between get_iterator and Iterator, and can be easily
used by many internal classes. At the same time, we extend the
requirement that Traversable implies Iterator or IteratorAggregate
to internal classes as well.

Closes GH-5216.
2020-06-24 15:31:41 +02:00