remove php4-style object reference passing

This commit is contained in:
Christian Weiske 2013-03-17 22:22:16 +01:00
parent defe7c0035
commit d0ed9adec8
13 changed files with 81 additions and 68 deletions

View file

@ -90,7 +90,7 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
. ' "' . $this->db->sql_escape($value) .'"' . ' "' . $this->db->sql_escape($value) .'"'
. $range; . $range;
if (!($dbresult = & $this->db->sql_query_limit($query, 1, 0))) { if (!($dbresult = $this->db->sql_query_limit($query, 1, 0))) {
message_die( message_die(
GENERAL_ERROR, GENERAL_ERROR,
'Could not get bookmark', '', __LINE__, __FILE__, 'Could not get bookmark', '', __LINE__, __FILE__,
@ -148,7 +148,7 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
. $query_2 . $query_2
.' WHERE B.bId = '. $this->db->sql_escape($bid); .' WHERE B.bId = '. $this->db->sql_escape($bid);
if (!($dbresult = & $this->db->sql_query($sql))) { if (!($dbresult = $this->db->sql_query($sql))) {
message_die( message_die(
GENERAL_ERROR, 'Could not get bookmark', GENERAL_ERROR, 'Could not get bookmark',
'', __LINE__, __FILE__, $sql, $this->db '', __LINE__, __FILE__, $sql, $this->db
@ -630,7 +630,7 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
. ' WHERE bId = ' . intval($bId); . ' WHERE bId = ' . intval($bId);
$this->db->sql_transaction('begin'); $this->db->sql_transaction('begin');
if (!($dbresult = & $this->db->sql_query($sql))) { if (!($dbresult = $this->db->sql_query($sql))) {
$this->db->sql_transaction('rollback'); $this->db->sql_transaction('rollback');
message_die( message_die(
GENERAL_ERROR, 'Could not update bookmark', GENERAL_ERROR, 'Could not update bookmark',

View file

@ -200,7 +200,7 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_DbService
$sql = 'INSERT INTO '. $this->getTableName() $sql = 'INSERT INTO '. $this->getTableName()
. ' ' . $this->db->sql_build_array('INSERT', $values); . ' ' . $this->db->sql_build_array('INSERT', $values);
if (!($dbresult =& $this->db->sql_query($sql))) { if (!($dbresult = $this->db->sql_query($sql))) {
$this->db->sql_transaction('rollback'); $this->db->sql_transaction('rollback');
message_die( message_die(
GENERAL_ERROR, 'Could not attach tags', GENERAL_ERROR, 'Could not attach tags',
@ -222,7 +222,7 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_DbService
$query.= ' AND '. $bs->getTableName() .'.uId = '. $uId; $query.= ' AND '. $bs->getTableName() .'.uId = '. $uId;
$query.= ' AND '. $this->getTableName() .'.tag = "'. $this->db->sql_escape($tag) .'"'; $query.= ' AND '. $this->getTableName() .'.tag = "'. $this->db->sql_escape($tag) .'"';
if (!($dbresult =& $this->db->sql_query($query))) { if (!($dbresult = $this->db->sql_query($query))) {
message_die(GENERAL_ERROR, 'Could not delete tags', '', __LINE__, __FILE__, $query, $this->db); message_die(GENERAL_ERROR, 'Could not delete tags', '', __LINE__, __FILE__, $query, $this->db);
return false; return false;
} }
@ -238,7 +238,7 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_DbService
$query = 'DELETE FROM '. $this->getTableName() .' WHERE bId = '. intval($bookmarkid); $query = 'DELETE FROM '. $this->getTableName() .' WHERE bId = '. intval($bookmarkid);
if (!($dbresult =& $this->db->sql_query($query))) { if (!($dbresult = $this->db->sql_query($query))) {
message_die(GENERAL_ERROR, 'Could not delete tags', '', __LINE__, __FILE__, $query, $this->db); message_die(GENERAL_ERROR, 'Could not delete tags', '', __LINE__, __FILE__, $query, $this->db);
return false; return false;
} }
@ -258,7 +258,7 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_DbService
$GLOBALS['tableprefix'].'bookmarks', $GLOBALS['tableprefix'].'bookmarks',
$uId); $uId);
if (!($dbresult =& $this->db->sql_query($query))) { if (!($dbresult = $this->db->sql_query($query))) {
message_die(GENERAL_ERROR, 'Could not delete tags', '', __LINE__, __FILE__, $query, $this->db); message_die(GENERAL_ERROR, 'Could not delete tags', '', __LINE__, __FILE__, $query, $this->db);
return false; return false;
} }
@ -370,7 +370,7 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_DbService
$query .= ' WHERE '. $this->db->sql_build_array('SELECT', $conditions) .' AND LEFT(T.tag, 7) <> "system:" GROUP BY T.tag ORDER BY bCount DESC, tag'; $query .= ' WHERE '. $this->db->sql_build_array('SELECT', $conditions) .' AND LEFT(T.tag, 7) <> "system:" GROUP BY T.tag ORDER BY bCount DESC, tag';
if (!($dbresult =& $this->db->sql_query($query))) { if (!($dbresult = $this->db->sql_query($query))) {
message_die(GENERAL_ERROR, 'Could not get tags', '', __LINE__, __FILE__, $query, $this->db); message_die(GENERAL_ERROR, 'Could not get tags', '', __LINE__, __FILE__, $query, $this->db);
return false; return false;
} }
@ -418,7 +418,7 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_DbService
$query_5 = ' AND LEFT(T0.tag, 7) <> "system:" GROUP BY T0.tag ORDER BY bCount DESC, T0.tag'; $query_5 = ' AND LEFT(T0.tag, 7) <> "system:" GROUP BY T0.tag ORDER BY bCount DESC, T0.tag';
$query = $query_1 . $query_2 . $query_3 . $query_4 . $query_5; $query = $query_1 . $query_2 . $query_3 . $query_4 . $query_5;
if (! ($dbresult =& $this->db->sql_query_limit($query, $limit)) ){ if (! ($dbresult = $this->db->sql_query_limit($query, $limit)) ){
message_die(GENERAL_ERROR, 'Could not get related tags', '', __LINE__, __FILE__, $query, $this->db); message_die(GENERAL_ERROR, 'Could not get related tags', '', __LINE__, __FILE__, $query, $this->db);
return false; return false;
} }
@ -448,7 +448,7 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_DbService
$query = 'SELECT T.tag, COUNT(T.tag) AS bCount FROM '.$GLOBALS['tableprefix'].'bookmarks AS B LEFT JOIN '.$GLOBALS['tableprefix'].'bookmarks2tags AS T ON B.bId = T.bId WHERE B.bHash = \''. $this->db->sql_escape($hash) .'\' '. $privacy .'AND LEFT(T.tag, 7) <> "system:" GROUP BY T.tag ORDER BY bCount DESC'; $query = 'SELECT T.tag, COUNT(T.tag) AS bCount FROM '.$GLOBALS['tableprefix'].'bookmarks AS B LEFT JOIN '.$GLOBALS['tableprefix'].'bookmarks2tags AS T ON B.bId = T.bId WHERE B.bHash = \''. $this->db->sql_escape($hash) .'\' '. $privacy .'AND LEFT(T.tag, 7) <> "system:" GROUP BY T.tag ORDER BY bCount DESC';
if (!($dbresult =& $this->db->sql_query_limit($query, $limit))) { if (!($dbresult = $this->db->sql_query_limit($query, $limit))) {
message_die(GENERAL_ERROR, 'Could not get related tags for this hash', '', __LINE__, __FILE__, $query, $this->db); message_die(GENERAL_ERROR, 'Could not get related tags for this hash', '', __LINE__, __FILE__, $query, $this->db);
return false; return false;
} }
@ -622,12 +622,12 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_DbService
function hasTag($bookmarkid, $tag) { function hasTag($bookmarkid, $tag) {
$query = 'SELECT COUNT(*) AS tCount FROM '. $this->getTableName() .' WHERE bId = '. intval($bookmarkid) .' AND tag ="'. $this->db->sql_escape($tag) .'"'; $query = 'SELECT COUNT(*) AS tCount FROM '. $this->getTableName() .' WHERE bId = '. intval($bookmarkid) .' AND tag ="'. $this->db->sql_escape($tag) .'"';
if (! ($dbresult =& $this->db->sql_query($query)) ) { if (! ($dbresult = $this->db->sql_query($query)) ) {
message_die(GENERAL_ERROR, 'Could not find tag', '', __LINE__, __FILE__, $query, $this->db); message_die(GENERAL_ERROR, 'Could not find tag', '', __LINE__, __FILE__, $query, $this->db);
return false; return false;
} }
if ($row =& $this->db->sql_fetchrow($dbresult)) { if ($row = $this->db->sql_fetchrow($dbresult)) {
if ($row['tCount'] > 0) { if ($row['tCount'] > 0) {
$output = true; $output = true;
} }
@ -645,8 +645,8 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_DbService
return false; return false;
// Find bookmarks with old tag // Find bookmarks with old tag
$bookmarksInfo =& $bookmarkservice->getBookmarks(0, NULL, $userid, $old); $bookmarksInfo = $bookmarkservice->getBookmarks(0, NULL, $userid, $old);
$bookmarks =& $bookmarksInfo['bookmarks']; $bookmarks = $bookmarksInfo['bookmarks'];
// Delete old tag // Delete old tag
$this->deleteTag($userid, $old); $this->deleteTag($userid, $old);
@ -655,7 +655,7 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_DbService
$new = $tagservice->normalize($new); $new = $tagservice->normalize($new);
foreach(array_keys($bookmarks) as $key) { foreach(array_keys($bookmarks) as $key) {
$row =& $bookmarks[$key]; $row = $bookmarks[$key];
$this->attachTags($row['bId'], $new, $fromApi, NULL, false); $this->attachTags($row['bId'], $new, $fromApi, NULL, false);
} }

View file

@ -62,7 +62,7 @@ class SemanticScuttle_Service_CommonDescription extends SemanticScuttle_DbServic
$values = array('tag'=>$tag, 'cdDescription'=>$desc, 'uId'=>$uId, 'cdDatetime'=>$datetime); $values = array('tag'=>$tag, 'cdDescription'=>$desc, 'uId'=>$uId, 'cdDatetime'=>$datetime);
$sql = 'INSERT INTO '. $this->getTableName() .' '. $this->db->sql_build_array('INSERT', $values); $sql = 'INSERT INTO '. $this->getTableName() .' '. $this->db->sql_build_array('INSERT', $values);
if (!($dbresult =& $this->db->sql_query($sql))) { if (!($dbresult = $this->db->sql_query($sql))) {
$this->db->sql_transaction('rollback'); $this->db->sql_transaction('rollback');
message_die(GENERAL_ERROR, 'Could not add tag description', '', __LINE__, __FILE__, $sql, $this->db); message_die(GENERAL_ERROR, 'Could not add tag description', '', __LINE__, __FILE__, $sql, $this->db);
return false; return false;
@ -79,7 +79,7 @@ class SemanticScuttle_Service_CommonDescription extends SemanticScuttle_DbServic
$query.= ' WHERE tag=\'' . $this->db->sql_escape($tag) . "'"; $query.= ' WHERE tag=\'' . $this->db->sql_escape($tag) . "'";
$query.= " ORDER BY cdDatetime DESC"; $query.= " ORDER BY cdDatetime DESC";
if (!($dbresult = & $this->db->sql_query_limit($query, 1, 0))) { if (!($dbresult = $this->db->sql_query_limit($query, 1, 0))) {
message_die(GENERAL_ERROR, 'Could not get tag description', '', __LINE__, __FILE__, $query, $this->db); message_die(GENERAL_ERROR, 'Could not get tag description', '', __LINE__, __FILE__, $query, $this->db);
return false; return false;
} }
@ -99,7 +99,7 @@ class SemanticScuttle_Service_CommonDescription extends SemanticScuttle_DbServic
$query.= ' WHERE tag=\'' . $this->db->sql_escape($tag) . "'"; $query.= ' WHERE tag=\'' . $this->db->sql_escape($tag) . "'";
$query.= " ORDER BY cdDatetime DESC"; $query.= " ORDER BY cdDatetime DESC";
if (!($dbresult = & $this->db->sql_query($query))) { if (!($dbresult = $this->db->sql_query($query))) {
message_die(GENERAL_ERROR, 'Could not get tag descriptions', '', __LINE__, __FILE__, $query, $this->db); message_die(GENERAL_ERROR, 'Could not get tag descriptions', '', __LINE__, __FILE__, $query, $this->db);
return false; return false;
} }
@ -114,12 +114,12 @@ class SemanticScuttle_Service_CommonDescription extends SemanticScuttle_DbServic
$query.= " FROM `". $this->getTableName() ."`"; $query.= " FROM `". $this->getTableName() ."`";
$query.= ' WHERE cdId=\'' . $this->db->sql_escape($cdId) . "'"; $query.= ' WHERE cdId=\'' . $this->db->sql_escape($cdId) . "'";
if (!($dbresult = & $this->db->sql_query($query))) { if (!($dbresult = $this->db->sql_query($query))) {
message_die(GENERAL_ERROR, 'Could not get tag descriptions', '', __LINE__, __FILE__, $query, $this->db); message_die(GENERAL_ERROR, 'Could not get tag descriptions', '', __LINE__, __FILE__, $query, $this->db);
return false; return false;
} }
if ($row =& $this->db->sql_fetchrow($dbresult)) { if ($row = $this->db->sql_fetchrow($dbresult)) {
$this->db->sql_freeresult($dbresult); $this->db->sql_freeresult($dbresult);
return $row; return $row;
} else { } else {
@ -140,7 +140,7 @@ class SemanticScuttle_Service_CommonDescription extends SemanticScuttle_DbServic
$values = array('bHash'=>$bHash, 'cdTitle'=>$title, 'cdDescription'=>$desc, 'uId'=>$uId, 'cdDatetime'=>$datetime); $values = array('bHash'=>$bHash, 'cdTitle'=>$title, 'cdDescription'=>$desc, 'uId'=>$uId, 'cdDatetime'=>$datetime);
$sql = 'INSERT INTO '. $this->getTableName() .' '. $this->db->sql_build_array('INSERT', $values); $sql = 'INSERT INTO '. $this->getTableName() .' '. $this->db->sql_build_array('INSERT', $values);
if (!($dbresult =& $this->db->sql_query($sql))) { if (!($dbresult = $this->db->sql_query($sql))) {
$this->db->sql_transaction('rollback'); $this->db->sql_transaction('rollback');
message_die(GENERAL_ERROR, 'Could not add bookmark description', '', __LINE__, __FILE__, $sql, $this->db); message_die(GENERAL_ERROR, 'Could not add bookmark description', '', __LINE__, __FILE__, $sql, $this->db);
return false; return false;
@ -154,7 +154,7 @@ class SemanticScuttle_Service_CommonDescription extends SemanticScuttle_DbServic
$query.= ' WHERE bHash=\'' . $this->db->sql_escape($bHash) . "'"; $query.= ' WHERE bHash=\'' . $this->db->sql_escape($bHash) . "'";
$query.= " ORDER BY cdDatetime DESC"; $query.= " ORDER BY cdDatetime DESC";
if (!($dbresult = & $this->db->sql_query_limit($query, 1, 0))) { if (!($dbresult = $this->db->sql_query_limit($query, 1, 0))) {
message_die(GENERAL_ERROR, 'Could not get bookmark description', '', __LINE__, __FILE__, $query, $this->db); message_die(GENERAL_ERROR, 'Could not get bookmark description', '', __LINE__, __FILE__, $query, $this->db);
return false; return false;
} }
@ -174,7 +174,7 @@ class SemanticScuttle_Service_CommonDescription extends SemanticScuttle_DbServic
$query.= ' WHERE bHash=\'' . $this->db->sql_escape($bHash) . "'"; $query.= ' WHERE bHash=\'' . $this->db->sql_escape($bHash) . "'";
$query.= " ORDER BY cdDatetime DESC"; $query.= " ORDER BY cdDatetime DESC";
if (!($dbresult = & $this->db->sql_query($query))) { if (!($dbresult = $this->db->sql_query($query))) {
message_die(GENERAL_ERROR, 'Could not get bookmark descriptions', '', __LINE__, __FILE__, $query, $this->db); message_die(GENERAL_ERROR, 'Could not get bookmark descriptions', '', __LINE__, __FILE__, $query, $this->db);
return false; return false;
} }
@ -188,7 +188,7 @@ class SemanticScuttle_Service_CommonDescription extends SemanticScuttle_DbServic
$query = 'DELETE FROM '. $this->getTableName() . ' WHERE uId = '. intval($uId); $query = 'DELETE FROM '. $this->getTableName() . ' WHERE uId = '. intval($uId);
$this->db->sql_transaction('begin'); $this->db->sql_transaction('begin');
if (!($dbresult = & $this->db->sql_query($query))) { if (!($dbresult = $this->db->sql_query($query))) {
$this->db->sql_transaction('rollback'); $this->db->sql_transaction('rollback');
message_die(GENERAL_ERROR, 'Could not delete user descriptions', '', message_die(GENERAL_ERROR, 'Could not delete user descriptions', '',
__LINE__, __FILE__, $query, $this->db); __LINE__, __FILE__, $query, $this->db);

View file

@ -198,7 +198,7 @@ class SemanticScuttle_Service_SearchHistory extends SemanticScuttle_DbService
{ {
$sql = 'SELECT COUNT(*) AS `total` FROM '. $this->getTableName(); $sql = 'SELECT COUNT(*) AS `total` FROM '. $this->getTableName();
if (!($dbresult = $this->db->sql_query($sql)) if (!($dbresult = $this->db->sql_query($sql))
|| (!($row = & $this->db->sql_fetchrow($dbresult))) || (!($row = $this->db->sql_fetchrow($dbresult)))
) { ) {
message_die( message_die(
GENERAL_ERROR, 'Could not get total searches', GENERAL_ERROR, 'Could not get total searches',

View file

@ -54,7 +54,7 @@ class SemanticScuttle_Service_Tag extends SemanticScuttle_DbService
$query.= ' WHERE tag = \''. $this->db->sql_escape($tag) . "'"; $query.= ' WHERE tag = \''. $this->db->sql_escape($tag) . "'";
$query.= ' AND uId = ' . intval($uId); $query.= ' AND uId = ' . intval($uId);
if (!($dbresult = & $this->db->sql_query($query))) { if (!($dbresult = $this->db->sql_query($query))) {
message_die(GENERAL_ERROR, 'Could not get tag description', '', __LINE__, __FILE__, $query, $this->db); message_die(GENERAL_ERROR, 'Could not get tag description', '', __LINE__, __FILE__, $query, $this->db);
return false; return false;
} }
@ -74,7 +74,7 @@ class SemanticScuttle_Service_Tag extends SemanticScuttle_DbService
$query.= ' WHERE tag = \'' . $this->db->sql_escape($tag) . "'"; $query.= ' WHERE tag = \'' . $this->db->sql_escape($tag) . "'";
$query.= ' AND uId = "' . intval($uId) . '"'; $query.= ' AND uId = "' . intval($uId) . '"';
if (!($dbresult = & $this->db->sql_query($query))) { if (!($dbresult = $this->db->sql_query($query))) {
message_die(GENERAL_ERROR, 'Could not get tag description', '', __LINE__, __FILE__, $query, $this->db); message_die(GENERAL_ERROR, 'Could not get tag description', '', __LINE__, __FILE__, $query, $this->db);
return false; return false;
} }
@ -93,7 +93,7 @@ class SemanticScuttle_Service_Tag extends SemanticScuttle_DbService
$query.= ' FROM '.$this->getTableName(); $query.= ' FROM '.$this->getTableName();
$query.= ' WHERE tag = \''. $this->db->sql_escape($tag) . "'"; $query.= ' WHERE tag = \''. $this->db->sql_escape($tag) . "'";
if (!($dbresult = & $this->db->sql_query($query))) { if (!($dbresult = $this->db->sql_query($query))) {
message_die(GENERAL_ERROR, 'Could not get tag description', '', __LINE__, __FILE__, $query, $this->db); message_die(GENERAL_ERROR, 'Could not get tag description', '', __LINE__, __FILE__, $query, $this->db);
return false; return false;
} }
@ -114,7 +114,7 @@ class SemanticScuttle_Service_Tag extends SemanticScuttle_DbService
} }
$this->db->sql_transaction('begin'); $this->db->sql_transaction('begin');
if (!($dbresult = & $this->db->sql_query($query))) { if (!($dbresult = $this->db->sql_query($query))) {
$this->db->sql_transaction('rollback'); $this->db->sql_transaction('rollback');
message_die(GENERAL_ERROR, 'Could not delete bookmarks', '', __LINE__, __FILE__, $query, $this->db); message_die(GENERAL_ERROR, 'Could not delete bookmarks', '', __LINE__, __FILE__, $query, $this->db);
return false; return false;

View file

@ -43,9 +43,9 @@ class SemanticScuttle_Service_Tag2Tag extends SemanticScuttle_DbService
} }
function __construct(&$db) function __construct($db)
{ {
$this->db =& $db; $this->db =$db;
$this->tablename = $GLOBALS['tableprefix'] .'tags2tags'; $this->tablename = $GLOBALS['tableprefix'] .'tags2tags';
} }
@ -173,7 +173,7 @@ class SemanticScuttle_Service_Tag2Tag extends SemanticScuttle_DbService
$query.= " AND uId = '".intval($uId)."'"; $query.= " AND uId = '".intval($uId)."'";
} }
//die($query); //die($query);
if (! ($dbresult =& $this->db->sql_query($query)) ){ if (! ($dbresult = $this->db->sql_query($query)) ){
message_die(GENERAL_ERROR, 'Could not get related tags', '', __LINE__, __FILE__, $query, $this->db); message_die(GENERAL_ERROR, 'Could not get related tags', '', __LINE__, __FILE__, $query, $this->db);
return false; return false;
} }
@ -312,7 +312,7 @@ class SemanticScuttle_Service_Tag2Tag extends SemanticScuttle_DbService
$query.= " LIMIT 0," . intval($limit); $query.= " LIMIT 0," . intval($limit);
} }
if (! ($dbresult =& $this->db->sql_query($query)) ){ if (! ($dbresult = $this->db->sql_query($query)) ){
message_die(GENERAL_ERROR, 'Could not get linked tags', '', __LINE__, __FILE__, $query, $this->db); message_die(GENERAL_ERROR, 'Could not get linked tags', '', __LINE__, __FILE__, $query, $this->db);
return false; return false;
} }
@ -337,7 +337,7 @@ class SemanticScuttle_Service_Tag2Tag extends SemanticScuttle_DbService
$query.= " ORDER BY count DESC"; $query.= " ORDER BY count DESC";
$query.= " LIMIT 0, " . intval($GLOBALS['maxSizeMenuBlock']); $query.= " LIMIT 0, " . intval($GLOBALS['maxSizeMenuBlock']);
if (! ($dbresult =& $this->db->sql_query($query)) ){ if (! ($dbresult = $this->db->sql_query($query)) ){
message_die(GENERAL_ERROR, 'Could not get linked tags', '', __LINE__, __FILE__, $query, $this->db); message_die(GENERAL_ERROR, 'Could not get linked tags', '', __LINE__, __FILE__, $query, $this->db);
return false; return false;
} }
@ -393,7 +393,7 @@ class SemanticScuttle_Service_Tag2Tag extends SemanticScuttle_DbService
$query.= strlen($relationType)>0 ? ' AND relationType = \''. $this->db->sql_escape($relationType) . "'" : ''; $query.= strlen($relationType)>0 ? ' AND relationType = \''. $this->db->sql_escape($relationType) . "'" : '';
$query.= strlen($uId)>0 ? ' AND uId = '. intval($uId) : ''; $query.= strlen($uId)>0 ? ' AND uId = '. intval($uId) : '';
if (!($dbresult =& $this->db->sql_query($query))) { if (!($dbresult = $this->db->sql_query($query))) {
message_die(GENERAL_ERROR, 'Could not remove tag relation', '', __LINE__, __FILE__, $query, $this->db); message_die(GENERAL_ERROR, 'Could not remove tag relation', '', __LINE__, __FILE__, $query, $this->db);
return false; return false;
} }
@ -410,7 +410,7 @@ class SemanticScuttle_Service_Tag2Tag extends SemanticScuttle_DbService
$query = 'DELETE FROM '. $this->getTableName(); $query = 'DELETE FROM '. $this->getTableName();
$query.= ' WHERE uId = '. intval($uId); $query.= ' WHERE uId = '. intval($uId);
if (!($dbresult =& $this->db->sql_query($query))) { if (!($dbresult = $this->db->sql_query($query))) {
message_die(GENERAL_ERROR, 'Could not remove tag relation', '', __LINE__, __FILE__, $query, $this->db); message_die(GENERAL_ERROR, 'Could not remove tag relation', '', __LINE__, __FILE__, $query, $this->db);
return false; return false;
} }

View file

@ -72,7 +72,7 @@ class SemanticScuttle_Service_TagCache extends SemanticScuttle_DbService
$query.= " AND uId = " . intval($uId); $query.= " AND uId = " . intval($uId);
//die($query); //die($query);
if (! ($dbresult =& $this->db->sql_query($query)) ){ if (! ($dbresult = $this->db->sql_query($query)) ){
message_die(GENERAL_ERROR, 'Could not get related tags', '', __LINE__, __FILE__, $query, $this->db); message_die(GENERAL_ERROR, 'Could not get related tags', '', __LINE__, __FILE__, $query, $this->db);
return false; return false;
} }
@ -101,7 +101,7 @@ class SemanticScuttle_Service_TagCache extends SemanticScuttle_DbService
$values = array('tag1' => $tag1, 'tag2' => $tag2, 'relationType'=> '>', 'uId'=> $uId); $values = array('tag1' => $tag1, 'tag2' => $tag2, 'relationType'=> '>', 'uId'=> $uId);
$query = 'INSERT INTO '. $this->getTableName() .' '. $this->db->sql_build_array('INSERT', $values); $query = 'INSERT INTO '. $this->getTableName() .' '. $this->db->sql_build_array('INSERT', $values);
//die($query); //die($query);
if (!($dbresult =& $this->db->sql_query($query))) { if (!($dbresult = $this->db->sql_query($query))) {
$this->db->sql_transaction('rollback'); $this->db->sql_transaction('rollback');
message_die(GENERAL_ERROR, 'Could not add tag cache inference', '', __LINE__, __FILE__, $query, $this->db); message_die(GENERAL_ERROR, 'Could not add tag cache inference', '', __LINE__, __FILE__, $query, $this->db);
return false; return false;
@ -122,7 +122,7 @@ class SemanticScuttle_Service_TagCache extends SemanticScuttle_DbService
$query.= ' AND relationType = ">"'; $query.= ' AND relationType = ">"';
$query.= strlen($uId)>0 ? ' AND uId = ' . intval($uId) : ''; $query.= strlen($uId)>0 ? ' AND uId = ' . intval($uId) : '';
if (!($dbresult =& $this->db->sql_query($query))) { if (!($dbresult = $this->db->sql_query($query))) {
message_die(GENERAL_ERROR, 'Could not remove tag cache inference', '', __LINE__, __FILE__, $query, $this->db); message_die(GENERAL_ERROR, 'Could not remove tag cache inference', '', __LINE__, __FILE__, $query, $this->db);
return false; return false;
} }
@ -215,7 +215,7 @@ class SemanticScuttle_Service_TagCache extends SemanticScuttle_DbService
$values = array('tag1' => $tag1, 'tag2' => $tag2, 'relationType'=> '=', 'uId'=> $uId); $values = array('tag1' => $tag1, 'tag2' => $tag2, 'relationType'=> '=', 'uId'=> $uId);
$query = 'INSERT INTO '. $this->getTableName() .' '. $this->db->sql_build_array('INSERT', $values); $query = 'INSERT INTO '. $this->getTableName() .' '. $this->db->sql_build_array('INSERT', $values);
//die($query); //die($query);
if (!($dbresult =& $this->db->sql_query($query))) { if (!($dbresult = $this->db->sql_query($query))) {
$this->db->sql_transaction('rollback'); $this->db->sql_transaction('rollback');
message_die(GENERAL_ERROR, 'Could not add tag cache synonymy', '', __LINE__, __FILE__, $query, $this->db); message_die(GENERAL_ERROR, 'Could not add tag cache synonymy', '', __LINE__, __FILE__, $query, $this->db);
return false; return false;
@ -232,7 +232,7 @@ class SemanticScuttle_Service_TagCache extends SemanticScuttle_DbService
$query.= ' AND relationType = "="'; $query.= ' AND relationType = "="';
$query.= ' AND uId = ' . intval($uId); $query.= ' AND uId = ' . intval($uId);
if (!($dbresult =& $this->db->sql_query($query))) { if (!($dbresult = $this->db->sql_query($query))) {
message_die(GENERAL_ERROR, 'Could not remove tag cache inference', '', __LINE__, __FILE__, $query, $this->db); message_die(GENERAL_ERROR, 'Could not remove tag cache inference', '', __LINE__, __FILE__, $query, $this->db);
return false; return false;
} }
@ -295,7 +295,7 @@ class SemanticScuttle_Service_TagCache extends SemanticScuttle_DbService
$query.= " AND uId = " . intval($uId); $query.= " AND uId = " . intval($uId);
//die($query); //die($query);
if (! ($dbresult =& $this->db->sql_query($query)) ){ if (! ($dbresult = $this->db->sql_query($query)) ){
message_die(GENERAL_ERROR, 'Could not get related tags', '', __LINE__, __FILE__, $query, $this->db); message_die(GENERAL_ERROR, 'Could not get related tags', '', __LINE__, __FILE__, $query, $this->db);
return false; return false;
} }
@ -323,7 +323,7 @@ class SemanticScuttle_Service_TagCache extends SemanticScuttle_DbService
$query.= " AND uId = " . intval($uId); $query.= " AND uId = " . intval($uId);
$query.= $tagExcepted!=''?" AND tag2!='" . $this->db->sql_escape($tagExcepted) . "'" : ''; $query.= $tagExcepted!=''?" AND tag2!='" . $this->db->sql_escape($tagExcepted) . "'" : '';
if (! ($dbresult =& $this->db->sql_query($query)) ){ if (! ($dbresult = $this->db->sql_query($query)) ){
message_die(GENERAL_ERROR, 'Could not get related tags', '', __LINE__, __FILE__, $query, $this->db); message_die(GENERAL_ERROR, 'Could not get related tags', '', __LINE__, __FILE__, $query, $this->db);
return false; return false;
} }
@ -371,7 +371,7 @@ class SemanticScuttle_Service_TagCache extends SemanticScuttle_DbService
function deleteByUser($uId) { function deleteByUser($uId) {
$query = 'DELETE FROM '. $this->getTableName() .' WHERE uId = '. intval($uId); $query = 'DELETE FROM '. $this->getTableName() .' WHERE uId = '. intval($uId);
if (!($dbresult = & $this->db->sql_query($query))) { if (!($dbresult = $this->db->sql_query($query))) {
message_die(GENERAL_ERROR, 'Could not delete user tags cache', '', __LINE__, __FILE__, $query, $this->db); message_die(GENERAL_ERROR, 'Could not delete user tags cache', '', __LINE__, __FILE__, $query, $this->db);
return false; return false;
} }

View file

@ -67,7 +67,7 @@ class SemanticScuttle_Service_TagStat extends SemanticScuttle_DbService
$query.= " AND relationType = '". $relationType ."'"; $query.= " AND relationType = '". $relationType ."'";
$query.= " AND uId = '".$uId."'"; $query.= " AND uId = '".$uId."'";
$dbresults =& $this->db->sql_query($query); $dbresults = $this->db->sql_query($query);
$row = $this->db->sql_fetchrow($dbresults); $row = $this->db->sql_fetchrow($dbresults);
$this->db->sql_freeresult($dbresults); $this->db->sql_freeresult($dbresults);
if($row['nb'] == null) { if($row['nb'] == null) {
@ -83,7 +83,7 @@ class SemanticScuttle_Service_TagStat extends SemanticScuttle_DbService
$query.= " AND relationType = '". $relationType ."'"; $query.= " AND relationType = '". $relationType ."'";
$query.= " AND uId = '".$uId."'"; $query.= " AND uId = '".$uId."'";
$dbresults =& $this->db->sql_query($query); $dbresults = $this->db->sql_query($query);
$row = $this->db->sql_fetchrow($dbresults); $row = $this->db->sql_fetchrow($dbresults);
$this->db->sql_freeresult($dbresults); $this->db->sql_freeresult($dbresults);
if($row['depth'] == null) { if($row['depth'] == null) {
@ -99,7 +99,7 @@ class SemanticScuttle_Service_TagStat extends SemanticScuttle_DbService
$query.= " AND relationType = '". $relationType ."'"; $query.= " AND relationType = '". $relationType ."'";
$query.= " AND uId = '".$uId."'"; $query.= " AND uId = '".$uId."'";
$dbresults =& $this->db->sql_query($query); $dbresults = $this->db->sql_query($query);
$row = $this->db->sql_fetchrow($dbresults); $row = $this->db->sql_fetchrow($dbresults);
$this->db->sql_freeresult($dbresults); $this->db->sql_freeresult($dbresults);
if($row['nbupdate'] == null) { if($row['nbupdate'] == null) {
@ -161,7 +161,7 @@ class SemanticScuttle_Service_TagStat extends SemanticScuttle_DbService
//die($query); //die($query);
if (! ($dbresult =& $this->db->sql_query($query)) ){ if (! ($dbresult = $this->db->sql_query($query)) ){
message_die(GENERAL_ERROR, 'Could not update stats', '', __LINE__, __FILE__, $query, $this->db); message_die(GENERAL_ERROR, 'Could not update stats', '', __LINE__, __FILE__, $query, $this->db);
return false; return false;
} }
@ -215,7 +215,7 @@ class SemanticScuttle_Service_TagStat extends SemanticScuttle_DbService
function deleteTagStatForUser($uId) { function deleteTagStatForUser($uId) {
$query = 'DELETE FROM '. $this->getTableName() .' WHERE uId = '. intval($uId); $query = 'DELETE FROM '. $this->getTableName() .' WHERE uId = '. intval($uId);
if (!($dbresult = & $this->db->sql_query($query))) { if (!($dbresult = $this->db->sql_query($query))) {
message_die(GENERAL_ERROR, 'Could not delete tag stats', '', __LINE__, message_die(GENERAL_ERROR, 'Could not delete tag stats', '', __LINE__,
__FILE__, $query, $this->db); __FILE__, $query, $this->db);
return false; return false;

View file

@ -120,12 +120,12 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService
if($nb>0) { if($nb>0) {
$query .= ' LIMIT 0, '.$nb; $query .= ' LIMIT 0, '.$nb;
} }
if (! ($dbresult =& $this->db->sql_query($query)) ) { if (! ($dbresult = $this->db->sql_query($query)) ) {
message_die(GENERAL_ERROR, 'Could not get user', '', __LINE__, __FILE__, $query, $this->db); message_die(GENERAL_ERROR, 'Could not get user', '', __LINE__, __FILE__, $query, $this->db);
return false; return false;
} }
while ($row = & $this->db->sql_fetchrow($dbresult)) { while ($row = $this->db->sql_fetchrow($dbresult)) {
$users[] = $row; $users[] = $row;
} }
$this->db->sql_freeresult($dbresult); $this->db->sql_freeresult($dbresult);
@ -149,7 +149,7 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService
$query .= ' LIMIT 0, ' . intval($nb); $query .= ' LIMIT 0, ' . intval($nb);
} }
if (! ($dbresult =& $this->db->sql_query($query)) ) { if (! ($dbresult = $this->db->sql_query($query)) ) {
message_die( message_die(
GENERAL_ERROR, 'Could not get user', GENERAL_ERROR, 'Could not get user',
'', __LINE__, __FILE__, $query, $this->db '', __LINE__, __FILE__, $query, $this->db
@ -158,7 +158,7 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService
} }
$users = array(); $users = array();
while ($row = & $this->db->sql_fetchrow($dbresult)) { while ($row = $this->db->sql_fetchrow($dbresult)) {
$users[] = new SemanticScuttle_Model_User( $users[] = new SemanticScuttle_Model_User(
$row[$this->getFieldName('primary')], $row[$this->getFieldName('primary')],
$row[$this->getFieldName('username')] $row[$this->getFieldName('username')]
@ -434,7 +434,7 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService
')) = \''.$this->db->sql_escape($cook[1]).'\' AND '. ')) = \''.$this->db->sql_escape($cook[1]).'\' AND '.
$this->getFieldName('primary'). ' = '. $this->db->sql_escape($cook[0]); $this->getFieldName('primary'). ' = '. $this->db->sql_escape($cook[0]);
if (! ($dbresult =& $this->db->sql_query($query)) ) { if (! ($dbresult = $this->db->sql_query($query)) ) {
message_die( message_die(
GENERAL_ERROR, 'Could not get user', GENERAL_ERROR, 'Could not get user',
'', __LINE__, __FILE__, $query, $this->db '', __LINE__, __FILE__, $query, $this->db
@ -596,7 +596,7 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService
// Gets the list of user IDs being watched by the given user. // Gets the list of user IDs being watched by the given user.
$query = 'SELECT watched FROM '. $GLOBALS['tableprefix'] .'watched WHERE uId = '. intval($uId); $query = 'SELECT watched FROM '. $GLOBALS['tableprefix'] .'watched WHERE uId = '. intval($uId);
if (! ($dbresult =& $this->db->sql_query($query)) ) { if (! ($dbresult = $this->db->sql_query($query)) ) {
message_die(GENERAL_ERROR, 'Could not get watchlist', '', __LINE__, __FILE__, $query, $this->db); message_die(GENERAL_ERROR, 'Could not get watchlist', '', __LINE__, __FILE__, $query, $this->db);
return false; return false;
} }
@ -606,7 +606,7 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService
$this->db->sql_freeresult($dbresult); $this->db->sql_freeresult($dbresult);
return $arrWatch; return $arrWatch;
} }
while ($row =& $this->db->sql_fetchrow($dbresult)) { while ($row = $this->db->sql_fetchrow($dbresult)) {
$arrWatch[] = $row['watched']; $arrWatch[] = $row['watched'];
} }
$this->db->sql_freeresult($dbresult); $this->db->sql_freeresult($dbresult);
@ -668,7 +668,7 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService
// Returns true if the current user is watching the given user, and false otherwise. // Returns true if the current user is watching the given user, and false otherwise.
$query = 'SELECT watched FROM '. $GLOBALS['tableprefix'] .'watched AS W INNER JOIN '. $this->getTableName() .' AS U ON U.'. $this->getFieldName('primary') .' = W.watched WHERE U.'. $this->getFieldName('primary') .' = '. intval($watcheduser) .' AND W.uId = '. intval($currentuser); $query = 'SELECT watched FROM '. $GLOBALS['tableprefix'] .'watched AS W INNER JOIN '. $this->getTableName() .' AS U ON U.'. $this->getFieldName('primary') .' = W.watched WHERE U.'. $this->getFieldName('primary') .' = '. intval($watcheduser) .' AND W.uId = '. intval($currentuser);
if (! ($dbresult =& $this->db->sql_query($query)) ) { if (! ($dbresult = $this->db->sql_query($query)) ) {
message_die(GENERAL_ERROR, 'Could not get watchstatus', '', __LINE__, __FILE__, $query, $this->db); message_die(GENERAL_ERROR, 'Could not get watchstatus', '', __LINE__, __FILE__, $query, $this->db);
return false; return false;
} }
@ -690,7 +690,7 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService
if ($watched) { if ($watched) {
$sql = 'DELETE FROM '. $GLOBALS['tableprefix'] .'watched WHERE uId = '. intval($currentUserID) .' AND watched = '. intval($subjectUserID); $sql = 'DELETE FROM '. $GLOBALS['tableprefix'] .'watched WHERE uId = '. intval($currentUserID) .' AND watched = '. intval($subjectUserID);
if (!($dbresult =& $this->db->sql_query($sql))) { if (!($dbresult = $this->db->sql_query($sql))) {
$this->db->sql_transaction('rollback'); $this->db->sql_transaction('rollback');
message_die(GENERAL_ERROR, 'Could not add user to watch list', '', __LINE__, __FILE__, $sql, $this->db); message_die(GENERAL_ERROR, 'Could not add user to watch list', '', __LINE__, __FILE__, $sql, $this->db);
return false; return false;
@ -701,7 +701,7 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService
'watched' => intval($subjectUserID) 'watched' => intval($subjectUserID)
); );
$sql = 'INSERT INTO '. $GLOBALS['tableprefix'] .'watched '. $this->db->sql_build_array('INSERT', $values); $sql = 'INSERT INTO '. $GLOBALS['tableprefix'] .'watched '. $this->db->sql_build_array('INSERT', $values);
if (!($dbresult =& $this->db->sql_query($sql))) { if (!($dbresult = $this->db->sql_query($sql))) {
$this->db->sql_transaction('rollback'); $this->db->sql_transaction('rollback');
message_die(GENERAL_ERROR, 'Could not add user to watch list', '', __LINE__, __FILE__, $sql, $this->db); message_die(GENERAL_ERROR, 'Could not add user to watch list', '', __LINE__, __FILE__, $sql, $this->db);
return false; return false;
@ -743,7 +743,7 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService
// Execute the statement. // Execute the statement.
$this->db->sql_transaction('begin'); $this->db->sql_transaction('begin');
if (!($dbresult = & $this->db->sql_query($sql))) { if (!($dbresult = $this->db->sql_query($sql))) {
$this->db->sql_transaction('rollback'); $this->db->sql_transaction('rollback');
message_die( message_die(
GENERAL_ERROR, 'Could not insert user', GENERAL_ERROR, 'Could not insert user',
@ -826,7 +826,7 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService
// Execute the statement. // Execute the statement.
$this->db->sql_transaction('begin'); $this->db->sql_transaction('begin');
if (!($dbresult = & $this->db->sql_query($sql))) { if (!($dbresult = $this->db->sql_query($sql))) {
$this->db->sql_transaction('rollback'); $this->db->sql_transaction('rollback');
message_die( message_die(
GENERAL_ERROR, 'Could not update user', '', GENERAL_ERROR, 'Could not update user', '',
@ -845,7 +845,7 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService
function getAllUsers ( ) { function getAllUsers ( ) {
$query = 'SELECT * FROM '. $this->getTableName(); $query = 'SELECT * FROM '. $this->getTableName();
if (! ($dbresult =& $this->db->sql_query($query)) ) { if (! ($dbresult = $this->db->sql_query($query)) ) {
message_die(GENERAL_ERROR, 'Could not get users', '', __LINE__, __FILE__, $query, $this->db); message_die(GENERAL_ERROR, 'Could not get users', '', __LINE__, __FILE__, $query, $this->db);
return false; return false;
} }
@ -872,7 +872,7 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService
function deleteUser($uId) { function deleteUser($uId) {
$query = 'DELETE FROM '. $this->getTableName() .' WHERE uId = '. intval($uId); $query = 'DELETE FROM '. $this->getTableName() .' WHERE uId = '. intval($uId);
if (!($dbresult = & $this->db->sql_query($query))) { if (!($dbresult = $this->db->sql_query($query))) {
message_die(GENERAL_ERROR, 'Could not delete user', '', __LINE__, __FILE__, $query, $this->db); message_die(GENERAL_ERROR, 'Could not delete user', '', __LINE__, __FILE__, $query, $this->db);
return false; return false;
} }

View file

@ -276,4 +276,17 @@ function message_die($msg_code, $msg_text = '', $msg_title = '', $err_line = '',
echo "<html>\n<body>\n". $msg_title ."\n<br /><br />\n". $msg_text ."</body>\n</html>"; echo "<html>\n<body>\n". $msg_title ."\n<br /><br />\n". $msg_text ."</body>\n</html>";
exit; exit;
} }
/**
* Calls reset() on the given arg, without the E_STRICT error
* "Only variables should be passed by reference"
*
* @param array $arg Array to return first element of
*
* @return mixed First element of the array
*/
function rreset($array)
{
return reset($array);
}
?> ?>

View file

@ -64,7 +64,7 @@ class Api_ExportCsvTest extends TestBaseApi
*/ */
public function testMimeTypeFilename() public function testMimeTypeFilename()
{ {
$res = reset($this->getAuthRequest())->send(); $res = rreset($this->getAuthRequest())->send();
$this->assertEquals(200, $res->getStatus()); $this->assertEquals(200, $res->getStatus());
//verify MIME content type //verify MIME content type
@ -253,7 +253,7 @@ class Api_ExportCsvTest extends TestBaseApi
$ar[] = $arl; $ar[] = $arl;
} }
} }
if (count(end($ar)) == 1 && reset(end($ar)) == '') { if (count(end($ar)) == 1 && rreset(end($ar)) == '') {
unset($ar[key($ar)]); unset($ar[key($ar)]);
} }
return $ar; return $ar;

View file

@ -12,7 +12,7 @@ class Api_OpenSearchTest extends TestBaseApi
$xhtml = $req->send()->getBody(); $xhtml = $req->send()->getBody();
$xml = simplexml_load_string($xhtml); $xml = simplexml_load_string($xhtml);
$xml->registerXPathNamespace('h', reset($xml->getDocNamespaces())); $xml->registerXPathNamespace('h', rreset($xml->getDocNamespaces()));
$this->assertInstanceOf( $this->assertInstanceOf(
'SimpleXMLElement', $xml, 'SimpleXMLElement', $xml,
@ -58,7 +58,7 @@ class Api_OpenSearchTest extends TestBaseApi
{ {
$xml = $this->getRequest('api/opensearch.php')->send()->getBody(); $xml = $this->getRequest('api/opensearch.php')->send()->getBody();
$x = simplexml_load_string($xml); $x = simplexml_load_string($xml);
$x->registerXPathNamespace('os', reset($x->getDocNamespaces())); $x->registerXPathNamespace('os', rreset($x->getDocNamespaces()));
$arElements = $x->xpath('//os:Url[@type="text/html"]'); $arElements = $x->xpath('//os:Url[@type="text/html"]');
$this->assertEquals( $this->assertEquals(

View file

@ -87,7 +87,7 @@ class TestBase extends PHPUnit_Framework_TestCase
protected function addUser( protected function addUser(
$username = null, $password = null, $privateKey = null $username = null, $password = null, $privateKey = null
) { ) {
return reset($this->addUserData($username, $password, $privateKey)); return rreset($this->addUserData($username, $password, $privateKey));
} }