Last modified: 2012-08-14 18:46:38 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T40406, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 38406 - update.php fails with SQL error because database name is not properly quoted.
update.php fails with SQL error because database name is not properly quoted.
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
Database (Other open bugs)
1.19
All All
: Unprioritized normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-07-14 20:43 UTC by Van de Bugger
Modified: 2012-08-14 18:46 UTC (History)
3 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Van de Bugger 2012-07-14 20:43:55 UTC
I am upgrading MediaWiki from 1.18.4 to 1.19.1, and running maintenance/update.php script. It fails with error:

> A database query syntax error has occurred.
> The last attempted database query was:
> "SHOW INDEX FROM opencaching-su.`shar_user`"
> from within function "UserDupes::hasUniqueIndex".
> Database returned error "1064: You have an error in your SQL syntax; check the > manual that corresponds to your MySQL server version for the right syntax to
> use near '-su.`shar_user`' at line 1 (localhost)"

"opencaching-su" is the name of my database; "shar_" is the table prefix for shared tables.

I guess the problem is in not properly quoted database name (it contains dash). I looks the bug is in file Database.php, line ~1975, function tableName:

> if ( isset( $database ) ) {
>     $database = ( $format == 'quoted' || $this->isQuotedIdentifier( $database ) ? $database : $this->addIdentifierQuotes( $database ) );
> }

I am not sure about PHP priorities of || and ? operators, but I have added "echo" statement and saw that $database is set and remains unchanged after this piece of code. Then I fixed it to:

> if ( isset( $database ) ) {
>     if ( $format == 'quoted' ) {
>         $database = ( $this->isQuotedIdentifier( $database ) ? $database : $this->addIdentifierQuotes( $database ) );
>     }
> }

This variant works well to me.
Comment 1 Alexandre Emsenhuber [IAlex] 2012-07-18 08:24:26 UTC
Fix pending review in Gerrit change #15867.
Comment 2 Alexandre Emsenhuber [IAlex] 2012-08-14 18:46:38 UTC
Now merged.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links