From 20f7a13ef07bec09f494b37765b1aa0fb184ef68 Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Wed, 14 Oct 2020 19:38:33 -0700 Subject: [PATCH] Minor changes for PHP 8.0 RC2 (#1204) --- appveyor.yml | 2 +- source/pdo_sqlsrv/pdo_dbh.cpp | 6 ++++++ source/pdo_sqlsrv/pdo_stmt.cpp | 9 ++++++--- source/pdo_sqlsrv/pdo_util.cpp | 15 ++------------- .../pdo_sqlsrv/pdostatement_getColumnMeta.phpt | 2 +- ...ostatement_getColumnMeta_unicode_col_name.phpt | 2 +- 6 files changed, 17 insertions(+), 19 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index f3f0f728..f672aa84 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -30,7 +30,7 @@ environment: SQL_INSTANCE: SQL2019 PHP_VC: vs16 PHP_MAJOR_VER: 8.0 - PHP_MINOR_VER: 0rc1 + PHP_MINOR_VER: 0RC2 PHP_EXE_PATH: Release THREAD: nts platform: x86 diff --git a/source/pdo_sqlsrv/pdo_dbh.cpp b/source/pdo_sqlsrv/pdo_dbh.cpp index 03f192f2..e25168fd 100644 --- a/source/pdo_sqlsrv/pdo_dbh.cpp +++ b/source/pdo_sqlsrv/pdo_dbh.cpp @@ -912,6 +912,8 @@ int pdo_sqlsrv_dbh_begin( _Inout_ pdo_dbh_t *dbh ) DIE ("pdo_sqlsrv_dbh_begin: Uncaught exception occurred."); } + // Should not have reached here but adding this due to compilation warnings + return 0; } @@ -954,6 +956,8 @@ int pdo_sqlsrv_dbh_commit( _Inout_ pdo_dbh_t *dbh ) DIE ("pdo_sqlsrv_dbh_commit: Uncaught exception occurred."); } + // Should not have reached here but adding this due to compilation warnings + return 0; } // pdo_sqlsrv_dbh_rollback @@ -993,6 +997,8 @@ int pdo_sqlsrv_dbh_rollback( _Inout_ pdo_dbh_t *dbh ) DIE ("pdo_sqlsrv_dbh_rollback: Uncaught exception occurred."); } + // Should not have reached here but adding this due to compilation warnings + return 0; } // pdo_sqlsrv_dbh_set_attr diff --git a/source/pdo_sqlsrv/pdo_stmt.cpp b/source/pdo_sqlsrv/pdo_stmt.cpp index 5e82a046..9ecab26a 100644 --- a/source/pdo_sqlsrv/pdo_stmt.cpp +++ b/source/pdo_sqlsrv/pdo_stmt.cpp @@ -724,6 +724,8 @@ int pdo_sqlsrv_stmt_fetch( _Inout_ pdo_stmt_t *stmt, _In_ enum pdo_fetch_orienta DIE ("pdo_sqlsrv_stmt_fetch: Unexpected exception occurred."); } + // Should not have reached here but adding this due to compilation warnings + return 0; } // pdo_sqlsrv_stmt_get_col_data @@ -832,15 +834,16 @@ int pdo_sqlsrv_stmt_get_col_data( _Inout_ pdo_stmt_t *stmt, _In_ int colno, *len = sizeof(zval); } - return 1; - } - + return 1; + } catch ( core::CoreException& ) { return 0; } catch ( ... ) { DIE ("pdo_sqlsrv_stmt_get_col_data: Unexpected exception occurred."); } + // Should not have reached here but adding this due to compilation warnings + return 0; } // pdo_sqlsrv_stmt_set_attr diff --git a/source/pdo_sqlsrv/pdo_util.cpp b/source/pdo_sqlsrv/pdo_util.cpp index 02fbee87..c4afaa12 100644 --- a/source/pdo_sqlsrv/pdo_util.cpp +++ b/source/pdo_sqlsrv/pdo_util.cpp @@ -635,20 +635,9 @@ void add_remaining_errors_to_array (_In_ sqlsrv_error const* error, _Inout_ zval if (error->next != NULL && PDO_SQLSRV_G(report_additional_errors)) { sqlsrv_error *p = error->next; while (p != NULL) { - // check if sql state or native message is NULL and handle them accordingly - char *state = ""; - char *msg = ""; - - if (p->sqlstate != NULL) { - state = reinterpret_cast(p->sqlstate); - } - if (p->native_message != NULL) { - msg = reinterpret_cast(p->native_message); - } - - add_next_index_string(array_z, state); + add_next_index_string(array_z, reinterpret_cast(p->sqlstate)); add_next_index_long(array_z, p->native_code); - add_next_index_string(array_z, msg); + add_next_index_string(array_z, reinterpret_cast(p->native_message)); p = p-> next; } diff --git a/test/functional/pdo_sqlsrv/pdostatement_getColumnMeta.phpt b/test/functional/pdo_sqlsrv/pdostatement_getColumnMeta.phpt index 6493bf94..bf54175a 100644 --- a/test/functional/pdo_sqlsrv/pdostatement_getColumnMeta.phpt +++ b/test/functional/pdo_sqlsrv/pdostatement_getColumnMeta.phpt @@ -58,7 +58,7 @@ function fetchBoth($conn, $tbname) echo "Expect getColumnMeta to fail with -1\n"; } catch (Error $e) { if (PHP_MAJOR_VERSION == 8) { - $error = '*PDOStatement::getColumnMeta(): Argument #1 ($index) must be greater than or equal to 0*'; + $error = '*PDOStatement::getColumnMeta(): Argument #1 ($column) must be greater than or equal to 0*'; } else { $error = '*Invalid column reference: column number must be non-negative*'; } diff --git a/test/functional/pdo_sqlsrv/pdostatement_getColumnMeta_unicode_col_name.phpt b/test/functional/pdo_sqlsrv/pdostatement_getColumnMeta_unicode_col_name.phpt index 2aba3fa9..f3485ec6 100644 --- a/test/functional/pdo_sqlsrv/pdostatement_getColumnMeta_unicode_col_name.phpt +++ b/test/functional/pdo_sqlsrv/pdostatement_getColumnMeta_unicode_col_name.phpt @@ -63,7 +63,7 @@ function fetchBoth($conn, $tbname) echo "Expect getColumnMeta to fail with -1\n"; } catch (Error $e) { if (PHP_MAJOR_VERSION == 8) { - $error = '*PDOStatement::getColumnMeta(): Argument #1 ($index) must be greater than or equal to 0*'; + $error = '*PDOStatement::getColumnMeta(): Argument #1 ($column) must be greater than or equal to 0*'; } else { $error = '*Invalid column reference: column number must be non-negative*'; }