-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[Bug #77120] Handle OCI_SUCCESS_WITH_INFO returned from OCISessionBegin #6857
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
--TEST-- | ||
Handling OCI_SUCCESS_WITH_INFO | ||
--SKIPIF-- | ||
<?php | ||
if (!extension_loaded('pdo') || !extension_loaded('pdo_oci')) die('skip not loaded'); | ||
?> | ||
--FILE-- | ||
<?php | ||
|
||
function connectAsAdmin(): PDO { | ||
return PDOTest::test_factory(__DIR__ . '/../../pdo_oci/tests/common.phpt'); | ||
} | ||
|
||
function connectAsUser(string $username, string $password): PDO { | ||
return new PDO(getenv('PDOTEST_DSN'), $username, $password); | ||
} | ||
|
||
function dropProfile(PDO $conn): void { | ||
$conn->exec(<<<'SQL' | ||
BEGIN | ||
EXECUTE IMMEDIATE 'DROP PROFILE BUG77120_PROFILE CASCADE'; | ||
EXCEPTION | ||
WHEN OTHERS THEN | ||
IF SQLCODE != -2380 THEN | ||
RAISE; | ||
END IF; | ||
END; | ||
SQL | ||
); | ||
} | ||
|
||
function dropUser(PDO $conn): void { | ||
$conn->exec(<<<'SQL' | ||
BEGIN | ||
EXECUTE IMMEDIATE 'DROP USER BUG77120_USER CASCADE'; | ||
EXCEPTION | ||
WHEN OTHERS THEN | ||
IF SQLCODE != -1918 THEN | ||
RAISE; | ||
END IF; | ||
END; | ||
SQL | ||
); | ||
} | ||
|
||
function triggerCompilationError(PDO $conn): void { | ||
$conn->exec(<<<'SQL' | ||
CREATE OR REPLACE FUNCTION BUG77120(INT A) RETURN INT | ||
AS | ||
BEGIN | ||
RETURN 0; | ||
END; | ||
SQL | ||
); | ||
} | ||
|
||
require __DIR__ . '/../../pdo/tests/pdo_test.inc'; | ||
|
||
$conn = connectAsAdmin(); | ||
|
||
dropUser($conn); | ||
dropProfile($conn); | ||
|
||
$password = bin2hex(random_bytes(8)); | ||
|
||
$conn->exec('CREATE PROFILE BUG77120_PROFILE LIMIT PASSWORD_LIFE_TIME 1/86400 PASSWORD_GRACE_TIME 1'); | ||
$conn->exec('CREATE USER BUG77120_USER IDENTIFIED BY "' . $password . '" PROFILE BUG77120_PROFILE'); | ||
$conn->exec('GRANT CREATE SESSION TO BUG77120_USER'); | ||
|
||
// let the password expire | ||
sleep(2); | ||
|
||
$conn = connectAsUser('BUG77120_USER', $password); | ||
var_dump($conn->errorInfo()); | ||
|
||
$conn = connectAsAdmin(); | ||
dropUser($conn); | ||
dropProfile($conn); | ||
|
||
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); | ||
triggerCompilationError($conn); | ||
var_dump($conn->errorInfo()); | ||
|
||
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | ||
triggerCompilationError($conn); | ||
var_dump($conn->errorInfo()); | ||
|
||
?> | ||
--EXPECTF-- | ||
array(3) { | ||
[0]=> | ||
string(5) "HY000" | ||
[1]=> | ||
int(28002) | ||
[2]=> | ||
string(%d) "OCISessionBegin: OCI_SUCCESS_WITH_INFO: ORA-28002: %s | ||
(%s:%d)" | ||
} | ||
array(3) { | ||
[0]=> | ||
string(5) "HY000" | ||
[1]=> | ||
int(24344) | ||
[2]=> | ||
string(%d) "OCIStmtExecute: OCI_SUCCESS_WITH_INFO: ORA-24344: %s | ||
(%s:%d)" | ||
} | ||
array(3) { | ||
[0]=> | ||
string(5) "HY000" | ||
[1]=> | ||
int(24344) | ||
[2]=> | ||
string(%d) "OCIStmtExecute: OCI_SUCCESS_WITH_INFO: ORA-24344: %s | ||
(%s:%d)" | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.