Skip to content

Commit b7d0f28

Browse files
authored
error on from table-name create from function-call (#459)
1 parent 31e91bb commit b7d0f28

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

tests/rules/data/syntax-error-in-prepared-statement.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,4 +351,14 @@ public function testInvalidDeleteUpdateInsert(Connection $conn)
351351
]);
352352
}
353353

354+
/**
355+
* @return string|false
356+
*/
357+
private function returnsUnion() {}
358+
359+
public function bug458(Connection $conn)
360+
{
361+
$table = $this->returnsUnion();
362+
$conn->executeQuery('SELECT * FROM ' . $table . ' LIMIT 1');
363+
}
354364
}

tests/rules/data/syntax-error-in-query-function.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,15 @@ public function bug442(\mysqli $mysqli, string $table)
4343
{
4444
mysqli_query($mysqli, "SELECT * FROM `$table`");
4545
}
46+
47+
/**
48+
* @return string|false
49+
*/
50+
private function returnsUnion() {}
51+
52+
public function bug458(\mysqli $mysqli)
53+
{
54+
$table = $this->returnsUnion();
55+
mysqli_query($mysqli,'SELECT * FROM ' . $table . ' LIMIT 1');
56+
}
4657
}

tests/rules/data/syntax-error-in-query-method.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,4 +138,15 @@ public function testInvalidDeleteUpdateInsert(PDO $pdo)
138138
$pdo->query('REPLACE into adasfd SET email="sdf"');
139139
}
140140

141+
/**
142+
* @return string|false
143+
*/
144+
private function returnsUnion() {}
145+
146+
public function bug458(PDO $pdo)
147+
{
148+
$table = $this->returnsUnion();
149+
$pdo->query('SELECT * FROM ' . $table . ' LIMIT 1');
150+
}
151+
141152
}

0 commit comments

Comments
 (0)