I am using SSL certificate authentication to log into Mediawiki. One of the users would get an error when he used his valid certificate. The error:
Caught exception: A database error has occurred Query:
INSERT INTO `user`
(user_id,user_name,user_password,user_newpassword,user_newpass_time,user_email,user_email_authenticated,user_real_name,user_options,user_token,user_registration,user_editcount)
VALUES
(NULL,'john.smith','','','20090310212536','',NULL,'','quickbar=1\nunderline=2\ncols=80\nrows=25\nsearchlimit=20\ncontextlines=5\ncontextchars=50\ndisablesuggest=0\nskin=\nmath=1\nusenewrc=0\nrcdays=7\nrclimit=50\nwllimit=250\nhideminor=0\nhighlightbroken=1\nstubthreshold=0\npreviewontop=1\npreviewonfirst=0\neditsection=1\neditsectiononrightclick=0\neditondblclick=0\neditwidth=0\nshowtoc=1\nshowtoolbar=1\nminordefault=0\ndate=default\nimagesize=2\nthumbsize=2\nrememberpassword=0\nnocache=0\ndiffonly=0\nshowhiddencats=0\nnorollbackdiff=0\nenotifwatchlistpages=0\nenotifusertalkpages=1\nenotifminoredits=0\nenotifrevealaddr=0\nshownumberswatching=1\nfancysig=0\nexternaleditor=0\nexternaldiff=0\nforceeditsummary=0\nshowjumplinks=1\njustify=0\nnumberheadings=0\nuselivepreview=0\nwatchlistdays=3\nextendwatchlist=0\nwatchlisthideminor=0\nwatchlisthidebots=0\nwatchlisthideown=0\nwatchlisthideanons=0\nwatchlisthideliu=0\nwatchcreations=0\nwatchdefault=0\nwatchmoves=0\nwatchdeletion=0\nnoconvertlink=0\nvariant=en\nlanguage=en\nsearchNs0=1','8f168c4d8ed2afa12c3b223d001e1cd7','20090310212536','0')
Function: User::addToDatabase Error: 1062 Duplicate entry
'john.smith' for key 2 (localhost)
Mediawiki is set up to create a user using the information in the certificate if the user does not exist. It turns out that if the field from the certificate used to create the username starts with a lowercase letter, then Mediawiki will think the user does not exist, but MySQL complains that the user already exists. Mediawiki is looking for a username that starts with a capital letter. The issue was solved by issuing another certificate to the user with the first letter of the username capitalized.