Last modified: 2011-08-25 16:59:53 UTC
With version r82697 (http://biowikifarm.net/test/Special:Version ) (as well as with a versions a number of days back, the error is a few days old), the following error occurs: Warning: mysql_real_escape_string() expects parameter 2 to be resource, null given in /usr/share/mediawikistaging/phase3/includes/db/DatabaseMysql.php on line 316 Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /usr/share/mediawikistaging/phase3/includes/db/DatabaseMysql.php on line 23 Database error A database query syntax error has occurred. This may indicate a bug in the software. The last attempted database query was: BEGIN from within function "DatabaseBase::begin". Database returned error "0: ". I have tried to test a possible dependency on additional extensions, but disabling extensions does not help (with the exception of ParserFunctions, which disables much of the template processing, so it is probably unrelated). Disabling SMW does not remove the error. Gregor
It looks to be something with the templates you're using... I can't seem to reproduce it (And I'd rather not have to try and duplicate your whole wiki...) It seems to be on your templates with multiple parser function calls etc...
It occurs only on specific pages - but the templates in question are inherited from en.wikipedia... There is a second page which produces funny results, but this occurs in the context of SMW (the error above occurs with SMW disabled as well). http://biowikifarm.net/test/Special:FormEdit/Artportrait/Bombus Any of the errors point to code lines that have recently been modified? (Version r79596 did not have this error yet).
That could is unlikely to tell us, we really need a call stack And now, the errors seem to be gone on your wiki now...
*On some pages
function strencode( $s ) { try { $sQuoted = mysql_real_escape_string( $s, $this->mConn ); if($sQuoted === false) { $this->ping(); $sQuoted = mysql_real_escape_string( $s, $this->mConn ); } return $sQuoted; } catch (Exception $e) { var_dump($e); var_dump(debug_backtrace()); return $s; } } Replace the existing function with something like that. At least we'll get some idea of where it's failing
Apologies for removing the error temporarily, I was trying to pinpoint which templates may cause it, to simplify the solution. Failed however. Error is back. Function is replaced as requested above. wgShowDebug is true now. Please remind me how I get the call stack. I did it months ago, but can't remember. Link to instructions?
If you go to includes/db/DatabaseMySql.php, and replace the strencode function with the one pasted above, that should give some insight
I did replace the function as mentioned above. I see not change. Sorry, I am not very experienced with debugging. Settings are: $wgShowSQLErrors = true; $wgShowDebug = true;// if true debug data shown on the wiki page at the bottom $wgShowExceptionDetails = true; error_reporting(E_ALL); ini_set("display_errors", 1); $wgDebugLogFile = "$IP/debug.log";
(In reply to comment #5) > [snip] > Replace the existing function with something like that. At least we'll get some > idea of where it's failing Why would a try/catch block catch an E_WARNING?
I have this same issue. I was using mediawiki 1.16.2 and I have upgraded it to 1.17.0, having upgraded the sql schemas. Everything seems to work fine except my user wikipage that shows these errors.
Just upgraded from 1.16 to 1.17 and I'm getting the same error when I set $wgUseSharedUploads = true; (I'm running four interwikis sharing one pool wiki for the media files). Would be nice though, if my wikis had images again :| Here is the output: Warning: mysql_real_escape_string() expects parameter 2 to be resource, null given in /html/wiki/en/w/includes/db/DatabaseMysql.php on line 318 Warning: mysql_real_escape_string() expects parameter 2 to be resource, null given in /html/wiki/en/w/includes/db/DatabaseMysql.php on line 318 Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /html/wiki/en/w/includes/db/DatabaseMysql.php on line 23 A database query syntax error has occurred. This may indicate a bug in the software. The last attempted database query was: BEGIN from within function "DatabaseBase::begin". Database returned error "0: ". Debug data: Start request GET /wiki/Main_Page HTTP HEADERS: Accept: text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/webp, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1 Accept-Encoding: gzip, deflate Accept-Language: en,de;q=0.9,de-DE;q=0.8 Cache-Control: no-cache Connection: Keep-Alive Cookie: database_3UserID=1; database_3UserName=Till+Kraemer; database_3Token=1d8916427743c36ef3936c5f20a8c9e3; awc_startTime=20110814185359; database_3_session=2bauhg71ti53lp57pfhqage6q2; __utma=162725736.456536178.1297683604.1313346115.1313410956.169; __utmb=162725736.37.10.1313410956; __utmc=162725736; __utmz=162725736.1313410956.169.53.utmcsr=pool.domain.com|utmccn=(referral)|utmcmd=referral|utmcct=/wiki/Main_Page Host: en.domain.com Referer: http://en.domain.com/wiki/Till_Kraemer User-Agent: Opera/9.80 (Windows NT 6.1; U; en) Presto/2.9.168 Version/11.50 CACHES: APCBagOStuff[main] APCBagOStuff[message] FakeMemCachedClient[parser] Unstubbing $wgParser on call of $wgParser::setFunctionHook from SimpleSecurity::__construct Unstubbing $wgOut on call of $wgOut::_unstub from wfDebug Unstubbing $wgContLang on call of $wgContLang::getMagic from MagicWord::load LocalisationCache: using store LCStore_DB Unstubbing $wgMessageCache on call of $wgMessageCache::get from wfMsgGetKey Unstubbing $wgLang on call of $wgLang::getCode from MessageCache::get User: got user 1 from cache Connecting to 111.222.333.444 database_3... Connected to 111.222.333.444 database_3. User: loading options for user 1 from override cache. User: logged in from session User: loading options for user 1 from override cache. MessageCache::load: Loading en... got from global cache Use of MessageCache::addMessages is deprecated. [Called from call_user_func_array in (internal function)] Use of MessageCache::addMessage is deprecated. [Called from setupSEOParserHooks in /html/wiki/en/w/extensions/Add_HTML_Meta_and_Title.php at line 57] Fully initialised Title::getRestrictionTypes: applicable restriction types for Main Page are edit,move,readOutputPage::checkLastModified: CACHE DISABLED User::isBlockedFrom: enter User::isBlockedFrom: asking isBlocked() User::isBlocked: enter User::getBlockedStatus: checking... IP: 555.666.777.888 Block::load: '', '1', 1 Article::view using parser cache: no Class SkinMonobook not found; skipped loading Article::view: doing uncached parse User::isBlockedFrom: enter User::isBlockedFrom: asking isBlocked() User::isBlocked: enter User::getBlockedStatus: already loaded. SiteStats::loadAndLazyInit: reading site_stats from slave SQL ERROR: User::isBlockedFrom: enter User::isBlockedFrom: asking isBlocked() User::isBlocked: enter User::getBlockedStatus: already loaded. Title::getRestrictionTypes: applicable restriction types for Main Page are edit,move,read Any pointers are more thank appreciated! Thanks + cheers, Till
P.S.: Can I just downgrade to 1.16? Or do I have to change the databases somehow?
Closing the bug. Whatever precisely caused it, has disappeared from code in REL1_18 as well as trunk. The error no longer occurs there.