Some users are reporting database errors for one of my extensions,
UserRightsList.
http://www.mediawiki.org/wiki/User_talk:JimHu#Database_Error
The error reported is
1146: Table 'mw_.user' doesn't exist (localhost)
or
1142: SELECT command denied to user 'cdy'(a)'srv83.one.com' for table
'user'
depending on how MySQL privileges are set. The extension works for me
in 1.11. 1, and I'm not sure exactly where the problem is for the
users. I suspect it's because I'm misusing $wgDBprefix, and the
extension is looking for a db that doesn't exist. But since I don't
use it in my wikis, it's hard to test on my local installs. I'm
guessing the problem is somewhere in the method below (which should
probably be rewritten anyway to use more MW style db access code).
function findMyUsers(){
global $wgUser, $wgDBprefix;
$dbr =& wfGetDB( DB_SLAVE );
if(in_array('userrights',$wgUser->getRights())){
$sql = "SELECT u.user_id, u.user_name, u.user_registration FROM
$wgDBprefix.user u WHERE 1";
}else{
$sql = "SELECT u.user_id, u.user_name, u.user_registration FROM
$wgDBprefix.logging l, $wgDBprefix.user u WHERE
l.log_title = u.user_name AND
log_type = 'newusers' AND
log_user = '".$wgUser->getID()."'
";
}
if (isset($this->group) && $this->group !=''){
$sql = str_replace("FROM","FROM $wgDBprefix.user_groups, ", $sql);
$sql .= " AND ug_user = u.user_id AND ug_group =
'".$this->group."'
";
}
if (isset($this->username) && !is_null($this->username) && $this-
username != ''){
$sql .= " AND
u.user_name LIKE'".mysql_real_escape_string($this-
username)."' ";
}
if (isset($this->yearfrom) && !is_null($this->yearfrom) && $this-
yearfrom != ''){
$month =
'00';
if (!is_null($this->monthfrom ) ) $month = $this->monthfrom;
$fromdate = str_pad($this->yearfrom.$month, 14, '0', STR_PAD_RIGHT);
$sql .= " AND STRCMP(u.user_registration,'$fromdate') = 1 ";
}
if (isset($this->yearto) && !is_null($this->yearto) && $this-
yearto != ''){
$year =
$this->yearto;
$month = '99';
if (!is_null($this->monthto ) ) $month = $this->monthto;
$todate = str_pad($year.$month, 14, '9', STR_PAD_RIGHT);
$sql .= " AND STRCMP(u.user_registration,'$todate') = -1 ";
}
$sql .= " ORDER BY u.user_name";
$sql = $dbr->limitResult($sql, $this->limit, $this->offset);
#echo $sql;
$results = $dbr->query($sql);
$this->num = $dbr->numRows($results);
if (!$results) return array();
while( $x = $dbr->fetchObject ( $results ) ) {
$arr[] = get_object_vars($x);
}
return $arr;
}
=====================================
Jim Hu
Associate Professor
Dept. of Biochemistry and Biophysics
2128 TAMU
Texas A&M Univ.
College Station, TX 77843-2128
979-862-4054