https://bugzilla.wikimedia.org/show_bug.cgi?id=38406

       Web browser: ---
             Bug #: 38406
           Summary: update.php fails with SQL error because database name
                    is not properly quoted.
           Product: MediaWiki
           Version: 1.19
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: Unprioritized
         Component: Database
        AssignedTo: wikibugs-l@lists.wikimedia.org
        ReportedBy: van.de.bug...@gmail.com
    Classification: Unclassified
   Mobile Platform: ---


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.

-- 
Configure bugmail: https://bugzilla.wikimedia.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
You are on the CC list for the bug.

_______________________________________________
Wikibugs-l mailing list
Wikibugs-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to