Skip to content

Commit

Permalink
Merge branch 'release/4.2.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Schlaefer committed Sep 14, 2014
2 parents 81d40c1 + cf2ce2e commit 57ef342
Show file tree
Hide file tree
Showing 15 changed files with 111 additions and 110 deletions.
2 changes: 1 addition & 1 deletion app/Config/version.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
Configure::write('Saito.v', '4.2.0');
Configure::write('Saito.v', '4.2.1');

Configure::write('Saito.saitoHomepage', 'http://saito.siezi.com');
2 changes: 1 addition & 1 deletion app/Controller/CategoriesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function admin_delete($id = null) {
endif; // move or delete category

/* get categories for target <select> */
$categories = $this->Category->getCategoriesSelectForAccession(0);
$categories = $this->CurrentUser->Categories->getAllowed('list');
unset($categories[$id]);
$this->set('targetCategory', $categories);

Expand Down
38 changes: 20 additions & 18 deletions app/Controller/EntriesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -819,35 +819,37 @@ protected function _setNotifications($newEntry) {
}
}

/**
* Gets the thread ids of all threads which should be visisble on the an
* entries/index/# page.
*
* @param CurrentUserComponent $User
* @return array
*/
/**
* Gets thread ids for paginated entries/index.
*
* @param CurrentUserComponent $User
* @param array $order sort order
* @return array thread ids
*/
protected function _getInitialThreads(CurrentUserComponent $User, $order) {
Stopwatch::start('Entries->_getInitialThreads() Paginate');

$categories = $this->_setupCategoryChooser($User);

$this->paginate = array(
/* Whenever you change the conditions here check if you have to adjust
* the db index. Running this query without appropriate db index is a huge
* performance bottleneck!
*/
'conditions' => array(
'pid' => 0,
'Entry.category' => $categories
),
//! Check DB performance after changing conditions/sorting!
$this->paginate = [
'conditions' => [
'pid' => 0,
'Entry.category' => $categories
],
'contain' => false,
'fields' => 'id, pid, tid, time, last_answer, fixed',
'limit' => Configure::read('Saito.Settings.topics_per_page'),
'order' => $order,
'getInitialThreads' => 1,
);
];

$initialThreads = $this->paginate();
// disallows overwriting pagination params from request
unset(
$this->request->params['named']['direction'],
$this->request->params['named']['sort']
);
$initialThreads = $this->paginate(null, null, array_keys($order));

$initialThreadsNew = [];
foreach ($initialThreads as $k => $v) {
Expand Down
7 changes: 6 additions & 1 deletion app/Controller/SearchesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,12 @@ public function advanced() {
->Categories->getAllowed();
}
$this->Paginator->settings = $settings;
$this->set('results', $this->Paginator->paginate());
unset(
$this->request->query['direction'],
$this->request->query['sort']
);
$this->set('results',
$this->Paginator->paginate(null, null, ['Entry.time']));
}

if (!isset($query['category'])) {
Expand Down
20 changes: 14 additions & 6 deletions app/Controller/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,17 +177,25 @@ public function admin_index() {
}

public function index() {
$menuItems = [
'username' => [__('username_marking'), []],
'user_type' => [__('user_type'), []],
'UserOnline.logged_in' => [__('userlist_online'), ['direction' => 'desc']],
'registered' => [__('registered'), ['direction' => 'desc']]
];
$showBlocked = Configure::read('Saito.Settings.block_user_ui');
if ($showBlocked) {
$menuItems['user_lock'] = [__('user.set.lock.t'), ['direction' => 'desc']];
}

$this->paginate = [
'contain' => 'UserOnline',
'limit' => 400,
'order' => [
'UserOnline.logged_in' => 'asc',
'User.username' => 'asc'
]
'order' => ['UserOnline.logged_in' => 'desc', 'User.username' => 'asc']
];
$users = $this->paginate('User', null, array_keys($menuItems));

$data = $this->paginate('User');
$this->set('users', $data);
$this->set(compact('menuItems', 'users'));
}

public function ignore($blockedId) {
Expand Down
15 changes: 7 additions & 8 deletions app/Lib/Cache/CacheSupport.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __construct() {
foreach ($this->_buildInCaches as $_name) {
$this->add(new $_name);
}
CakeEventManager::instance()->instance($this);
CakeEventManager::instance()->attach($this);
}

public function implementedEvents() {
Expand Down Expand Up @@ -57,7 +57,9 @@ public function clear($cache = null, $id = null) {
$_Cache->clear();
}
} else {
$this->_Caches[$cache]->clear($id);
if (isset($this->_Caches[$cache])) {
$this->_Caches[$cache]->clear($id);
}
}
}

Expand All @@ -83,15 +85,16 @@ public function getId();
abstract class CacheSupportCachelet implements CacheSupportCacheletInterface {

public function getId() {
if (!empty($this->_title)) {
return $this->_title;
}
return str_replace('CacheSupportCachelet', '', get_class($this));
}

}

class SaitoCacheSupportCachelet extends CacheSupportCachelet {

protected $_title = 'Saito';

public function clear($id = null) {
Cache::clear(false, 'default');
Cache::clear(false, 'short');
Expand All @@ -101,8 +104,6 @@ public function clear($id = null) {

class ApcCacheSupportCachelet extends CacheSupportCachelet {

protected $_title = 'Apc';

public function clear($id = null) {
if (function_exists('apc_store')) {
apc_clear_cache();
Expand All @@ -115,8 +116,6 @@ public function clear($id = null) {

class OpCacheSupportCachelet extends CacheSupportCachelet {

protected $_title = 'OpCache';

public function clear($id = null) {
if (function_exists('opcache_reset')) {
opcache_reset();
Expand Down
14 changes: 9 additions & 5 deletions app/Lib/Model/AppSettingModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@

class AppSettingModel extends AppModel {

/**
* afterSave callback
*
* @param bool $created
* @param array $options
* - 'clearCache' set to 'false' to prevent cache clearing
*/
public function afterSave($created, $options = []) {
parent::afterSave($created, $options);
if (isset($options['clearCache'])) {
if ($options['clearCache'] === false) {
return;
}
if (!isset($options['clearCache']) || $options['clearCache'] !== false) {
$this->clearCache();
}
$this->clearCache();
}

public function afterDelete() {
Expand Down
2 changes: 1 addition & 1 deletion app/Locale/deu/LC_MESSAGES/default.po
Original file line number Diff line number Diff line change
Expand Up @@ -1244,7 +1244,7 @@ msgstr "Der Zugriff auf diese Funktion ist eingeschränkt!"
#: Controller/Component/EmailNotificationComponent.php:48
#, php-format
msgid "New reply to \"%s\""
msgstr "Neu Antwort zu \"%s\""
msgstr "Neue Antwort zu \"%s\""

#: Controller/Component/EmailNotificationComponent.php:82
msgid "Successfull registration"
Expand Down
4 changes: 1 addition & 3 deletions app/Model/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@ public function updateThreadCounter() {

public function afterSave($created, $options = array()) {
// don't empty cache if it's only a thread count update
if (isset($this->data[$this->alias]['thread_count']) ||
!isset($this->data[$this->alias]['category'])
) {
if (!$created && !isset($this->data[$this->alias]['category'])) {
$options['clearCache'] = false;
}
parent::afterSave($created, $options);
Expand Down
2 changes: 1 addition & 1 deletion app/Test/Case/Controller/EntriesControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class EntriesMockController extends EntriesController {
public $uses = array('Entry');
// @codingStandardsIgnoreEnd

public function getInitialThreads($User, $order = 'Entry.last_answer DESC') {
public function getInitialThreads($User, $order = ['Entry.last_answer' => 'DESC']) {
$this->_getInitialThreads($User, $order);
}

Expand Down
11 changes: 8 additions & 3 deletions app/View/Helper/EntryHHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,18 @@ public function categorySelect($entry, $categories) {
* Everything you do in here is in worst case done a few hundred times on
* the frontpage. Think about (and benchmark) performance before you change it.
*/
public function threadCached(array $entrySub, ForumsUserInterface $CurrentUser, $level = 0, array $currentEntry = [], $lastAnswer = null) {
public function threadCached(array $entrySub, ForumsUserInterface $CurrentUser, $level = 0, array $currentEntry = [], $lastAnswer = null, $options = []) {
$options = $options + ['ignore' => null];
$id = (int)$entrySub['Entry']['id'];
$out = '';
if ($lastAnswer === null) {
$lastAnswer = $entrySub['Entry']['last_answer'];
}

if (!$CurrentUser->ignores($entrySub['Entry']['user_id'])) {
if ($options['ignore'] === null) {
$options['ignore'] = $CurrentUser->ignores($entrySub['Entry']['user_id']);
}
if (!$options['ignore']) {
$useLineCache = $level > 0;
if ($useLineCache) {
$_threadLineCached = $this->_LineCache->get($id);
Expand Down Expand Up @@ -251,8 +255,9 @@ class='link_show_thread {$id} et threadLine-content'>
if (isset($entrySub['_children'])) {
$subLevel = $level + 1;
$sub = '';
unset($options['ignore']);
foreach ($entrySub['_children'] as $child) {
$sub .= $this->threadCached($child, $CurrentUser, $subLevel, $currentEntry, $lastAnswer);
$sub .= $this->threadCached($child, $CurrentUser, $subLevel, $currentEntry, $lastAnswer, $options);
}
$out .= '<li>' . $this->_wrapUl($sub, $subLevel) . '</li>';
}
Expand Down
26 changes: 5 additions & 21 deletions app/View/Users/index.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,10 @@
<div class="panel-content">
<div class="table-menu sort-menu">
<?php
$_sortBy = $this->Paginator->sort('username', __('username_marking'));
$_sortBy .= ', ' . $this->Paginator->sort('User.user_type',
__('user_type'));
$_sortBy .= ', ' . $this->Paginator->sort('UserOnline.user_id',
__('userlist_online'),
[
'direction' => 'desc'
]);
$_sortBy .= ', ' . $this->Paginator->sort('registered',
__('registered'),
[
'direction' => 'desc'
]);
$_showBlocked = Configure::read('Saito.Settings.block_user_ui');
if ($_showBlocked) {
$_sortBy .= ', ' . $this->Paginator->sort('user_lock',
__('user.set.lock.t'),
['direction' => 'desc']);
}
echo __('Sort by: %s', $_sortBy);
foreach ($menuItems as $title => $mi) {
$menu[] = $this->Paginator->sort($title, $mi[0], $mi[1]);
}
echo __('Sort by: %s', implode(', ', $menu));
?>
</div>
<table class="table th-left row-sep">
Expand All @@ -57,7 +41,7 @@
if ($user['UserOnline']['logged_in']) {
$_u[] = __('Online');
}
if ($_showBlocked && $user['User']['user_lock']) {
if (!empty($user['User']['user_lock'])) {
$_u[] = __('%s banned',
$this->UserH->banned($user['User']['user_lock']));
}
Expand Down
3 changes: 2 additions & 1 deletion app/View/Users/view.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,8 @@
<ul class="threadCollection-node root">
<?php foreach ($lastEntries as $entry): ?>
<li>
<?= $this->EntryH->threadCached($entry, $CurrentUser); ?>
<?= $this->EntryH->threadCached($entry, $CurrentUser, 0, [], null,
['ignore' => false]); ?>
</li>
<?php endforeach; ?>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"require": {
"php": ">=5.4.0",
"ext-mcrypt": "*",
"pear-cakephp/cakephp": "2.5.3",
"pear-cakephp/cakephp": "2.5.4",
"kzykhys/ciconia": "~1.0.3",
"jbbcode/jbbcode": "~1.3"
},
Expand Down
Loading

0 comments on commit 57ef342

Please sign in to comment.