Integer limit, offset and column values raise TypeError in getSqlString() on a strict platform
Maintainer antworten meist innerhalb von 1 Tag
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 25/100
Rechercherichtung
Start with the named call sites in src/Sql/Select.php and src/Sql/AbstractSql.php, then read test/unit/TestAsset/TrustingSql92Platform.php and the existing unit tests that exercise these paths. Check how the expression path handles values before quoting. Done means integer and boolean values are safely quoted and the strict test platform catches non-string arguments; the unit suite passes.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Package Version
0.6.x-dev @ e022af5c
Php Version
8.3, 8.4, 8.5
Database Engine
Any platform whose quoteValue() keeps the string type: Sql92, MySQL, SQLite and PostgreSQL (PDO::quote())
Basic Information
PlatformInterface::quoteValue() takes a string (PlatformInterface.php#L68). Three call sites in strict-typed files pass values that can be integers or booleans:
Select::processLimit()passes$this->limit(Select.php#L522), typedstring|int|null.Select::processOffset()passes$this->offset(Select.php#L540).AbstractSql::resolveColumnValue()passes$column(AbstractSql.php#L445), which can beintorbool. Insert and Update values go through it.
The expression path in the same class already casts: quoteValue((string) $argument->getValue()) (AbstractSql.php#L242).
The unit suite does not catch this because TrustingSql92Platform::quoteValue($value) drops the string type (TrustingSql92Platform.php#L16), so it accepts integers.
Prepared statements are unaffected: those paths bind the value instead of quoting it. The MySQL and SQLite driver SelectDecorators render limit and offset without quoting, so only their non-decorated paths are affected.
Steps to Reproduce
(new Select('t'))->limit(10)->getSqlString($platform)with the MySQL or SQLite driver'sAdapterPlatform, or with PostgreSQL's (which has noSelectDecorator).(new Insert('t'))->values(['c' => 1])rendered withbuildSqlString()on the SQLiteAdapterPlatform.
Expected Behavior
Scalars are cast to string before quoting, as the expression path already does: LIMIT '10' and VALUES ('1').
TrustingSql92Platform::quoteValue() should keep the string type, so the suite fails if a call site passes a non-string again. With that change alone, 6 existing tests error.
Actual behavior?
TypeError: PhpDb\Adapter\Platform\Sql92::quoteValue(): Argument #1 ($value) must be of type string, int given, called in src/Sql/Select.php on line 522
On phpdb-pgsql:
TypeError: PDO::quote(): Argument #1 ($string) must be of type string, int given
Additional Info
The same cast was made on the unmerged sql-platform-refactor branch (a0b63fa4, "Fixed small issue where limit/offset were not cast as strings").
- Vorherrschende Sprache
- PHP
- Sterne
- 18
- Forks
- 8
- Ø Merge
- 6 T. 11 Std.
- Gemergte PRs (30 T.)
- 14
Entwicklungsumgebung
- Enthält ein Dockerfile oder eine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Kein Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus php-db/phpdb
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
Maintainer antworten meist innerhalb von 1 Tag
-
RFC
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 66/100
Maintainer antworten meist innerhalb von 1 Tag
-
RFC
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 38/100
Maintainer antworten meist innerhalb von 1 Tag
-
RFC
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 68/100
Maintainer antworten meist innerhalb von 1 Tag
-
RFC
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 45/100
Maintainer antworten meist innerhalb von 1 Tag
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
FriendsOfFlarum/best-answer#137 ·
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 90/100
-
bug
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 86/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
shukiv/jabali-panel#2041 · 1 Kommentar · 1 Reaktion ·
Maintainer antworten meist innerhalb von 1 Tag