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;
}
CommentFileSizeAuthor
#2 phpbb_api_listfunction.patch879 bytessrjosh
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

srjosh’s picture

The same goes for phpbb_api_get_user_name($user_id)

list ($username) = $db->sql_fetchrow($result);

Further information from http://us.php.net/list

Note: list() only works on numerical arrays and assumes the numerical indices start at 0.

srjosh’s picture

Status: Active » Needs review
FileSize
879 bytes

Attached is a patch that accomplishes these things.

Toxid’s picture

I've applied the patch and it seems to work.

vorapoap’s picture

Status: Needs review » Reviewed & tested by the community
vorapoap’s picture

Priority: Normal » Major

The code is back again!.. Please patch to 2.x-dev!!!

fizk’s picture

Status: Reviewed & tested by the community » Closed (fixed)