Closed (fixed)
Project:
Drupal driver for SQL Server and SQL Azure
Version:
4.3.x-dev
Component:
Schema handling
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
17 Jun 2022 at 19:31 UTC
Updated:
5 Jun 2023 at 10:39 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
freelockI got a similar error after upgrading to Drupal 9.4. We don't use SQL Server for the primary Drupal database -- we use it as a data source for an ongoing migration, so we end up with a long backtrace, starting with:
Error: Call to a member function fetchField() on null in modules/contrib/sqlsrv/src/Driver/Database/sqlsrv/Schema.php on line 765 #0 modules/contrib/sqlsrv/src/Driver/Database/sqlsrv/Connection.php(790): Drupal\sqlsrv\Driver\Database\sqlsrv\Schema->getDefaultSchema()
Error: Call to a member function fetchField() on null in Drupal\sqlsrv\Driver\Database\sqlsrv\Schema->getDefaultSchema() (line 765 of /var/www/html/downtoearthdistributors.com/modules/contrib/sqlsrv/src/Driver/Database/sqlsrv/Schema.php)
I'm guessing the internal database API changed...
Comment #3
freelockI just tracked this down to a change record that did more than deprecate functionality -- it removed a default 'return' option - #3185520: Introduced a Connection::lastInsertId method, deprecating the 'return' query option and the Database::RETURN_* constants.
The specific change is in core/lib/Drupal/Core/Database/Connection.php . In 9.3.x, this function returned an option 'return' => Database::RETURN_STATEMENT. In 9.4.x, this option was removed from default options.
Comment #4
freelockThe core Connection Class query method has been changed between 9.3 to 9.4 to make the return option optional. I applied the same change to the \Drupal\sqlsrv\Driver\Database\sqlsrv\Connection class, to the query() and queryDirect() methods, which appears to fix this issue, and should be backward compatible.
Comment #5
ARRC-Drupal-Chick commentedI just noticed that I listed my "Drupal driver for SQL Server and SQL Azure" version as 4.1.3 and it should be 4.3.1. (Lysdexia strikes again.)
@freelock, thank you. It is always good to find out that I am not the only one to experience an issue.
Can I safely assume that your patch works with 4.3.1? I'm willing to try and see if it fixes my issue.
Comment #6
ARRC-Drupal-Chick commentedI attempted to apply the patch using composer (both from this site and locally downloaded) and it timed out.
So, I manually changed the two lines and Drupal 9.4.0 is now happy.
I copied the updated file to a 9.3.16 site and it worked just fine.
@freelock, thank you very much.
Comment #7
ARRC-Drupal-Chick commentedComment #8
solideogloria commentedI applied #4 successfully with Composer on Drupal 9.4.1. This fixed my issue.
I had been unable to select from a database using code like this:
Comment #9
IngJheyner commentedI confirm, patch #4 worked for me.
On the other hand, I have a site with drupal 9 and sqlserver, but I have had performance problems and I saw that it was solved with wincache but this module has not worked again, I appreciate if you give me some documentation where I can improve this, thanks
Comment #10
Dudelinos commentedI had the same error and #4 fixed it for me also. Thanks
Comment #11
ysamoylenko commented#4 fixes the problem on Drupal core 9.4.2.
Comment #12
dmlb2000 commentedFixed errors for me moving to 9.4 from 9.3.
Comment #13
mjmorley commentedFixed error for me after upgrading to drupal 9.4
Comment #14
jumpsuitgreen commented@freelock, thanks for posting. Patch #4 fixed the error for me as well. v9.4
Comment #15
calmforce commentedThis bug makes the module completely useless on Drupal 9.4 - it generates fatal errors upon connection to MSSQL DB. The patch #4 fixes the problem, so why the maintainers do not include it into the released code? The project looks abandoned, it has not been updated in a year and has the fatal error that makes it incompatible with the latest released version of Drupal.
Comment #16
gngn commentedRasising to 'major'
Comment #17
hitesh.koli#4 fixes the problem on Drupal core 9.4.12 . This patch need to go in next release
Comment #18
solideogloria commentedPatch #4 works in Drupal 9.5 as well.
Comment #19
robertoperuzzoPatch #4 works in my Drupal 9.5.7 new installation.
Comment #20
pstewart commentedPatch #4 working for me upgrading to D9.5.7, so another upvote for RTBC here.
Comment #21
pstewart commentedJust noting this issue is a side-effect from 3185269, which removed the default value from the options array. THe patch copies over the relevant change that was made in the parent class, so is good to go.
Comment #23
pstewart commented