Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
See below code on line 235 (comment out)..
It can't be guaranteed that list ($user_id) = $db->sql_fetchrow($result);
always return a valid value.
We need to use
$a = $db->sql_fetchrow($result);
$user_id = $a['user_id'];
Seem to relate to some php configuration or version?
New proposed code...
phpbb_api.php
function phpbb_api_get_user_id($username)
{
phpbb_api_session_begin();
global $phpbb_connection, $db;
$user_id = 0;
if (!empty($username))
{
if (!$phpbb_connection) {
return $user_id;
}
$sql = 'SELECT user_id
FROM ' . USERS_TABLE . "
WHERE username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'";
$result = $db->sql_query($sql);
//LINE 325: list ($user_id) = $db->sql_fetchrow($result);
$a = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
$user_id = $a['user_id'];
}
return $user_id;
}
Comment | File | Size | Author |
---|---|---|---|
#2 | phpbb_api_listfunction.patch | 879 bytes | srjosh |
Comments
Comment #1
srjoshThe same goes for phpbb_api_get_user_name($user_id)
Further information from http://us.php.net/list
Note: list() only works on numerical arrays and assumes the numerical indices start at 0.
Comment #2
srjoshAttached is a patch that accomplishes these things.
Comment #3
Toxid CreditAttribution: Toxid commentedI've applied the patch and it seems to work.
Comment #4
vorapoap CreditAttribution: vorapoap commentedComment #5
vorapoap CreditAttribution: vorapoap commentedThe code is back again!.. Please patch to 2.x-dev!!!
Comment #6
fizk CreditAttribution: fizk commented