From d0ed9adec8084b193c3429b664a408b2a3f6b71c Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Sun, 17 Mar 2013 22:22:16 +0100 Subject: remove php4-style object reference passing --- src/SemanticScuttle/Service/Bookmark.php | 6 ++--- src/SemanticScuttle/Service/Bookmark2Tag.php | 24 +++++++++---------- src/SemanticScuttle/Service/CommonDescription.php | 18 +++++++-------- src/SemanticScuttle/Service/SearchHistory.php | 2 +- src/SemanticScuttle/Service/Tag.php | 8 +++---- src/SemanticScuttle/Service/Tag2Tag.php | 14 ++++++------ src/SemanticScuttle/Service/TagCache.php | 16 ++++++------- src/SemanticScuttle/Service/TagStat.php | 10 ++++---- src/SemanticScuttle/Service/User.php | 28 +++++++++++------------ src/SemanticScuttle/functions.php | 13 +++++++++++ 10 files changed, 76 insertions(+), 63 deletions(-) (limited to 'src') diff --git a/src/SemanticScuttle/Service/Bookmark.php b/src/SemanticScuttle/Service/Bookmark.php index 17ab7ba..faeecc2 100644 --- a/src/SemanticScuttle/Service/Bookmark.php +++ b/src/SemanticScuttle/Service/Bookmark.php @@ -90,7 +90,7 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService . ' "' . $this->db->sql_escape($value) .'"' . $range; - 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', '', __LINE__, __FILE__, @@ -148,7 +148,7 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService . $query_2 .' WHERE B.bId = '. $this->db->sql_escape($bid); - if (!($dbresult = & $this->db->sql_query($sql))) { + if (!($dbresult = $this->db->sql_query($sql))) { message_die( GENERAL_ERROR, 'Could not get bookmark', '', __LINE__, __FILE__, $sql, $this->db @@ -630,7 +630,7 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService . ' WHERE bId = ' . intval($bId); $this->db->sql_transaction('begin'); - if (!($dbresult = & $this->db->sql_query($sql))) { + if (!($dbresult = $this->db->sql_query($sql))) { $this->db->sql_transaction('rollback'); message_die( GENERAL_ERROR, 'Could not update bookmark', diff --git a/src/SemanticScuttle/Service/Bookmark2Tag.php b/src/SemanticScuttle/Service/Bookmark2Tag.php index 3e5c533..6505a5a 100644 --- a/src/SemanticScuttle/Service/Bookmark2Tag.php +++ b/src/SemanticScuttle/Service/Bookmark2Tag.php @@ -200,7 +200,7 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_DbService $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'); message_die( 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 '. $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); return false; } @@ -238,7 +238,7 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_DbService $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); return false; } @@ -258,7 +258,7 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_DbService $GLOBALS['tableprefix'].'bookmarks', $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); 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'; - 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); 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 = $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); 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'; - 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); return false; } @@ -622,12 +622,12 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_DbService function hasTag($bookmarkid, $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); return false; } - if ($row =& $this->db->sql_fetchrow($dbresult)) { + if ($row = $this->db->sql_fetchrow($dbresult)) { if ($row['tCount'] > 0) { $output = true; } @@ -645,8 +645,8 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_DbService return false; // Find bookmarks with old tag - $bookmarksInfo =& $bookmarkservice->getBookmarks(0, NULL, $userid, $old); - $bookmarks =& $bookmarksInfo['bookmarks']; + $bookmarksInfo = $bookmarkservice->getBookmarks(0, NULL, $userid, $old); + $bookmarks = $bookmarksInfo['bookmarks']; // Delete old tag $this->deleteTag($userid, $old); @@ -655,7 +655,7 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_DbService $new = $tagservice->normalize($new); foreach(array_keys($bookmarks) as $key) { - $row =& $bookmarks[$key]; + $row = $bookmarks[$key]; $this->attachTags($row['bId'], $new, $fromApi, NULL, false); } diff --git a/src/SemanticScuttle/Service/CommonDescription.php b/src/SemanticScuttle/Service/CommonDescription.php index 0fffd32..d03b34a 100644 --- a/src/SemanticScuttle/Service/CommonDescription.php +++ b/src/SemanticScuttle/Service/CommonDescription.php @@ -62,7 +62,7 @@ class SemanticScuttle_Service_CommonDescription extends SemanticScuttle_DbServic $values = array('tag'=>$tag, 'cdDescription'=>$desc, 'uId'=>$uId, 'cdDatetime'=>$datetime); $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'); message_die(GENERAL_ERROR, 'Could not add tag description', '', __LINE__, __FILE__, $sql, $this->db); return false; @@ -79,7 +79,7 @@ class SemanticScuttle_Service_CommonDescription extends SemanticScuttle_DbServic $query.= ' WHERE tag=\'' . $this->db->sql_escape($tag) . "'"; $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); return false; } @@ -99,7 +99,7 @@ class SemanticScuttle_Service_CommonDescription extends SemanticScuttle_DbServic $query.= ' WHERE tag=\'' . $this->db->sql_escape($tag) . "'"; $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); return false; } @@ -114,12 +114,12 @@ class SemanticScuttle_Service_CommonDescription extends SemanticScuttle_DbServic $query.= " FROM `". $this->getTableName() ."`"; $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); return false; } - if ($row =& $this->db->sql_fetchrow($dbresult)) { + if ($row = $this->db->sql_fetchrow($dbresult)) { $this->db->sql_freeresult($dbresult); return $row; } else { @@ -140,7 +140,7 @@ class SemanticScuttle_Service_CommonDescription extends SemanticScuttle_DbServic $values = array('bHash'=>$bHash, 'cdTitle'=>$title, 'cdDescription'=>$desc, 'uId'=>$uId, 'cdDatetime'=>$datetime); $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'); message_die(GENERAL_ERROR, 'Could not add bookmark description', '', __LINE__, __FILE__, $sql, $this->db); return false; @@ -154,7 +154,7 @@ class SemanticScuttle_Service_CommonDescription extends SemanticScuttle_DbServic $query.= ' WHERE bHash=\'' . $this->db->sql_escape($bHash) . "'"; $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); return false; } @@ -174,7 +174,7 @@ class SemanticScuttle_Service_CommonDescription extends SemanticScuttle_DbServic $query.= ' WHERE bHash=\'' . $this->db->sql_escape($bHash) . "'"; $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); return false; } @@ -188,7 +188,7 @@ class SemanticScuttle_Service_CommonDescription extends SemanticScuttle_DbServic $query = 'DELETE FROM '. $this->getTableName() . ' WHERE uId = '. intval($uId); $this->db->sql_transaction('begin'); - if (!($dbresult = & $this->db->sql_query($query))) { + if (!($dbresult = $this->db->sql_query($query))) { $this->db->sql_transaction('rollback'); message_die(GENERAL_ERROR, 'Could not delete user descriptions', '', __LINE__, __FILE__, $query, $this->db); diff --git a/src/SemanticScuttle/Service/SearchHistory.php b/src/SemanticScuttle/Service/SearchHistory.php index a056ce2..ac0b1c7 100644 --- a/src/SemanticScuttle/Service/SearchHistory.php +++ b/src/SemanticScuttle/Service/SearchHistory.php @@ -198,7 +198,7 @@ class SemanticScuttle_Service_SearchHistory extends SemanticScuttle_DbService { $sql = 'SELECT COUNT(*) AS `total` FROM '. $this->getTableName(); if (!($dbresult = $this->db->sql_query($sql)) - || (!($row = & $this->db->sql_fetchrow($dbresult))) + || (!($row = $this->db->sql_fetchrow($dbresult))) ) { message_die( GENERAL_ERROR, 'Could not get total searches', diff --git a/src/SemanticScuttle/Service/Tag.php b/src/SemanticScuttle/Service/Tag.php index 2476608..39147b8 100644 --- a/src/SemanticScuttle/Service/Tag.php +++ b/src/SemanticScuttle/Service/Tag.php @@ -54,7 +54,7 @@ class SemanticScuttle_Service_Tag extends SemanticScuttle_DbService $query.= ' WHERE tag = \''. $this->db->sql_escape($tag) . "'"; $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); return false; } @@ -74,7 +74,7 @@ class SemanticScuttle_Service_Tag extends SemanticScuttle_DbService $query.= ' WHERE tag = \'' . $this->db->sql_escape($tag) . "'"; $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); return false; } @@ -93,7 +93,7 @@ class SemanticScuttle_Service_Tag extends SemanticScuttle_DbService $query.= ' FROM '.$this->getTableName(); $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); return false; } @@ -114,7 +114,7 @@ class SemanticScuttle_Service_Tag extends SemanticScuttle_DbService } $this->db->sql_transaction('begin'); - if (!($dbresult = & $this->db->sql_query($query))) { + if (!($dbresult = $this->db->sql_query($query))) { $this->db->sql_transaction('rollback'); message_die(GENERAL_ERROR, 'Could not delete bookmarks', '', __LINE__, __FILE__, $query, $this->db); return false; diff --git a/src/SemanticScuttle/Service/Tag2Tag.php b/src/SemanticScuttle/Service/Tag2Tag.php index 33d211b..9dddc44 100644 --- a/src/SemanticScuttle/Service/Tag2Tag.php +++ b/src/SemanticScuttle/Service/Tag2Tag.php @@ -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'; } @@ -173,7 +173,7 @@ class SemanticScuttle_Service_Tag2Tag extends SemanticScuttle_DbService $query.= " AND uId = '".intval($uId)."'"; } //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); return false; } @@ -312,7 +312,7 @@ class SemanticScuttle_Service_Tag2Tag extends SemanticScuttle_DbService $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); return false; } @@ -337,7 +337,7 @@ class SemanticScuttle_Service_Tag2Tag extends SemanticScuttle_DbService $query.= " ORDER BY count DESC"; $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); 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($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); return false; } @@ -410,7 +410,7 @@ class SemanticScuttle_Service_Tag2Tag extends SemanticScuttle_DbService $query = 'DELETE FROM '. $this->getTableName(); $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); return false; } diff --git a/src/SemanticScuttle/Service/TagCache.php b/src/SemanticScuttle/Service/TagCache.php index b0ddfa6..0fdb986 100644 --- a/src/SemanticScuttle/Service/TagCache.php +++ b/src/SemanticScuttle/Service/TagCache.php @@ -72,7 +72,7 @@ class SemanticScuttle_Service_TagCache extends SemanticScuttle_DbService $query.= " AND uId = " . intval($uId); //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); return false; } @@ -101,7 +101,7 @@ class SemanticScuttle_Service_TagCache extends SemanticScuttle_DbService $values = array('tag1' => $tag1, 'tag2' => $tag2, 'relationType'=> '>', 'uId'=> $uId); $query = 'INSERT INTO '. $this->getTableName() .' '. $this->db->sql_build_array('INSERT', $values); //die($query); - if (!($dbresult =& $this->db->sql_query($query))) { + if (!($dbresult = $this->db->sql_query($query))) { $this->db->sql_transaction('rollback'); message_die(GENERAL_ERROR, 'Could not add tag cache inference', '', __LINE__, __FILE__, $query, $this->db); return false; @@ -122,7 +122,7 @@ class SemanticScuttle_Service_TagCache extends SemanticScuttle_DbService $query.= ' AND relationType = ">"'; $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); return false; } @@ -215,7 +215,7 @@ class SemanticScuttle_Service_TagCache extends SemanticScuttle_DbService $values = array('tag1' => $tag1, 'tag2' => $tag2, 'relationType'=> '=', 'uId'=> $uId); $query = 'INSERT INTO '. $this->getTableName() .' '. $this->db->sql_build_array('INSERT', $values); //die($query); - if (!($dbresult =& $this->db->sql_query($query))) { + if (!($dbresult = $this->db->sql_query($query))) { $this->db->sql_transaction('rollback'); message_die(GENERAL_ERROR, 'Could not add tag cache synonymy', '', __LINE__, __FILE__, $query, $this->db); return false; @@ -232,7 +232,7 @@ class SemanticScuttle_Service_TagCache extends SemanticScuttle_DbService $query.= ' AND relationType = "="'; $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); return false; } @@ -295,7 +295,7 @@ class SemanticScuttle_Service_TagCache extends SemanticScuttle_DbService $query.= " AND uId = " . intval($uId); //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); return false; } @@ -323,7 +323,7 @@ class SemanticScuttle_Service_TagCache extends SemanticScuttle_DbService $query.= " AND uId = " . intval($uId); $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); return false; } @@ -371,7 +371,7 @@ class SemanticScuttle_Service_TagCache extends SemanticScuttle_DbService function deleteByUser($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); return false; } diff --git a/src/SemanticScuttle/Service/TagStat.php b/src/SemanticScuttle/Service/TagStat.php index 23ebbc9..af8d110 100644 --- a/src/SemanticScuttle/Service/TagStat.php +++ b/src/SemanticScuttle/Service/TagStat.php @@ -67,7 +67,7 @@ class SemanticScuttle_Service_TagStat extends SemanticScuttle_DbService $query.= " AND relationType = '". $relationType ."'"; $query.= " AND uId = '".$uId."'"; - $dbresults =& $this->db->sql_query($query); + $dbresults = $this->db->sql_query($query); $row = $this->db->sql_fetchrow($dbresults); $this->db->sql_freeresult($dbresults); if($row['nb'] == null) { @@ -83,7 +83,7 @@ class SemanticScuttle_Service_TagStat extends SemanticScuttle_DbService $query.= " AND relationType = '". $relationType ."'"; $query.= " AND uId = '".$uId."'"; - $dbresults =& $this->db->sql_query($query); + $dbresults = $this->db->sql_query($query); $row = $this->db->sql_fetchrow($dbresults); $this->db->sql_freeresult($dbresults); if($row['depth'] == null) { @@ -99,7 +99,7 @@ class SemanticScuttle_Service_TagStat extends SemanticScuttle_DbService $query.= " AND relationType = '". $relationType ."'"; $query.= " AND uId = '".$uId."'"; - $dbresults =& $this->db->sql_query($query); + $dbresults = $this->db->sql_query($query); $row = $this->db->sql_fetchrow($dbresults); $this->db->sql_freeresult($dbresults); if($row['nbupdate'] == null) { @@ -161,7 +161,7 @@ class SemanticScuttle_Service_TagStat extends SemanticScuttle_DbService //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); return false; } @@ -215,7 +215,7 @@ class SemanticScuttle_Service_TagStat extends SemanticScuttle_DbService function deleteTagStatForUser($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__, __FILE__, $query, $this->db); return false; diff --git a/src/SemanticScuttle/Service/User.php b/src/SemanticScuttle/Service/User.php index 7550ed2..434e6b7 100644 --- a/src/SemanticScuttle/Service/User.php +++ b/src/SemanticScuttle/Service/User.php @@ -120,12 +120,12 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService if($nb>0) { $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); return false; } - while ($row = & $this->db->sql_fetchrow($dbresult)) { + while ($row = $this->db->sql_fetchrow($dbresult)) { $users[] = $row; } $this->db->sql_freeresult($dbresult); @@ -149,7 +149,7 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService $query .= ' LIMIT 0, ' . intval($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 @@ -158,7 +158,7 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService } $users = array(); - while ($row = & $this->db->sql_fetchrow($dbresult)) { + while ($row = $this->db->sql_fetchrow($dbresult)) { $users[] = new SemanticScuttle_Model_User( $row[$this->getFieldName('primary')], $row[$this->getFieldName('username')] @@ -434,7 +434,7 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService ')) = \''.$this->db->sql_escape($cook[1]).'\' AND '. $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( GENERAL_ERROR, 'Could not get user', '', __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. $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); return false; } @@ -606,7 +606,7 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService $this->db->sql_freeresult($dbresult); return $arrWatch; } - while ($row =& $this->db->sql_fetchrow($dbresult)) { + while ($row = $this->db->sql_fetchrow($dbresult)) { $arrWatch[] = $row['watched']; } $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. $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); return false; } @@ -690,7 +690,7 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService if ($watched) { $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'); message_die(GENERAL_ERROR, 'Could not add user to watch list', '', __LINE__, __FILE__, $sql, $this->db); return false; @@ -701,7 +701,7 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService 'watched' => intval($subjectUserID) ); $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'); message_die(GENERAL_ERROR, 'Could not add user to watch list', '', __LINE__, __FILE__, $sql, $this->db); return false; @@ -743,7 +743,7 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService // Execute the statement. $this->db->sql_transaction('begin'); - if (!($dbresult = & $this->db->sql_query($sql))) { + if (!($dbresult = $this->db->sql_query($sql))) { $this->db->sql_transaction('rollback'); message_die( GENERAL_ERROR, 'Could not insert user', @@ -826,7 +826,7 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService // Execute the statement. $this->db->sql_transaction('begin'); - if (!($dbresult = & $this->db->sql_query($sql))) { + if (!($dbresult = $this->db->sql_query($sql))) { $this->db->sql_transaction('rollback'); message_die( GENERAL_ERROR, 'Could not update user', '', @@ -845,7 +845,7 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService function getAllUsers ( ) { $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); return false; } @@ -872,7 +872,7 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService function deleteUser($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); return false; } diff --git a/src/SemanticScuttle/functions.php b/src/SemanticScuttle/functions.php index 09f7cf3..802a7f1 100644 --- a/src/SemanticScuttle/functions.php +++ b/src/SemanticScuttle/functions.php @@ -276,4 +276,17 @@ function message_die($msg_code, $msg_text = '', $msg_title = '', $err_line = '', echo "\n\n". $msg_title ."\n

\n". $msg_text ."\n"; 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); +} ?> -- cgit v1.2.3