Maybe someone can help. I have updated the sqlsrv module from the 8.2 branch to 3.1.1 and now I'm getting the following fatal error on some pages (not all):

Fatal error: Cannot declare class Drupal\sqlsrv\Driver\Database\sqlsrv\Utils, because the name is already in use in C:\inetpub\wwwroot\mysite\web\drivers\lib\Drupal\Driver\Database\sqlsrv\Utils.php on line 10

It seems that a namespace might need to be updated, but I don't know where to fix it.

Is there a step I missed during the update?

My installation:
Windows Server 2016
IIS 10
PHP 7.3.19
Drupal 8.9

Thanks!

Comments

Dudelinos created an issue. See original summary.

beakerboy’s picture

Make sure you have deleted the drivers directory from your webroot. As of Drupal 8.9, there is no need to manually copy the drivers directory from the module to webroot.

Please let me know if this is the issue.

Dudelinos’s picture

Thanks for the quick reply Beakerboy. The drivers folder was still there, so I deleted it. That seems to have fixed the error above. I also removed the post script in the composer.json file that was copying the files to the drivers folder. I also removed the PHPmssql component that was installed for the 8.2 version. I also ran "composer update" and rebuilt the cache. But I still get the crashed pages. The log shows the following error after I open a crashed page (error 500):

Warning: require(C:\inetpub\wwwroot\mysite\vendor\composer/../../web/drivers/lib/Drupal/Driver\Database\sqlsrv\Utils.php): failed to open stream: No such file or directory in require() (line 111 of C:\inetpub\wwwroot\mysite\vendor\symfony\class-loader\WinCacheClassLoader.php)

It does this on only some particular pages though, like the status page or configuration page.

EDIT:
The error above was in the drupal error log. The one below is the fatal error:

Fatal error: require(): Failed opening required 'C:\inetpub\wwwroot\mysite\vendor\composer/../../web/drivers/lib/Drupal/Driver\Database\sqlsrv\Utils.php' (include_path='C:\inetpub\wwwroot\mysite\vendor/pear/archive_tar;C:\inetpub\wwwroot\mysite\vendor/pear/console_getopt;C:\inetpub\wwwroot\mysite\vendor/pear/pear-core-minimal/src;C:\inetpub\wwwroot\mysite\vendor/pear/pear_exception;.;C:\php\pear') in C:\inetpub\wwwroot\mysite\vendor\symfony\class-loader\WinCacheClassLoader.php on line 111

beakerboy’s picture

If the Wincache Class Loader is causing the problem, what happens if you uninstall the Wincache module, or disable Wincache on the server?

beakerboy’s picture

Another possibility is the “autoload” section of the module’s composer.json. The newer versions still had an autoload directive for the classes in webroot/drivers. I just removed that and pushed the changes to the git repo. You can try the dev branch. I can make a new release as well if you would like to try that.

Dudelinos’s picture

I updated to the dev branch and now instead of a 500 server error, I get the standard Drupal error (The website encountered an unexpected error. Please try again later.), which means we made progress. The Drupal report log shows the following error:

Error: Class 'Drupal\Driver\Database\sqlsrv\Utils' not found in sqlsrv_requirements() (line 140 of C:\inetpub\wwwroot\bookstore\web\modules\contrib\sqlsrv\sqlsrv.install)

Does that gives you a hint on what's wrong?

Edit:
Forgot to mention that I also tried to disable the Wincache extension, which resulted in the "The website encountered an unexpected error. Please try again later." on all pages. So I reenabled it.

beakerboy’s picture

This is odd. The sqlsrv.install file in the drupalcode.org repository does not match the version that is in the GitHub repository, which is where I do my active development. I have no idea why there is a difference. I’ll let you know when this is updated. I’ll have to make a release for this since it’s a pretty big bug.

  • Beakerboy committed 10f5c6d on 3.1.x
    Issue #3159832 by Beakerboy: Fatal error after upgrading to sqlsrv 3.1.1
    
beakerboy’s picture

Go ahead and try the new 3.1.2 release. Sorry for the headaches!

Dudelinos’s picture

The 3.1.2 release solved it. Thanks a million Beakerboy :)

Dudelinos’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.