Skip to content
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

Fixes for PHP 8.1 compatibility #40

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
library/Zend/Db/Adapter/Abstract.php Outdated Show resolved Hide resolved
library/Zend/Db/Adapter/Pdo/Abstract.php Outdated Show resolved Hide resolved
library/Zend/Db/Select.php Outdated Show resolved Hide resolved
library/Zend/Http/Response.php Outdated Show resolved Hide resolved
library/Zend/Locale/Data.php Outdated Show resolved Hide resolved
library/Zend/Oauth/Http/Utility.php Outdated Show resolved Hide resolved
@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
library/Zend/Db/Adapter/Abstract.php Outdated Show resolved Hide resolved
library/Zend/Db/Statement.php Outdated Show resolved Hide resolved
library/Zend/Http/Client.php Outdated Show resolved Hide resolved
library/Zend/Validate/File/Extension.php Outdated Show resolved Hide resolved
@@ -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

@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