Skip to content

Commit 9e541e6

Browse files
committed
pgsqlSetNoticeCallback: test case for closure callback
php#4823 (comment) Closure cannot be used as a callback if not persisted.
1 parent 78dcf9c commit 9e541e6

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
--TEST--
2+
pgsqlSetNoticeCallback catches Postgres "raise notice".
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('pdo') || !extension_loaded('pdo_pgsql')) die('skip not loaded');
6+
require_once dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
7+
require_once dirname(__FILE__) . '/config.inc';
8+
PDOTest::skip();
9+
?>
10+
--FILE--
11+
<?php
12+
function disp($message) { echo trim($message)."\n"; }
13+
function attach($db)
14+
{
15+
$db->pgsqlSetNoticeCallback(function($message) { echo trim($message)."\n"; });
16+
// https://github.com/php/php-src/pull/4823#pullrequestreview-335623806
17+
$eraseCallbackMemoryHere = (object)[1];
18+
}
19+
require dirname(__FILE__) . '/issue78621.inc';
20+
?>
21+
--EXPECT--
22+
NOTICE: I tampered your data, did you know?
23+
array(1) {
24+
[0]=>
25+
array(1) {
26+
["a"]=>
27+
string(2) "oh"
28+
}
29+
}
30+
Done

0 commit comments

Comments
 (0)