Skip to content

Commit 3cefdcb

Browse files
committed
bug #50268 Allow resources in Query::setParam (l-vo)
This PR was merged into the 6.2 branch. Discussion ---------- Allow resources in Query::setParam | Q | A | ------------- | --- | Branch? | 6.2 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | | License | MIT | Doc PR | See #46744 (comment) (failures in tests seem not related) Commits ------- 318e0e4 Allow resources in Query::setParam
2 parents 3835573 + 318e0e4 commit 3cefdcb

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

src/Symfony/Bridge/Doctrine/Middleware/Debug/Query.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function stop(): void
4343
}
4444
}
4545

46-
public function setParam(string|int $param, null|string|int|float|bool &$variable, int $type): void
46+
public function setParam(string|int $param, mixed &$variable, int $type): void
4747
{
4848
// Numeric indexes start at 0 in profiler
4949
$idx = \is_int($param) ? $param - 1 : $param;

src/Symfony/Bridge/Doctrine/Tests/Middleware/Debug/MiddlewareTest.php

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -145,23 +145,31 @@ public function testWithParamBound(callable $executeMethod)
145145
{
146146
$this->init();
147147

148-
$product = 'product1';
149-
$price = 12.5;
150-
$stock = 5;
148+
$sql = <<<EOT
149+
INSERT INTO products(name, price, stock, picture, tags)
150+
VALUES (?, ?, ?, ?, ?)
151+
EOT;
152+
153+
$expectedRes = $res = $this->getResourceFromString('mydata');
151154

152-
$stmt = $this->conn->prepare('INSERT INTO products(name, price, stock) VALUES (?, ?, ?)');
155+
$stmt = $this->conn->prepare($sql);
153156
$stmt->bindParam(1, $product);
154157
$stmt->bindParam(2, $price);
155158
$stmt->bindParam(3, $stock, ParameterType::INTEGER);
159+
$stmt->bindParam(4, $res, ParameterType::BINARY);
160+
161+
$product = 'product1';
162+
$price = 12.5;
163+
$stock = 5;
156164

157165
$executeMethod($stmt);
158166

159167
// Debug data should not be affected by these changes
160168
$debug = $this->debugDataHolder->getData()['default'] ?? [];
161169
$this->assertCount(2, $debug);
162-
$this->assertSame('INSERT INTO products(name, price, stock) VALUES (?, ?, ?)', $debug[1]['sql']);
163-
$this->assertSame(['product1', '12.5', 5], $debug[1]['params']);
164-
$this->assertSame([ParameterType::STRING, ParameterType::STRING, ParameterType::INTEGER], $debug[1]['types']);
170+
$this->assertSame($sql, $debug[1]['sql']);
171+
$this->assertSame(['product1', 12.5, 5, $expectedRes], $debug[1]['params']);
172+
$this->assertSame([ParameterType::STRING, ParameterType::STRING, ParameterType::INTEGER, ParameterType::BINARY], $debug[1]['types']);
165173
$this->assertGreaterThan(0, $debug[1]['executionMS']);
166174
}
167175

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy