Skip to content

Commit 2b72cf3

Browse files
committed
Fix E_NOTICE error with Credits library
{ "error": { "exception": null, "code": "E_NOTICE", "message": "Only variable references should be returned by reference", "file": "\/home\/nginx\/bnetdocs-www\/libraries\/Credits.php", "line": 17 } }
1 parent 49499b6 commit 2b72cf3

File tree

1 file changed

+36
-9
lines changed

1 file changed

+36
-9
lines changed

libraries/Credits.php

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ class Credits {
1414
public static function &getTotalUsers($no_cache = false) {
1515
$cache_key = "bnetdocs-credits-totalusers";
1616
$cache_val = Common::$cache->get($cache_key);
17-
if (!$no_cache && $cache_val !== false) return (int) $cache_val;
17+
if (!$no_cache && $cache_val !== false) {
18+
$cache_val = (int) $cache_val;
19+
return $cache_val;
20+
}
1821
if (!isset(Common::$database)) {
1922
Common::$database = DatabaseDriver::getDatabaseObject();
2023
}
@@ -32,7 +35,10 @@ public static function &getTotalUsers($no_cache = false) {
3235
public function &getTopContributorsByDocuments() {
3336
$cache_key = "bnetdocs-credits-documents";
3437
$cache_val = Common::$cache->get($cache_key);
35-
if ($cache_val !== false) return unserialize($cache_val);
38+
if ($cache_val !== false) {
39+
$cache_val = unserialize($cache_val);
40+
return $cache_val;
41+
}
3642
if (!isset(Common::$database)) {
3743
Common::$database = DatabaseDriver::getDatabaseObject();
3844
}
@@ -68,7 +74,10 @@ public function &getTopContributorsByDocuments() {
6874
public function &getTopContributorsByNewsPosts() {
6975
$cache_key = "bnetdocs-credits-newsposts";
7076
$cache_val = Common::$cache->get($cache_key);
71-
if ($cache_val !== false) return unserialize($cache_val);
77+
if ($cache_val !== false) {
78+
$cache_val = unserialize($cache_val);
79+
return $cache_val;
80+
}
7281
if (!isset(Common::$database)) {
7382
Common::$database = DatabaseDriver::getDatabaseObject();
7483
}
@@ -104,7 +113,10 @@ public function &getTopContributorsByNewsPosts() {
104113
public function &getTopContributorsByPackets() {
105114
$cache_key = "bnetdocs-credits-packets";
106115
$cache_val = Common::$cache->get($cache_key);
107-
if ($cache_val !== false) return unserialize($cache_val);
116+
if ($cache_val !== false) {
117+
$cache_val = unserialize($cache_val);
118+
return $cache_val;
119+
}
108120
if (!isset(Common::$database)) {
109121
Common::$database = DatabaseDriver::getDatabaseObject();
110122
}
@@ -140,7 +152,10 @@ public function &getTopContributorsByPackets() {
140152
public function &getTopContributorsByServers() {
141153
$cache_key = "bnetdocs-credits-servers";
142154
$cache_val = Common::$cache->get($cache_key);
143-
if ($cache_val !== false) return unserialize($cache_val);
155+
if ($cache_val !== false) {
156+
$cache_val = unserialize($cache_val);
157+
return $cache_val;
158+
}
144159
if (!isset(Common::$database)) {
145160
Common::$database = DatabaseDriver::getDatabaseObject();
146161
}
@@ -176,7 +191,10 @@ public function &getTopContributorsByServers() {
176191
public static function getTotalDocumentsByUserId($user_id) {
177192
$cache_key = "bnetdocs-credits-documentsbyuserid-" . (int) $user_id;
178193
$cache_val = Common::$cache->get($cache_key);
179-
if ($cache_val !== false) return (int) $cache_val;
194+
if ($cache_val !== false) {
195+
$cache_val = (int) $cache_val;
196+
return $cache_val;
197+
}
180198
if (!isset(Common::$database)) {
181199
Common::$database = DatabaseDriver::getDatabaseObject();
182200
}
@@ -194,7 +212,10 @@ public static function getTotalDocumentsByUserId($user_id) {
194212
public static function getTotalNewsPostsByUserId($user_id) {
195213
$cache_key = "bnetdocs-credits-newspostsbyuserid-" . (int) $user_id;
196214
$cache_val = Common::$cache->get($cache_key);
197-
if ($cache_val !== false) return (int) $cache_val;
215+
if ($cache_val !== false) {
216+
$cache_val = (int) $cache_val;
217+
return $cache_val;
218+
}
198219
if (!isset(Common::$database)) {
199220
Common::$database = DatabaseDriver::getDatabaseObject();
200221
}
@@ -212,7 +233,10 @@ public static function getTotalNewsPostsByUserId($user_id) {
212233
public static function getTotalPacketsByUserId($user_id) {
213234
$cache_key = "bnetdocs-credits-packetsbyuserid-" . (int) $user_id;
214235
$cache_val = Common::$cache->get($cache_key);
215-
if ($cache_val !== false) return (int) $cache_val;
236+
if ($cache_val !== false) {
237+
$cache_val = (int) $cache_val;
238+
return $cache_val;
239+
}
216240
if (!isset(Common::$database)) {
217241
Common::$database = DatabaseDriver::getDatabaseObject();
218242
}
@@ -230,7 +254,10 @@ public static function getTotalPacketsByUserId($user_id) {
230254
public static function getTotalServersByUserId($user_id) {
231255
$cache_key = "bnetdocs-credits-serversbyuserid-" . (int) $user_id;
232256
$cache_val = Common::$cache->get($cache_key);
233-
if ($cache_val !== false) return (int) $cache_val;
257+
if ($cache_val !== false) {
258+
$cache_val = (int) $cache_val;
259+
return $cache_val;
260+
}
234261
if (!isset(Common::$database)) {
235262
Common::$database = DatabaseDriver::getDatabaseObject();
236263
}

0 commit comments

Comments
 (0)