Skip to content
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

Php8 #167

Open
wants to merge 41 commits into
base: 4.1.x
Choose a base branch
from
Open

Php8 #167

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
6c93bbc
Update .travis.yml
Beakerboy May 11, 2021
afe9796
Update Connection.php
Beakerboy May 11, 2021
6d11d6b
Update Utils.php
Beakerboy May 11, 2021
b0c2331
Update Update.php
Beakerboy May 11, 2021
fb3ae1e
Update Utils.php
Beakerboy May 11, 2021
173967e
Update Connection.php
Beakerboy May 11, 2021
838aac9
Update composer.json
Beakerboy May 11, 2021
ae38948
Update drupal9.1.x.sh
Beakerboy May 11, 2021
b37905a
Update drupal9.1.x.sh
Beakerboy May 11, 2021
d17e3da
Update drupal9.1.x.sh
Beakerboy May 11, 2021
4ff9108
Update drupal9.1.x.sh
Beakerboy May 11, 2021
e96ba2f
Update drupal9.1.x.sh
Beakerboy May 11, 2021
6faa836
Update drupal9.1.x.sh
Beakerboy May 11, 2021
9e950c4
Create Foo.php
Beakerboy May 11, 2021
1d100aa
Update and rename Foo.php to StatementWrapperLegacyTeatphp
Beakerboy May 11, 2021
9ee78e8
Update and rename StatementWrapperLegacyTeatphp to StatementWrapperLe…
Beakerboy May 11, 2021
0ce8ae4
Update StatementWrapperLegacyTest.php
Beakerboy May 11, 2021
f4f0c75
Update StatementWrapperLegacyTest.php
Beakerboy May 11, 2021
3ffa3ae
Update StatementWrapperLegacyTest.php
Beakerboy May 12, 2021
003426e
Update StatementWrapperLegacyTest.php
Beakerboy May 12, 2021
4e792e5
Update StatementWrapperLegacyTest.php
Beakerboy May 12, 2021
c577370
[Skip ci]
Beakerboy May 12, 2021
6fbe7ac
[skip ci]
Beakerboy May 12, 2021
9ea3747
Update .travis.yml
Beakerboy May 12, 2021
36409ed
Update StatementWrapperLegacyTest.php
Beakerboy May 12, 2021
6b2c32c
Update StatementWrapperLegacyTest.php
Beakerboy May 12, 2021
455137d
Update StatementWrapperLegacyTest.php
Beakerboy May 12, 2021
9224455
Update StatementWrapperLegacyTest.php
Beakerboy May 12, 2021
86b0304
Update StatementWrapperLegacyTest.php
Beakerboy May 12, 2021
44e1ed3
Update StatementWrapperLegacyTest.php
Beakerboy May 12, 2021
5fadde6
Update StatementWrapperLegacyTest.php
Beakerboy May 12, 2021
20d2258
Update StatementWrapperLegacyTest.php
Beakerboy May 12, 2021
a066cf1
Update StatementWrapperLegacyTest.php
Beakerboy May 12, 2021
c1e2114
Update StatementWrapperLegacyTest.php
Beakerboy May 12, 2021
85c90ca
Update StatementWrapperLegacyTest.php
Beakerboy May 12, 2021
8759851
Update StatementWrapperLegacyTest.php
Beakerboy May 12, 2021
b749d39
Update StatementWrapperLegacyTest.php
Beakerboy May 12, 2021
d32b386
[skip ci]
Beakerboy May 12, 2021
6825cd3
Update .travis.yml
Beakerboy May 12, 2021
543ea5d
Update .travis.yml
Beakerboy May 12, 2021
9cd78e2
Update TestSuiteBase.php
Beakerboy May 12, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"drupal/core" : "^9.1"
},
"require-dev": {
"phpunit/phpunit": "^7",
"phpunit/phpunit": "^8.5.10",
"phpstan/phpstan": "*",
"php-coveralls/php-coveralls": "*"
}
Expand Down
5 changes: 0 additions & 5 deletions dev/TestSuites/TestSuiteBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,8 @@ abstract class TestSuiteBase extends TestSuite {
protected $failingClasses = [
// Kernel Test Failures.
'/core/tests/Drupal/KernelTests/Core/Database/SelectSubqueryTest.php',
'/core/tests/Drupal/KernelTests/Core/Database/SchemaTest.php',
'/core/modules/aggregator/tests/src/Kernel/Migrate/MigrateAggregatorStubTest.php',
'/core/modules/migrate_drupal/tests/src/Kernel/d7/FieldDiscoveryTest.php',
'/core/modules/field_ui/tests/src/Kernel/EntityDisplayTest.php',
// Functional Test Failures.
'/core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationTest.php',
'/core/modules/datetime/tests/src/Functional/Views/FilterDateTest.php',
'/core/modules/language/tests/src/Functional/ConfigurableLanguageManagerTest.php',
'/core/modules/locale/tests/src/Functional/LocaleLocaleLookupTest.php',
'/core/modules/path/tests/src/Functional/PathAliasTest.php',
Expand Down
1 change: 1 addition & 0 deletions dev/travis/drupal9.1.x.sh
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
bash ../sqlsrv/dev/travis/drupal9.x.sh
composer require phpunit/phpunit:^8.5.10 --with-all-dependencies
17 changes: 16 additions & 1 deletion src/Driver/Database/sqlsrv/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Drupal\Core\Database\DatabaseException;
use Drupal\Core\Database\DatabaseNotFoundException;
use Drupal\Core\Database\StatementInterface;
use Drupal\Core\Database\StatementWrapper;
use Drupal\Core\Database\TransactionNoActiveException;
use Drupal\Core\Database\TransactionOutOfOrderException;
use Drupal\Core\Database\TransactionNameNonUniqueException;
Expand All @@ -16,6 +17,16 @@
*/
class Connection extends DatabaseConnection {

/**
* {@inheritdoc}
*/
protected $statementClass = NULL;

/**
* {@inheritdoc}
*/
protected $statementWrapperClass = StatementWrapper::class;

/**
* The identifier quote characters for the database type.
*
Expand Down Expand Up @@ -458,7 +469,7 @@ public function pushTransaction($name) {
* This method is overriden to manage EMULATE_PREPARE
* behaviour to prevent some compatibility issues with SQL Server.
*
* @param string|\Drupal\Core\Database\Statement $query
* @param string|\Drupal\Core\Database\Statement $query|\PDOStatement $query
* The query to execute. In most cases this will be a string containing
* an SQL query with placeholders. An already-prepared instance of
* StatementInterface may also be passed in order to allow calling
Expand Down Expand Up @@ -515,6 +526,10 @@ public function query($query, array $args = [], $options = []) {
$stmt = $query;
$stmt->execute(NULL, $options);
}
elseif ($query instanceof \PDOStatement) {
$stmt = $query;
$stmt->execute();
}
else {
$this->expandArguments($query, $args);
$query = rtrim($query, "; \t\n\r\0\x0B");
Expand Down
4 changes: 2 additions & 2 deletions src/Driver/Database/sqlsrv/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ public function execute() {
// We assume that an expression will never happen on a BLOB field,
// which is a fairly safe assumption to make since in most cases
// it would be an invalid query anyway.
$stmt->bindParam($placeholder, $data['arguments'][$placeholder]);
$stmt->getClientStatement()->bindParam($placeholder, $data['arguments'][$placeholder]);
}
}
if ($data['expression'] instanceof SelectInterface) {
$data['expression']->compile($this->connection, $this);
$select_query_arguments = $data['expression']->arguments();
foreach ($select_query_arguments as $placeholder => $argument) {
$stmt->bindParam($placeholder, $select_query_arguments[$placeholder]);
$stmt->getClientStatement()->bindParam($placeholder, $select_query_arguments[$placeholder]);
}
}
unset($fields[$field]);
Expand Down
15 changes: 8 additions & 7 deletions src/Driver/Database/sqlsrv/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Drupal\sqlsrv\Driver\Database\sqlsrv;

use Drupal\Core\Database\StatementWrapper;
use Symfony\Component\Yaml\Parser;

/**
Expand All @@ -12,14 +13,14 @@ class Utils {
/**
* Bind the arguments to the statement.
*
* @param \PDOStatement $stmt
* @param StatementWrapper $stmt
* Statement.
* @param array $values
* Argument values.
*/
public static function bindArguments(\PDOStatement $stmt, array &$values) {
public static function bindArguments(StatementWrapper $stmt, array &$values) {
foreach ($values as $key => &$value) {
$stmt->bindParam($key, $value, \PDO::PARAM_STR);
$stmt->getClientStatement()->bindParam($key, $value, \PDO::PARAM_STR);
}
}

Expand All @@ -28,7 +29,7 @@ public static function bindArguments(\PDOStatement $stmt, array &$values) {
*
* Takes care of properly managing binary data.
*
* @param \PDOStatement $stmt
* @param StatementWrapper $stmt
* PDOStatement to bind the values to.
* @param array $values
* Values to bind. It's an array where the keys are column
Expand All @@ -45,7 +46,7 @@ public static function bindArguments(\PDOStatement $stmt, array &$values) {
* @param mixed $blob_suffix
* Suffix for the blob key.
*/
public static function bindValues(\PDOStatement $stmt, array &$values, array &$blobs, $placeholder_prefix, array $columnInformation, &$max_placeholder = NULL, $blob_suffix = NULL) {
public static function bindValues(StatementWrapper $stmt, array &$values, array &$blobs, $placeholder_prefix, array $columnInformation, &$max_placeholder = NULL, $blob_suffix = NULL) {
if (empty($max_placeholder)) {
$max_placeholder = 0;
}
Expand All @@ -56,12 +57,12 @@ public static function bindValues(\PDOStatement $stmt, array &$values, array &$b
$blobs[$blob_key] = fopen('php://memory', 'a');
fwrite($blobs[$blob_key], $field_value);
rewind($blobs[$blob_key]);
$stmt->bindParam($placeholder, $blobs[$blob_key], \PDO::PARAM_LOB, 0, \PDO::SQLSRV_ENCODING_BINARY);
$stmt->getClientStatement()->bindParam($placeholder, $blobs[$blob_key], \PDO::PARAM_LOB, 0, \PDO::SQLSRV_ENCODING_BINARY);
}
else {
// Even though not a blob, make sure we retain a copy of these values.
$blobs[$blob_key] = $field_value;
$stmt->bindParam($placeholder, $blobs[$blob_key], \PDO::PARAM_STR);
$stmt->getClientStatement()->bindParam($placeholder, $blobs[$blob_key], \PDO::PARAM_STR);
}
}
}
Expand Down