Greeting Drupal gurus. I have an error that is now not allowing access to to the Configuration page as well as the Status Report page (however i can get to admin pages past those by typing in the URL directly). All other content (admin or user-facing) is otherwise unaffected. I recently upgraded this system to Drupal 9.0.2 along with sqlsrv to 4.0.2 and PHP is at 7.4.8 MySQL is at 5.6 currently. I am now at a dead-end trying to troubleshoot the following error:

**NOTE: the webroot folder is named drupal-8.7.8. that is not the OS version.

TypeError: Argument 1 passed to Drupal\sqlsrv\Driver\Database\sqlsrv\Utils::deployCustomFunctions() must be an instance of Drupal\sqlsrv\Driver\Database\sqlsrv\Connection, instance of Drupal\Driver\Database\sqlsrv\Connection given, called in C:\inetpub\wwwroot\drupal\drupal-8.7.8\modules\sqlsrv\sqlsrv.install on line 139 in Drupal\sqlsrv\Driver\Database\sqlsrv\Utils::deployCustomFunctions() (line 107 of C:\inetpub\wwwroot\drupal\drupal-8.7.8\modules\sqlsrv\src\Driver\Database\sqlsrv\Utils.php)
#0 C:\inetpub\wwwroot\drupal\drupal-8.7.8\modules\sqlsrv\sqlsrv.install(139): Drupal\sqlsrv\Driver\Database\sqlsrv\Utils::deployCustomFunctions()
#1 [internal function]: sqlsrv_requirements()
#2 C:\inetpub\wwwroot\drupal\drupal-8.7.8\core\lib\Drupal\Core\Extension\ModuleHandler.php(403): call_user_func_array()
#3 C:\inetpub\wwwroot\drupal\drupal-8.7.8\core\modules\system\src\SystemManager.php(109): Drupal\Core\Extension\ModuleHandler->invokeAll()
#4 C:\inetpub\wwwroot\drupal\drupal-8.7.8\core\modules\system\src\Controller\SystemInfoController.php(49): Drupal\system\SystemManager->listRequirements()
#5 [internal function]: Drupal\system\Controller\SystemInfoController->status()
#6 C:\inetpub\wwwroot\drupal\drupal-8.7.8\core\lib\Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()
#7 C:\inetpub\wwwroot\drupal\drupal-8.7.8\core\lib\Drupal\Core\Render\Renderer.php(573): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#8 C:\inetpub\wwwroot\drupal\drupal-8.7.8\core\lib\Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext()
#9 C:\inetpub\wwwroot\drupal\drupal-8.7.8\core\lib\Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
#10 C:\inetpub\wwwroot\drupal\drupal-8.7.8\vendor\symfony\http-kernel\HttpKernel.php(158): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#11 C:\inetpub\wwwroot\drupal\drupal-8.7.8\vendor\symfony\http-kernel\HttpKernel.php(80): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#12 C:\inetpub\wwwroot\drupal\drupal-8.7.8\core\lib\Drupal\Core\StackMiddleware\Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle()
#13 C:\inetpub\wwwroot\drupal\drupal-8.7.8\core\lib\Drupal\Core\StackMiddleware\KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle()
#14 C:\inetpub\wwwroot\drupal\drupal-8.7.8\core\modules\page_cache\src\StackMiddleware\PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#15 C:\inetpub\wwwroot\drupal\drupal-8.7.8\core\modules\page_cache\src\StackMiddleware\PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass()
#16 C:\inetpub\wwwroot\drupal\drupal-8.7.8\core\lib\Drupal\Core\StackMiddleware\ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle()
#17 C:\inetpub\wwwroot\drupal\drupal-8.7.8\core\lib\Drupal\Core\StackMiddleware\NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#18 C:\inetpub\wwwroot\drupal\drupal-8.7.8\vendor\stack\builder\src\Stack\StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#19 C:\inetpub\wwwroot\drupal\drupal-8.7.8\core\lib\Drupal\Core\DrupalKernel.php(705): Stack\StackedHttpKernel->handle()
#20 C:\inetpub\wwwroot\drupal\drupal-8.7.8\index.php(19): Drupal\Core\DrupalKernel->handle()
#21 {main}

If anyone out there can help me so I can get these 2 pages back up and running it would be greatly appreciated.

Comments

ST.TWG.TEST created an issue. See original summary.

avpaderno’s picture

Title: Utils::deployCustomFunctions() must be an instance of Connection » "Utils::deployCustomFunctions() must be an instance of Connection"
beakerboy’s picture

What version of Drupal and sqlsrv did you upA grade from?

ST.TWG.TEST’s picture

Drupal was upgraded from 8.9
sqlsrv: sqlsrv-8.x-1.0-rc1

ST.TWG.TEST’s picture

The Release note says:
Microsoft Drivers 5.6 for PHP for SQL Server

beakerboy’s picture

Have you removed the old driver code from webroot\drivers ? Newer versions of Drupal allow custom database driver code to reside directly within the module. If you have, then something is keeping old php files in memory, like Wincache. What length of time is Wincache set to expire? Does your settings.php specify the driver namespace? If so, that should be removed.

ST.TWG.TEST’s picture

Looking inside of C:>PHP>ext I removed all the other php_pdo_sqlsrv_74_nts versions. What other locations would the old driver code be present? I do not see it inside of Wincache and there is no references in settings.php. Any advice?

beakerboy’s picture

I did not mean the pdo driver, but the Drupal sqlsrv driver. Older versions requires the site admin to manually move the php files to webroot/drivers. Files in this location had the namespace Drupal\Driver\Database\sqlsrv. Now, files remain webroot/modules/contrib/sqlsrv/src and have the namespace of Drupal\sqlsrv\Driver\Database\sqlsrv. Somewhere, there must still be a Connection.php file with the old namespace.

ST.TWG.TEST’s picture

Beakerboy,

I have found only 2 Connection.php files so far and copied the top of the code block (see below). Which one needs to be edited and how (or both)? Or am I looking in the wrong place?

C:\inetpub\wwwroot\drupal\drupal-8.7.8\drivers\lib\Drupal\Driver\Database\sqlsrv

<?php

/**

* @file

* Definition of Drupal\Driver\Database\sqlsrv\Connection

*/

namespace Drupal\Driver\Database\sqlsrv;

use Drupal\Core\Database\Database;

use Drupal\Core\Database\StatementInterface;

use Drupal\Core\Database\IntegrityConstraintViolationException;

use Drupal\Core\Database\DatabaseExceptionWrapper;

use Drupal\Core\Database\DatabaseException;

use Drupal\Core\Database\DatabaseNotFoundException;

use Drupal\Core\Database\Connection as DatabaseConnection;

use Drupal\Core\Database\TransactionNoActiveException as DatabaseTransactionNoActiveException;

use Drupal\Core\Database\TransactionCommitFailedException as DatabaseTransactionCommitFailedException;

use Drupal\Core\Database\TransactionOutOfOrderException as DatabaseTransactionOutOfOrderException;

use Drupal\Core\Database\TransactionException as DatabaseTransactionException;

use Drupal\Core\Database\TransactionNameNonUniqueException as DatabaseTransactionNameNonUniqueException;

use Drupal\Driver\Database\sqlsrv\TransactionIsolationLevel as DatabaseTransactionIsolationLevel;

use Drupal\Driver\Database\sqlsrv\TransactionScopeOption as DatabaseTransactionScopeOption;

use Drupal\Driver\Database\sqlsrv\TransactionSettings as DatabaseTransactionSettings;

use Drupal\Driver\Database\sqlsrv\Context as DatabaseContext;

use Drupal\Driver\Database\sqlsrv\DriverSettings;

use Drupal\Driver\Database\sqlsrv\Utils as DatabaseUtils;

use PDO as PDO;

use PDOException as PDOException;

use Exception as Exception;

*******************************************************

C:\inetpub\wwwroot\drupal\drupal-8.7.8\core\lib\Drupal\Core\Database

<?php

namespace Drupal\Core\Database;

use Drupal\Component\Assertion\Inspector;

use Drupal\Core\Database\Query\Condition;

use Drupal\Core\Database\Query\Delete;

use Drupal\Core\Database\Query\Insert;

use Drupal\Core\Database\Query\Merge;

use Drupal\Core\Database\Query\Select;

use Drupal\Core\Database\Query\Truncate;

use Drupal\Core\Database\Query\Update;

use Drupal\Core\Database\Query\Upsert;

/**

* Base Database API class.

*

* This class provides a Drupal-specific extension of the PDO database

* abstraction class in PHP. Every database driver implementation must provide a

* concrete implementation of it to support special handling required by that

* database.

*

* @see http://php.net/manual/book.pdo.php

*/

abstract class Connection {

***************************************************

Or inside the php.ini?

; Directory in which the loadable extensions (modules) reside.

; http://php.net/extension-dir

;extension_dir = "./"

; On windows:

extension_dir = "C:\PHP_7_4_8\ext\"

beakerboy’s picture

Never edit, move, or delete anything in webroot\core. Those are the main Drupal files.

The top one is the old driver. You should delete the entire C:\inetpub\wwwroot\drupal\drupal-8.7.8\drivers directory.

The new Connection.php file should be in C:\inetpub\wwwroot\drupal\drupal-8.7.8\modules\sqlsrv\src\Driver\Database\sqlsrv or C:\inetpub\wwwroot\drupal\drupal-8.7.8\modules\contrib\sqlsrv\src\Driver\Database\sqlsrv

Your “webroot” is C:\inetpub\wwwroot\drupal\drupal-8.7.8\ so if I or anyone else asks about webroot-whatever, it means relative to that path...so when I asked if you had deleted the old drivers from webroot\drivers...that’s the directory I was referring to.

Maybe I should say Drupalroot though since Drupal could be Running in a subdirectory.

beakerboy’s picture

Feel free to post on the #sql-server slack channel as well.

ST.TWG.TEST’s picture

Beakerboy,

removing the entire drivers folder at webroot crashes the whole site (HTTP 500 Internal Server Error). Please advise.

webroot/modules/sqlsrv/src/Driver/Database/sqlsrv is the path to the Connection.php . Is that correct?

beakerboy’s picture

Why is it crashing? What is the full error? Is something still trying to open the old driver files? Do you have any custom modules that refer to database driver classes?

ST.TWG.TEST’s picture

Once the entire Drupalroot/drivers folder is removed from the Drupalroot folder, the entire system (all pages) go into HTTP 500 Internal Server Error. It seems that with Drivers folder removed, the system no longer even recognizes the location of php. I dont get the display_errors i turned on in the php.

Any ideas?

beakerboy’s picture

Normally a webserver will have a more detailed error message somewhere on why it’s giving the 500 error.

beakerboy’s picture

Maybe you could try upgrading more incrementally. You Could you try staying at drupal 8.9 and just first upgrade the Drupal driver to 3.1 (or 3.0) then bump up to Drupal 9 with the 4.0 driver?

ST.TWG.TEST’s picture

I thought I had successfully updated to Drupal 9.0.2, but without the status report i cannot confirm. Will there be any possible issues if I downgrade? (drupal core copying in progress now)

beakerboy’s picture

I assumed you could restore to a backup from before the upgrade. I hope you are not testing on a live site. I don’t think Drupal is able to be downgraded. Update scripts often make database changes, and there is no script to undo them.

Something, somewhere is trying to include the old Connection when it shouldn’t. Are you using composer? Does the autoloader need to rescan, or does your composer.json have any reference to the old drivers?

ST.TWG.TEST’s picture

Ok, so I think I may have located the issue:
In my DrupalwebRoot I have a folder "src" which has been kept and not replaced in any way while updating and/or upgrading.
folders Indexes and Tests reside here.
Inside Indexes there are 2 php files Index and IndexManager.

Index.php shows:
namespace Drupal\sqlsrv\Indexes;

IndexManager.php shows:
namespace Drupal\sqlsrv\Indexes;
use Drupal\Driver\Database\sqlsrv\Connection;

Is this what needs to be changed to C:\inetpub\wwwroot\drupal\drupal-8.7.8\modules\contrib\sqlsrv\src\Driver\Database\sqlsrv
as you have stated before?

beakerboy’s picture

Those files are not needed by the new driver. Everything it needs is in the module directory and must stay where it is.

ST.TWG.TEST’s picture

the src folder has been removed with no change.

I have located 2 remaining locations (so far) where I find the Drupal\Driver\Database\sqlsrv naming:

Connection.php located DrupalWebRoot\drivers\lib\Drupal\Driver\Database\sqlsrv
namespace Drupal\Driver\Database\sqlsrv;

and

Settings.php located DrupalWebRoot\sites\default

$databases['default']['default'] = array (

'database' => 'drupal8',

'username' => '****',

'password' => '***************',

'prefix' => '',

'host' => 'localhost',

'port' => '1433',

'namespace' => 'Drupal\\Driver\\Database\\sqlsrv',

'driver' => 'sqlsrv',

);

$config_directories['sync'] = 'sites/default/files/config_eqD71SD-gwahc4lCBfZII3savdr3InzdOtQFjd4N_IH6P_CHSgvlHIg7-JzB13fbFFG5tyja9Q/sync';

$settings ['config_sync_directory'] = "C:/drupal_sync";

Removing the drivers folder results in a HTTP 500 error on all pages. Should I change the namespace in settings.php then remove the drivers folder and then use IIS to restart everything?

beakerboy’s picture

In comment #6 I specifically asked about the namespace in your settings.php. Remove that line. The driver namespace is detected automatically now. delete the src folder and remove the drivers directory.

beakerboy’s picture

Let me know if you are still having problems. It sounds like I need to add more details to the installation instructions.

ST.TWG.TEST’s picture

I am in the process of going through every file contained in the folders that were not replaced during the upgrade to 9.0.2: ~, modules, profiles, sites, and themes looking for the naming you previously stated. I have removed drivers and src.

beakerboy’s picture

...and you removed the namespace from the settings.php, right? Have you looked at the server log to find the actual error that is causing the 500 failure? This will save you from searching through files.

ST.TWG.TEST’s picture

Beakerboy,

removing all the custom database settings:

$databases['default']['default'] = array (
'database' => 'drupal8',
'username' => '****',
'password' => '***************',
'prefix' => '',
'host' => 'localhost',
'port' => '1433',
'namespace' => 'Drupal\\Driver\\Database\\sqlsrv',
'driver' => 'sqlsrv',
);

resulted in the Drupal beginning Installation screen as if I was building a brand new instance from scratch.

At this point with only Configuration and Status Report pages non-viewable, would performing a full manual upgrade of the system be my only option (redoing 9.0.2. ?)

beakerboy’s picture

Again...have you tried just removing the ONE LINE with the namespace from settings.php...not the whole file, not the entire array...just the one line from the file.

Make that section of the file:


$databases['default']['default'] = [
    'database' => 'drupal8',
    'username' => '****',
    'password' => '***************',
    'prefix' => '',
    'host' => 'localhost',
    'port' => '1433',
    'driver' => 'sqlsrv',
];

Make sure you do not actually type in asterisks. Use your actual database username and password. Have you ever used slack? I have a #sql-server channel set up on the Drupal slack. We can have an actual back and forth discussion in real time if that helps. I must not be explaining myself very well.

beakerboy’s picture

Status: Active » Closed (outdated)