|
9 | 9 | use Doctrine\DBAL\Tests\TestUtil;
|
10 | 10 | use Generator;
|
11 | 11 |
|
| 12 | +use function func_get_args; |
12 | 13 | use function ini_get;
|
| 14 | +use function restore_error_handler; |
| 15 | +use function set_error_handler; |
13 | 16 | use function sprintf;
|
14 |
| - |
15 |
| -use const E_ALL; |
16 |
| -use const E_WARNING; |
| 17 | +use function str_contains; |
17 | 18 |
|
18 | 19 | /** @requires extension oci8 */
|
19 | 20 | class ResultTest extends FunctionalTestCase
|
@@ -56,9 +57,6 @@ public function testTruncatedFetch(
|
56 | 57 | bool $invalidateDataMidFetch,
|
57 | 58 | ): void {
|
58 | 59 | if ($invalidateDataMidFetch) {
|
59 |
| - // prevent the PHPUnit error handler from handling the warnings that oci_*() functions may trigger |
60 |
| - $this->iniSet('error_reporting', (string) (E_ALL & ~E_WARNING)); |
61 |
| - |
62 | 60 | $this->expectException(DriverException::class);
|
63 | 61 | $this->expectExceptionCode(4068);
|
64 | 62 | }
|
@@ -88,22 +86,37 @@ public function testTruncatedFetch(
|
88 | 86 | // Invalidate the original dataset by changing the pipelined function
|
89 | 87 | // after the initial prefetch that caches locally the first X results
|
90 | 88 | $this->createOrReplacePipelinedFunction($expectedTotalRowCount + 10);
|
| 89 | + |
| 90 | + $previous = null; |
| 91 | + $previous = set_error_handler(static function (int $errno, string $errstr) use (&$previous): bool { |
| 92 | + if (str_contains($errstr, 'ORA-04061')) { |
| 93 | + return true; |
| 94 | + } |
| 95 | + |
| 96 | + return $previous !== null && $previous(...func_get_args()); |
| 97 | + }); |
91 | 98 | }
|
92 | 99 |
|
93 |
| - while ($result->fetchOne()) { |
94 |
| - // Attempt to access all remaining rows from the original fetch |
95 |
| - // The rows locally cached from the default prefetch will first be used |
96 |
| - // but when the result attempts to get the remaining 10 rows beyond |
97 |
| - // the first prefetch, nothing will be returned |
98 |
| - // |
99 |
| - // PHP oci8 oci_fetch_array will issue a PHP E_WARNING when the 2nd prefetch occurs |
100 |
| - // oci_fetch_array(): ORA-04068: existing state of packages has been discarded |
101 |
| - // ORA-04061: existing state of function "ROOT.TEST_ORACLE_FETCH_FAILURE" has been invalidated |
102 |
| - // ORA-04065: not executed, altered or dropped function "ROOT.TEST_ORACLE_FETCH_FAILURE" |
103 |
| - // |
104 |
| - // If there was no issue, this should have returned rows totalling 10 |
105 |
| - // higher than the oci8 default prefetch |
106 |
| - continue; |
| 100 | + try { |
| 101 | + while ($result->fetchOne()) { |
| 102 | + // Attempt to access all remaining rows from the original fetch |
| 103 | + // The rows locally cached from the default prefetch will first be used |
| 104 | + // but when the result attempts to get the remaining 10 rows beyond |
| 105 | + // the first prefetch, nothing will be returned |
| 106 | + // |
| 107 | + // PHP oci8 oci_fetch_array will issue a PHP E_WARNING when the 2nd prefetch occurs |
| 108 | + // oci_fetch_array(): ORA-04068: existing state of packages has been discarded |
| 109 | + // ORA-04061: existing state of function "ROOT.TEST_ORACLE_FETCH_FAILURE" has been invalidated |
| 110 | + // ORA-04065: not executed, altered or dropped function "ROOT.TEST_ORACLE_FETCH_FAILURE" |
| 111 | + // |
| 112 | + // If there was no issue, this should have returned rows totalling 10 |
| 113 | + // higher than the oci8 default prefetch |
| 114 | + continue; |
| 115 | + } |
| 116 | + } finally { |
| 117 | + if ($invalidateDataMidFetch) { |
| 118 | + restore_error_handler(); |
| 119 | + } |
107 | 120 | }
|
108 | 121 |
|
109 | 122 | self::assertEquals(
|
|
0 commit comments