Skip to content

Commit 64c2e89

Browse files
committed
Refresh statistics when creating users
1 parent 1fd5363 commit 64c2e89

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

controllers/Credits.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function run(Router &$router) {
3535

3636
protected function getCredits(CreditsModel &$model) {
3737
$credits = new CreditsLib();
38-
$model->total_users = $credits->getTotalUsers();
38+
$model->total_users = CreditsLib::getTotalUsers();
3939
$model->top_contributors_by_documents
4040
= &$credits->getTopContributorsByDocuments();
4141
$model->top_contributors_by_news_posts

controllers/User/Register.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
use \BNETDocs\Libraries\CSRF;
66
use \BNETDocs\Libraries\Common;
77
use \BNETDocs\Libraries\Controller;
8+
use \BNETDocs\Libraries\Exceptions\QueryException;
89
use \BNETDocs\Libraries\Exceptions\RecaptchaException;
910
use \BNETDocs\Libraries\Exceptions\UnspecifiedViewException;
1011
use \BNETDocs\Libraries\Exceptions\UserNotFoundException;
11-
use \BNETDocs\Libraries\Exceptions\QueryException;
1212
use \BNETDocs\Libraries\Logger;
1313
use \BNETDocs\Libraries\Router;
1414
use \BNETDocs\Libraries\User;

libraries/Credits.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111

1212
class Credits {
1313

14-
public function &getTotalUsers() {
14+
public static function &getTotalUsers($no_cache = false) {
1515
$cache_key = "bnetdocs-credits-totalusers";
1616
$cache_val = Common::$cache->get($cache_key);
17-
if ($cache_val !== false) return (int) $cache_val;
17+
if (!$no_cache && $cache_val !== false) return (int) $cache_val;
1818
if (!isset(Common::$database)) {
1919
Common::$database = DatabaseDriver::getDatabaseObject();
2020
}

libraries/User.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use \BNETDocs\Libraries\Cache;
66
use \BNETDocs\Libraries\Common;
7+
use \BNETDocs\Libraries\Credits;
78
use \BNETDocs\Libraries\Database;
89
use \BNETDocs\Libraries\DatabaseDriver;
910
use \BNETDocs\Libraries\Exceptions\QueryException;
@@ -157,6 +158,7 @@ public static function create(
157158
} catch (PDOException $e) {
158159
throw new QueryException("Cannot create user", $e);
159160
} finally {
161+
Credits::getTotalUsers(true); // Refresh statistics
160162
return $successful;
161163
}
162164
}

0 commit comments

Comments
 (0)