Skip to content

Fix PHP 8.1 deprecation on mysqli::real_connect() calls#5296

Merged
derrabus merged 1 commit intodoctrine:2.13.xfrom
iammati:2.13.x
Feb 25, 2022
Merged

Fix PHP 8.1 deprecation on mysqli::real_connect() calls#5296
derrabus merged 1 commit intodoctrine:2.13.xfrom
iammati:2.13.x

Conversation

@iammati
Copy link
Copy Markdown
Contributor

@iammati iammati commented Feb 24, 2022

Current issue with the 2.13.x branch is that, as soon as deprecation exceptions are enabled, the real_connect method inside the MysqliConnection driver is throwing an exception; mysqli::real_connect(): Passing null to parameter #7 ($flags) of type int is deprecated.

To resolve this, a 0 instead of null will be used.
I'm not really familiar with bits values at all, so if 0 is a bad default value feel free to adjust that - was only able to track it down at that part here. :)

Q A
Type bug
Fixed issues #4869

Summary

Replaced the ?? null with ?? 0 when trying to retrieve the flags' driver-options since PHP 8.1 does no longer accept null for the 7th parameter $flags of the real_connect method.

@sbuerk
Copy link
Copy Markdown
Contributor

sbuerk commented Feb 24, 2022

?? 0 should be the correct fallback. See php-src stub file for this method:

https://github.com/php/php-src/blob/266667c23425a139edb4f44d0f42a99186520e43/ext/mysqli/mysqli.stub.php#L251

    /**
     * @tentative-return-type
     * @alias mysqli_real_connect
     */
    public function real_connect(
        ?string $hostname = null,
        ?string $username = null,
        ?string $password = null,
        ?string $database = null,
        ?int $port = null,
        ?string $socket = null,
        int $flags = 0
    ): bool {}

@derrabus derrabus added this to the 2.13.8 milestone Feb 25, 2022
@derrabus derrabus merged commit a2212d1 into doctrine:2.13.x Feb 25, 2022
@derrabus
Copy link
Copy Markdown
Member

Thank you!

@derrabus derrabus changed the title Fix #4869: PHP 8.1 deprecated passing null to #7 flags parameter for … Fix PHP 8.1 deprecation on mysqli::real_connect() calls Feb 25, 2022
tzkoshi pushed a commit to tzkoshi/dbal that referenced this pull request Mar 16, 2022
Release [2.13.8](https://github.com/doctrine/dbal/milestone/104)

2.13.8
======

- Total issues resolved: **1**
- Total pull requests resolved: **9**
- Total contributors: **3**

CI,SQL Server
-------------

 - [5303: Run workflow on AppVeyor only if certain files changed](doctrine#5303) thanks to @morozov

Dependencies,Static Analysis
----------------------------

 - [5300: Psalm 4.22.0, PHPUnit 9.5.16](doctrine#5300) thanks to @derrabus

Bug,PHP,mysqli
--------------

 - [5296: Fix PHP 8.1 deprecation on `mysqli::real&doctrine#95;connect()` calls](doctrine#5296) thanks to @iammati

Error Handling,Static Analysis,mysqli
-------------------------------------

 - [5269: Run static analysis jobs on PHP 8.1](doctrine#5269) thanks to @morozov

Static Analysis
---------------

 - [5262: PHPStan 1.4.6, Psalm 4.20.0, PHPUnit 9.5.13](doctrine#5262) thanks to @derrabus
 - [5178: PHPStan 1.4.0](doctrine#5178) thanks to @derrabus

CI
--

 - [5238: Run PHP 7.4 on AppVeyor](doctrine#5238) thanks to @derrabus

Documentation
-------------

 - [5187: Update README for release 3.3](doctrine#5187) thanks to @derrabus

Connections,Reserved Keywords,Static Analysis
---------------------------------------------

 - [5166: Enforce consistent constructor in dynamically instantiated classes](doctrine#5166) thanks to @morozov
reviewtypo3org pushed a commit to TYPO3/typo3 that referenced this pull request Mar 22, 2022
This patch raises doctrine/dbal to 2.13.8 as minimum version,
which contains a bugfix to avoid a native php error is emitted,
stating "mysqli::real_connect(): Passing null to parameter #7".

See: doctrine/dbal#5296

One phpstan ignore pattern slightly changed because of a
changed return type declarion of doctrine/dbal. Tackling
the corresponding error should be done in a dedicated test
after proper investigation.

Used commands:

> composer req doctrine/dbal:^2.13.8
> composer req doctrine/dbal:^2.13.8 \
  -d typo3/sysext/core --no-update
> composer req doctrine/dbal:^2.13.8 \
  -d typo3/sysext/install --no-update
> composer req doctrine/dbal:^2.13.8 \
  -d typo3/sysext/redirects --no-update
> composer req doctrine/dbal:^2.13.8 \
  -d typo3/sysext/core --no-update
> Build/Scripts/runTests.sh -s phpstanGenerateBaseline

Resolves: #97222
Releases: 11.5
Change-Id: I6c1712a792780bd2966b3977d43f767e59304bd5
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/74013
Tested-by: core-ci <typo3@b13.com>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Benni Mack <benni@typo3.org>
TYPO3IncTeam pushed a commit to TYPO3-CMS/core that referenced this pull request Mar 22, 2022
This patch raises doctrine/dbal to 2.13.8 as minimum version,
which contains a bugfix to avoid a native php error is emitted,
stating "mysqli::real_connect(): Passing null to parameter #7".

See: doctrine/dbal#5296

One phpstan ignore pattern slightly changed because of a
changed return type declarion of doctrine/dbal. Tackling
the corresponding error should be done in a dedicated test
after proper investigation.

Used commands:

> composer req doctrine/dbal:^2.13.8
> composer req doctrine/dbal:^2.13.8 \
  -d typo3/sysext/core --no-update
> composer req doctrine/dbal:^2.13.8 \
  -d typo3/sysext/install --no-update
> composer req doctrine/dbal:^2.13.8 \
  -d typo3/sysext/redirects --no-update
> composer req doctrine/dbal:^2.13.8 \
  -d typo3/sysext/core --no-update
> Build/Scripts/runTests.sh -s phpstanGenerateBaseline

Resolves: #97222
Releases: 11.5
Change-Id: I6c1712a792780bd2966b3977d43f767e59304bd5
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/74013
Tested-by: core-ci <typo3@b13.com>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Benni Mack <benni@typo3.org>
TYPO3IncTeam pushed a commit to TYPO3-CMS/install that referenced this pull request Mar 22, 2022
This patch raises doctrine/dbal to 2.13.8 as minimum version,
which contains a bugfix to avoid a native php error is emitted,
stating "mysqli::real_connect(): Passing null to parameter #7".

See: doctrine/dbal#5296

One phpstan ignore pattern slightly changed because of a
changed return type declarion of doctrine/dbal. Tackling
the corresponding error should be done in a dedicated test
after proper investigation.

Used commands:

> composer req doctrine/dbal:^2.13.8
> composer req doctrine/dbal:^2.13.8 \
  -d typo3/sysext/core --no-update
> composer req doctrine/dbal:^2.13.8 \
  -d typo3/sysext/install --no-update
> composer req doctrine/dbal:^2.13.8 \
  -d typo3/sysext/redirects --no-update
> composer req doctrine/dbal:^2.13.8 \
  -d typo3/sysext/core --no-update
> Build/Scripts/runTests.sh -s phpstanGenerateBaseline

Resolves: #97222
Releases: 11.5
Change-Id: I6c1712a792780bd2966b3977d43f767e59304bd5
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/74013
Tested-by: core-ci <typo3@b13.com>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Benni Mack <benni@typo3.org>
TYPO3IncTeam pushed a commit to TYPO3-CMS/redirects that referenced this pull request Mar 22, 2022
This patch raises doctrine/dbal to 2.13.8 as minimum version,
which contains a bugfix to avoid a native php error is emitted,
stating "mysqli::real_connect(): Passing null to parameter #7".

See: doctrine/dbal#5296

One phpstan ignore pattern slightly changed because of a
changed return type declarion of doctrine/dbal. Tackling
the corresponding error should be done in a dedicated test
after proper investigation.

Used commands:

> composer req doctrine/dbal:^2.13.8
> composer req doctrine/dbal:^2.13.8 \
  -d typo3/sysext/core --no-update
> composer req doctrine/dbal:^2.13.8 \
  -d typo3/sysext/install --no-update
> composer req doctrine/dbal:^2.13.8 \
  -d typo3/sysext/redirects --no-update
> composer req doctrine/dbal:^2.13.8 \
  -d typo3/sysext/core --no-update
> Build/Scripts/runTests.sh -s phpstanGenerateBaseline

Resolves: #97222
Releases: 11.5
Change-Id: I6c1712a792780bd2966b3977d43f767e59304bd5
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/74013
Tested-by: core-ci <typo3@b13.com>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Benni Mack <benni@typo3.org>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants