Page MenuHomePhabricator

Call to a member function real_escape_string() on a non-object in DatabaseMysqli.php on line 187
Closed, ResolvedPublicPRODUCTION ERROR

Description

[22-Nov-2013 11:38:16] Fatal error: Call to a member function real_escape_string() on a non-object at /usr/local/apache/common-local/php-1.23wmf4/includes/db/DatabaseMysqli.php on line 187
Server: mw1007
URL: http://[unknown-host]
Backtrace:
#0 /usr/local/apache/common-local/php-1.23wmf4/includes/db/DatabaseMysqli.php(187): DatabaseMysqli::mysqlRealEscapeString()
#1 /usr/local/apache/common-local/php-1.23wmf4/includes/db/DatabaseMysqlBase.php(455): DatabaseMysqli->mysqlRealEscapeString(10)
#2 /usr/local/apache/common-local/php-1.23wmf4/includes/db/Database.php(2399): DatabaseMysqlBase->strencode(10)
#3 /usr/local/apache/common-local/php-1.23wmf4/includes/db/Database.php(1999): DatabaseBase->addQuotes(10)
#4 /usr/local/apache/common-local/php-1.23wmf4/includes/db/Database.php(1579): DatabaseBase->makeList(Array, 1)
#5 /usr/local/apache/common-local/php-1.23wmf4/includes/db/Database.php(1527): DatabaseBase->selectSQLText(Array, Array, Array, 'BacklinkCache::...', Array, Array)
#6 /usr/local/apache/common-local/php-1.23wmf4/includes/cache/BacklinkCache.php(221): DatabaseBase->select(Array, Array, Array, 'BacklinkCache::...', Array)
#7 /usr/local/apache/common-local/php-1.23wmf4/includes/cache/BacklinkCache.php(164): BacklinkCache->queryLinks('templatelinks', 397042, 400281, INF)
#8 /usr/local/apache/common-local/php-1.23wmf4/extensions/Parsoid/php/ParsoidCacheUpdateJob.php(100): BacklinkCache->getLinks('templatelinks', 397042, 400281)
#9 /usr/local/apache/common-local/php-1.23wmf4/extensions/Parsoid/php/ParsoidCacheUpdateJob.php(49): ParsoidCacheUpdateJob->doPartialUpdate()
#10 /usr/local/apache/common-local/php-1.23wmf4/maintenance/runJobs.php(101): ParsoidCacheUpdateJob->run()
#11 /usr/local/apache/common-local/php-1.23wmf4/maintenance/doMaintenance.php(113): RunJobs->execute()
#12 /usr/local/apache/common-local/php-1.23wmf4/maintenance/runJobs.php(181): require_once('/usr/local/apac...')
#13 /usr/local/apache/common-local/multiversion/MWScript.php(97): require_once('/usr/local/apac...')
#14 {main}

Version: unspecified
Severity: normal

Details

Reference
bz57463

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 2:38 AM
bzimport set Reference to bz57463.
bzimport added a subscriber: Unknown Object (MLST).

Reedy: Has been once in the logs, or more often? Is there any such output also for wmf5 instances yet?

It happens on all versions, easily reproducible.

Taking this since it's 99% likely to be my fault.

(In reply to comment #2 by Chad)

It happens on all versions, easily reproducible.
Taking this since it's 99% likely to be my fault.

Chad: Any news?

  • Bug 61516 has been marked as a duplicate of this bug. ***

This still happens regularly:
2015-07-26 13:46:26 mw1 metawiki: [34b059ed] /wiki/Special:CreateWiki BadMethodCallException from line 293 of /srv/mediawiki/w/includes/db/DatabaseMysqli.php: Call to a member function real_escape_string() on a non-object (boolean)
#0 /srv/mediawiki/w/includes/db/DatabaseMysqlBase.php(544): DatabaseMysqli->mysqlRealEscapeString()
#1 /srv/mediawiki/w/includes/db/Database.php(2692): DatabaseMysqlBase->strencode()
#2 /srv/mediawiki/w/includes/db/Database.php(2238): DatabaseBase->addQuotes()
#3 /srv/mediawiki/w/includes/db/Database.php(1776): DatabaseBase->makeList()
#4 /srv/mediawiki/w/includes/db/Database.php(1724): DatabaseBase->selectSQLText()
#5 /srv/mediawiki/w/includes/db/Database.php(1815): DatabaseBase->select()
#6 /srv/mediawiki/w/includes/cache/LocalisationCache.php(1159): DatabaseBase->selectRow()
#7 /srv/mediawiki/w/includes/cache/LocalisationCache.php(382): LCStoreDB->get()
#8 /srv/mediawiki/w/includes/cache/LocalisationCache.php(281): LocalisationCache->loadSubitem()
#9 /srv/mediawiki/w/languages/Language.php(2548): LocalisationCache->getSubitem()
#10 /srv/mediawiki/w/includes/cache/MessageCache.php(811): Language->getMessage()
#11 /srv/mediawiki/w/includes/cache/MessageCache.php(738): MessageCache->getMessageFromFallbackChain()
#12 /srv/mediawiki/w/includes/Message.php(1075): MessageCache->get()
#13 /srv/mediawiki/w/includes/Message.php(698): Message->fetchMessage()
#14 /srv/mediawiki/w/includes/Message.php(801): Message->toString()
#15 /srv/mediawiki/w/extensions/CreateWiki/SpecialCreateWiki.php(185): Message->plain()
#16 /srv/mediawiki/w/includes/htmlform/HTMLForm.php(546): SpecialCreateWiki::processInput()
#17 /srv/mediawiki/w/includes/htmlform/HTMLForm.php(469): HTMLForm->trySubmit()
#18 /srv/mediawiki/w/includes/htmlform/HTMLForm.php(484): HTMLForm->tryAuthorizedSubmit()
#19 /srv/mediawiki/w/extensions/CreateWiki/SpecialCreateWiki.php(80): HTMLForm->show()
#20 /srv/mediawiki/w/includes/specialpage/SpecialPage.php(384): SpecialCreateWiki->execute()
#21 /srv/mediawiki/w/includes/specialpage/SpecialPageFactory.php(582): SpecialPage->run()
#22 /srv/mediawiki/w/includes/MediaWiki.php(267): SpecialPageFactory::executePath()
#23 /srv/mediawiki/w/includes/MediaWiki.php(566): MediaWiki->performRequest()
#24 /srv/mediawiki/w/includes/MediaWiki.php(414): MediaWiki->main()
#25 /srv/mediawiki/w/index.php(41): MediaWiki->run()
#26 {main}

Start request POST /wiki/Special:CreateWiki
HTTP HEADERS:
CONTENT-LENGTH: 187
CONNECTION: keep-alive
HOST: meta.miraheze.org
CONTENT-TYPE: application/x-www-form-urlencoded
ACCEPT-LANGUAGE: nl,en-US;q=0.7,en;q=0.3
COOKIE: REDACTED
ACCEPT: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
DNT: 1
REFERER: https://meta.miraheze.org/wiki/Special:CreateWiki
ACCEPT-ENCODING: gzip, deflate
USER-AGENT: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:39.0) Gecko/20100101 Firefox/39.0
Creating a new RedisConnectionPool instance with id REDACTED.
[caches] main: RedisBagOStuff, message: RedisBagOStuff, parser: RedisBagOStuff
[caches] LocalisationCache: using store LCStoreDB
Fully initialised
Connected to database 0 at 185.52.1.77
[warning] Did not find alias for special page 'CreateWiki'. Perhaps no aliases are defined for it? [Called from SpecialPageFactory::getLocalNameFor in /srv/mediawiki/w/includes/specialpage/SpecialPageFactory.php at line 674]
[warning] Did not find alias for special page 'CreateWiki'. Perhaps no aliases are defined for it? [Called from SpecialPageFactory::getLocalNameFor in /srv/mediawiki/w/includes/specialpage/SpecialPageFactory.php at line 674]
[CentralAuthVerbose] Loading CentralAuthUser for user Southparkfan from cache object
User: got user 1 from cache
CentralAuthHooks::onUserLoadFromSession: logged in from session
CentralAuthHooks::initSession: Session already initialised for Southparkfan with token [REDACTED].
User: loading options for user 1 from override cache.
[MessageCache] MessageCache::load: Loading en... got from global cache
Unstubbing $wgParser on call of $wgParser::firstCallInit from MessageCache::transform
Parser: using preprocessor: Preprocessor_Hash
Unstubbing $wgLang on call of $wgLang::_unstub from ParserOptions::__construct
ContextSource::getContext (HTMLForm): called and $context is null. Using RequestContext::getMain() for sanity
[warning] Did not find alias for special page 'CreateWiki'. Perhaps no aliases are defined for it? [Called from SpecialPageFactory::getLocalNameFor in /srv/mediawiki/w/includes/specialpage/SpecialPageFactory.php at line 674]
User: got user 1 from cache
[CreateWiki] Creating wiki southparkfanwiki (sitename: SouthparkfanWiki - language: nl - private: yes) with a founder of Southparkfan
DatabaseBase::query: Writes done: INSERT INTO logging (log_id,log_type,log_action,log_timestamp,log_user,log_user_text,log_namespace,log_title,log_page,log_comment,log_params)
VALUES (NULL,'X')
IP: REDACTED
User: got user 1 from cache
wfShellExec: /bin/bash '/srv/mediawiki/w/includes/limit.sh' 'php5 /srv/mediawiki/w/extensions/CentralAuth/maintenance/createLocalAccount.php '\''Southparkfan'\'' --wiki '\''southparkfanwiki'\''' 'MW_INCLUDE_STDERR=;MW_CPU_LIMIT=180; MW_CGROUP='\'''\''; MW_MEM_LIMIT=307200; MW_FILE_SIZE_LIMIT=102400; MW_WALL_CLOCK_LIMIT=180; MW_USE_LOG_PIPE=yes'
[CreateWiki] Failed to create local account for founder.

Software:
MediaWiki 1.25.1 (4be314b)
HHVM 3.9.0-dev (srv)
MariaDB 10.0.20-MariaDB-0+deb8u1-log
(These errors also occur under HHVM 3.3, HHVM 3.6 and MediaWiki 1.24 (perhaps 1.23 too - not sure about that) too.)

SpecialCreateWiki.php:
P1069

EDIT: I tried this with rMWde808f57a90c9c6f7bc4dbc4e4b544a07e0daa0f, but it still throws the same MWException.

@Reedy: I can replicate it whenever you want, so if I have to provide some extra debug info (bd808 proposed to catch the exception and then var_dump() mConn if I am right) orsomething else that's okay.

Since rMWc63fde6797c2b6ba, this error would instead appear in the log as an DBUnexpectedError exception: "DB connection was already closed or the connection dropped." Though the question remains: In this case, how is mConn becoming a non-object, and why is the DatabaseMysqli object used afterward?

demon raised the priority of this task from Medium to High.Oct 26 2015, 5:27 PM
demon claimed this task.

I'm going to be bold and call this resolved.

  1. Per @PleaseStand, this error would never appear as such anymore.
  2. More generally, this error in and of itself isn't very useful. We've encountered similar things before (cf: T142079/#303969, T67263) and we consider it resolved there

I think we can say the same here. Let's just open a new task if it comes up again.

mmodell changed the subtype of this task from "Task" to "Production Error".Aug 28 2019, 11:12 PM