Page MenuHomePhabricator

wfGetDB function contains extra character
Closed, InvalidPublic


Author: shaun

After downloading 1.5.2 on 2005-11-17 and when going through upgrade from
previous version, upgrade halted complaining that the wfGetDB function was not
defined. After tracing the problem, found that wfGetDB was defined in
includes/DatabaseFunctions.php on line 50 as

function &wfGetDB( $db = DB_LAST, $groups = array() ) {

(notice the extra '&' before the function name)

After removing this character, upgrade was successful.

Version: 1.5.x
Severity: blocker
OS: Windows XP



Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 8:58 PM
bzimport set Reference to bz4018.
bzimport added a subscriber: Unknown Object (MLST).

avarab wrote:

That function is supposed to return a reference and changing it to not do so
could result in some unexpected behaviour.

What's your setup like?

shaun wrote:

bsd platform , mysql db host, all mediawiki defaults

The call to the wfGetDB function on line 46 of maintenance/ :

$dbw =& wfGetDB( DB_MASTER );

is where the update halted the first time through.

I'm not as familiar with the symantics of php, but I cannot find any
documentation online describing a function definition requiring knowledge of a
reference return-value in this manner. The reference in the assignment appears
to make sense, but I can't make sense of an ampersand in the definition. Can
you point me at some docs that describe what this does?

Go to and look up 'references'.