Skip to content

Fixes for PHP 8.1 compatibility #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

karyna-t
Copy link

@karyna-t karyna-t commented Oct 27, 2021

Description (*)

Issues were found when trying to launch Magento, and running Unit Tests, on php-8.1. env.
This PR is fixing Zend code to be compatible with PHP 8.1.

Related Pull Requests

Related Issues

  1. Fix Unit tests to be compatible with PHP8.1 magento2#34441

@karyna-t karyna-t force-pushed the php8.1-compatibility/fixes branch 2 times, most recently from e010510 to 95f04f4 Compare November 2, 2021 20:37
@karyna-t karyna-t force-pushed the php8.1-compatibility/fixes branch from 95f04f4 to 72bc347 Compare November 15, 2021 16:05
@karyna-t karyna-t force-pushed the php8.1-compatibility/fixes branch from 469212b to 5364d08 Compare November 17, 2021 10:14
@karyna-t karyna-t force-pushed the php8.1-compatibility/fixes branch from 2685e14 to 59ddff2 Compare November 18, 2021 13:19
@karyna-t karyna-t changed the title Fixes for the issues found by Magento Unit Tests for PHP 8.1 compatibility Fixes for PHP 8.1 compatibility Nov 18, 2021
@karyna-t karyna-t force-pushed the php8.1-compatibility/fixes branch from 59ddff2 to a79c8ec Compare November 19, 2021 15:55
@@ -134,14 +134,17 @@ protected function _prepare($sql)
*/
protected function _parseParameters($sql)
{
$sql = $this->_stripQuoted($sql);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend leaving it as it is

// split into text and params
$this->_sqlSplit = preg_split('/(\?|\:[a-zA-Z0-9_]+)/',
$sql, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
if ($sql !== null) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How will the following foreach be executed if $sql === null?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -134,7 +132,6 @@ public function getExtension()
*/
public function setExtension($extension)
{
$this->_extension = null;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think

$this->_extension = '';

is more appropriate

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @fascinosum
The property $_extension is '' by default

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only right after initialization of the object

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -245,7 +245,7 @@ public function _execute(array $params = null)
* @return mixed Array, object, or scalar depending on fetch mode.
* @throws Zend_Db_Statement_Exception
*/
public function fetch($style = null, $cursor = null, $offset = null)
public function fetch($style = null, $cursor = PDO::FETCH_ORI_NEXT, $offset = 0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move these operations to the method code

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @fascinosum , done

@andrewbess andrewbess force-pushed the php8.1-compatibility/fixes branch from bbbc1c8 to 438053d Compare November 29, 2021 17:36
@magento-devops-reposync-svc magento-devops-reposync-svc merged commit 83f34f5 into magento:master Nov 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants