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

converter breaks when connection is named $something->mysql #32

Open
JTBrinkmann opened this issue Jun 25, 2020 · 2 comments
Open

converter breaks when connection is named $something->mysql #32

JTBrinkmann opened this issue Jun 25, 2020 · 2 comments
Labels

Comments

@JTBrinkmann
Copy link
Contributor

JTBrinkmann commented Jun 25, 2020

While updating a legacy project, I noticed that this tool fails to convert files that store a connection in a property called mysql (e.g. $this->mysql or $x->mysql). This breaks lines using that connection as parameter. I noticed it behaving differently depending on whether the next mysql_* call is inside brackets. It doesn't seem to break if the property has a different name (e.g. $this->mysqlConn) or if it's a variable (i.e. $mysql)

example:

<?php
$a = mysql_query('SELECT 1', $this->mysql);
if (mysql_num_rows($a)) { /* ... */ }

$b = mysql_query('SELECT 1', $this->mysql);
(
  mysql_num_rows($b)
);


$c = mysql_query('SELECT 1', $this->mysql);
mysql_num_rows($c);
( mysql_num_rows($c) );

expected result:

<?php
$a = mysqli_query($this->mysql, 'SELECT 1');
if (mysqlo_num_rows($a)) { /* ... */ }

$b = mysqli_query($this->mysql, 'SELECT 2');
(
  mysqli_num_rows($b)
);


$c = mysqli_query($this->mysql, 'SELECT 3');
mysqli_num_rows($c);
( mysqli_num_rows($c) );

actual result:

<?php
$a = mysql);
if (mysqli_query( $this->mysqli_num_rows($a), 'SELECT 1') { /* ... */ }

$b = mysql);
(
  mysqli_query( $this->mysqli_num_rows($b)
, 'SELECT 2');


$c = mysql);

tested on current master (dc496d1) with this file https://github.com/simplepie/simplepie/blob/1.2.1/simplepie.inc (old version)

@JTBrinkmann
Copy link
Contributor Author

As a workaround, I renamed the property before running the tool.

@philip
Copy link
Owner

philip commented Sep 20, 2020

Thank you, this is an unfortunate bug.

@philip philip added the bug label Sep 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants