Page MenuHomePhabricator

Error during document revision compare
Closed, ResolvedPublic

Description

Product/Version

MediaWiki 1.27.1
PHP 5.6.30 (cgi-fcgi)
MS SQL Server 10.50.6529

During testing of Mediawiki on a SQL Server based MEDIAWIKI installation, I encountered some errors documented below. I know this should not be a surprise, since Mediawiki is not guaranteed to work with SQL Server. I am stuck with SQL Server, and I would really like to use MediaWiki. I am hoping that somebody could look into this and provide some feedback if it is feasible to provide a fix for this.

To recreate this error, open the history of a page, select two revisions and click one of the two buttons labeled "Compare selected revisions" The following is the error screen that is displayed.

A database query error has occurred. This may indicate a bug in the software.
Query:
SELECT COUNT(*) AS rowcount FROM (SELECT TOP 1001 1 FROM [wiki].[revision] WHERE rev_page = '90' AND (rev_timestamp > '20170215184107') AND (rev_timestamp < '20170215185129') ) tmp_count
Function: Title::countRevisionsBetween
Error: 156 [SQLSTATE 42000][Error Code 156][Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Incorrect syntax near the keyword 'rowcount'. [SQLSTATE 42000][Error Code 102][Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Incorrect syntax near 'tmp_count'. [SQLSTATE 42000][Error Code 8180][Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Statement(s) could not be prepared. [SQLSTATE 01000][Error Code 16954][Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Executing SQL directly; no cursor.

Backtrack is as follows:
#0 C:\inetpub\wwwroot\WCR\includes\db\Database.php(901): DatabaseBase->reportQueryError('[SQLSTATE 42000...', 156, 'SELECT COUNT(*)...', 'Title::countRev...', false) #1 C:\inetpub\wwwroot\WCR\includes\db\Database.php(1327): DatabaseBase->query('SELECT COUNT(*)...', 'Title::countRev...') #2 C:\inetpub\wwwroot\WCR\includes\Title.php(4096): DatabaseBase->selectRowCount('revision', '1', Array, 'Title::countRev...', Array) #3 C:\inetpub\wwwroot\WCR\includes\diff\DifferenceEngine.php(1017): Title->countRevisionsBetween(Object(Revision), Object(Revision), 1000) #4 C:\inetpub\wwwroot\WCR\includes\diff\DifferenceEngine.php(687): DifferenceEngine->getMultiNotice() #5 C:\inetpub\wwwroot\WCR\includes\diff\DifferenceEngine.php(652): DifferenceEngine->getDiff('<div id="mw-dif...', '<div id="mw-dif...', '') #6 C:\inetpub\wwwroot\WCR\includes\diff\DifferenceEngine.php(454): DifferenceEngine->showDiff('<div id="mw-dif...', '<div id="mw-dif...', '') #7 C:\inetpub\wwwroot\WCR\includes\page\Article.php(787): DifferenceEngine->showDiffPage(false) #8 C:\inetpub\wwwroot\WCR\includes\page\Article.php(498): Article->showDiffPage() #9 C:\inetpub\wwwroot\WCR\includes\actions\ViewAction.php(44): Article->view() #10 C:\inetpub\wwwroot\WCR\includes\MediaWiki.php(503): ViewAction->show() #11 C:\inetpub\wwwroot\WCR\includes\MediaWiki.php(288): MediaWiki->performAction(Object(Article), Object(Title)) #12 C:\inetpub\wwwroot\WCR\includes\MediaWiki.php(745): MediaWiki->performRequest() #13 C:\inetpub\wwwroot\WCR\includes\MediaWiki.php(519): MediaWiki->main() #14 C:\inetpub\wwwroot\WCR\index.php(43): MediaWiki->run() #15 {main}

Some errors I can see offhand, rowcount is a reserved word in MSSQL.
rev_page is an int and does not need the tick marks around it.
rev_timestamp also does not need the tick marks.
I believe that the syntax of the count command is not correct for MSSQL server.

Event Timeline

The syntax error is around tmp_count
I would say, it needs an "AS tmp_count "

most database engines does not have problem with quoted int. The timestamp needs to be quoted in mysql because it is a character field, not a date or datetime field. There need to be done more work to get it working on mssql

Change 342411 had a related patch set uploaded (by Brian Wolff):
[mediawiki/core] Make selectRowCount() (hopefully) work in MSSQL.

https://gerrit.wikimedia.org/r/342411

Umherirrender assigned this task to Bawolff.
Umherirrender triaged this task as Medium priority.

Change 342411 merged by jenkins-bot:
[mediawiki/core] Make selectRowCount() (hopefully) work in MSSQL.

https://gerrit.wikimedia.org/r/342411

How could this be closed, Resolved , if it has not been tested against MSSQL?

@Jhuff05: You are free to file a new task if there's any followup issues to sort out and if the patch did not fully do what it is supposed to do...

Change 345328 had a related patch set uploaded (by Brian Wolff):
[mediawiki/core@REL1_28] Make selectRowCount() (hopefully) work in MSSQL.

https://gerrit.wikimedia.org/r/345328

Change 345330 had a related patch set uploaded (by Brian Wolff):
[mediawiki/core@REL1_27] Make selectRowCount() (hopefully) work in MSSQL.

https://gerrit.wikimedia.org/r/345330

Change 345328 merged by jenkins-bot:
[mediawiki/core@REL1_28] Make selectRowCount() (hopefully) work in MSSQL.

https://gerrit.wikimedia.org/r/345328

Change 345330 merged by Brian Wolff:
[mediawiki/core@REL1_27] Make selectRowCount() (hopefully) work in MSSQL.

https://gerrit.wikimedia.org/r/345330