MySQLConverterTool icon indicating copy to clipboard operation
MySQLConverterTool copied to clipboard

converter breaks when connection is named $something->mysql

Open JTBrinkmann opened this issue 5 years ago • 2 comments

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 avatar Jun 25 '20 12:06 JTBrinkmann

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

JTBrinkmann avatar Jun 25 '20 12:06 JTBrinkmann

Thank you, this is an unfortunate bug.

philip avatar Sep 20 '20 16:09 philip