Skip to content

Commit 7a1be1c

Browse files
authored
fix fatal error on mysql error 1103 / incorrect table (#447)
1 parent a3a1291 commit 7a1be1c

File tree

5 files changed

+23
-7
lines changed

5 files changed

+23
-7
lines changed

.github/workflows/tests.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ jobs:
8787
# ignore php8.2 requirement error https://github.com/sebastianbergmann/phpunit/issues/5033
8888
composer-options: "--prefer-dist --no-progress --ignore-platform-req=php+"
8989

90-
- name: Setup Problem Matchers for PHPUnit
91-
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
90+
- name: Configure matchers
91+
uses: mheap/phpunit-matcher-action@v1
9292

9393
- name: Lint
9494
run: php vendor/bin/parallel-lint --colors src tests
@@ -97,7 +97,7 @@ jobs:
9797
run: |
9898
mysql -uroot -h127.0.0.1 -proot < tests/schema.sql
9999
100-
- run: composer phpunit
100+
- run: composer phpunit -- --teamcity
101101

102102
replay:
103103
name: PHPUnit (reflection replay)
@@ -135,7 +135,7 @@ jobs:
135135
# ignore php8.2 requirement error https://github.com/sebastianbergmann/phpunit/issues/5033
136136
composer-options: "--prefer-dist --no-progress --ignore-platform-req=php+"
137137

138-
- name: Setup Problem Matchers for PHPUnit
139-
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
138+
- name: Configure matchers
139+
uses: mheap/phpunit-matcher-action@v1
140140

141-
- run: composer phpunit
141+
- run: composer phpunit -- --teamcity

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ pdo.php
1010
.env
1111

1212
.idea/
13+
14+
/test.php

src/QueryReflection/MysqliQueryReflector.php

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ final class MysqliQueryReflector implements QueryReflector, RecordingReflector
2020
private const MYSQL_SYNTAX_ERROR_CODE = 1064;
2121
private const MYSQL_UNKNOWN_COLUMN_IN_FIELDLIST = 1054;
2222
public const MYSQL_UNKNOWN_TABLE = 1146;
23+
public const MYSQL_INCORRECT_TABLE = 1103;
2324

2425
public const MYSQL_HOST_NOT_FOUND = 2002;
2526

@@ -29,6 +30,7 @@ final class MysqliQueryReflector implements QueryReflector, RecordingReflector
2930
self::MYSQL_SYNTAX_ERROR_CODE,
3031
self::MYSQL_UNKNOWN_COLUMN_IN_FIELDLIST,
3132
self::MYSQL_UNKNOWN_TABLE,
33+
self::MYSQL_INCORRECT_TABLE,
3234
];
3335

3436
private const MAX_CACHE_SIZE = 50;

tests/rules/config/.phpunit-phpstan-dba-pdo-mysql.cache

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/rules/data/query-plan-analyzer.php

+12
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,16 @@ public function nonSimulatableQuery(Connection $conn, $email): void
6060
{
6161
$conn->executeQuery('SELECT * FROM ada WHERE email = '.$email);
6262
}
63+
64+
public function bug442(Connection $conn, string $table)
65+
{
66+
// just make sure we don't fatal error
67+
$conn->fetchAllAssociative("SELECT * FROM `$table`");
68+
69+
$query = 'SELECT email, adaid FROM '. $table .' WHERE adaid = ?';
70+
$conn->fetchAssociative($query, [1]);
71+
72+
$query = "SELECT email, adaid FROM `$table` WHERE adaid = ?";
73+
$conn->fetchAssociative($query, [1]);
74+
}
6375
}

0 commit comments

Comments
 (0)