diff --git a/app/Config/version.php b/app/Config/version.php index 1826ac93a..cec29ae88 100644 --- a/app/Config/version.php +++ b/app/Config/version.php @@ -1,4 +1,4 @@ */ - $categories = $this->Category->getCategoriesSelectForAccession(0); + $categories = $this->CurrentUser->Categories->getAllowed('list'); unset($categories[$id]); $this->set('targetCategory', $categories); diff --git a/app/Controller/EntriesController.php b/app/Controller/EntriesController.php index efd71af37..2db382364 100644 --- a/app/Controller/EntriesController.php +++ b/app/Controller/EntriesController.php @@ -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) { diff --git a/app/Controller/SearchesController.php b/app/Controller/SearchesController.php index 164cd498b..bb50407c6 100644 --- a/app/Controller/SearchesController.php +++ b/app/Controller/SearchesController.php @@ -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'])) { diff --git a/app/Controller/UsersController.php b/app/Controller/UsersController.php index ad274ff98..5cb17aed9 100644 --- a/app/Controller/UsersController.php +++ b/app/Controller/UsersController.php @@ -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) { diff --git a/app/Lib/Cache/CacheSupport.php b/app/Lib/Cache/CacheSupport.php index 0c9533359..879326d4d 100644 --- a/app/Lib/Cache/CacheSupport.php +++ b/app/Lib/Cache/CacheSupport.php @@ -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() { @@ -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); + } } } @@ -83,6 +85,9 @@ 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)); } @@ -90,8 +95,6 @@ public function getId() { class SaitoCacheSupportCachelet extends CacheSupportCachelet { - protected $_title = 'Saito'; - public function clear($id = null) { Cache::clear(false, 'default'); Cache::clear(false, 'short'); @@ -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(); @@ -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(); diff --git a/app/Lib/Model/AppSettingModel.php b/app/Lib/Model/AppSettingModel.php index 0605de334..123501a3f 100644 --- a/app/Lib/Model/AppSettingModel.php +++ b/app/Lib/Model/AppSettingModel.php @@ -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() { diff --git a/app/Locale/deu/LC_MESSAGES/default.po b/app/Locale/deu/LC_MESSAGES/default.po index b58bfc992..33ec4a0e1 100644 --- a/app/Locale/deu/LC_MESSAGES/default.po +++ b/app/Locale/deu/LC_MESSAGES/default.po @@ -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" diff --git a/app/Model/Category.php b/app/Model/Category.php index e17eefad2..6e7bea2d6 100755 --- a/app/Model/Category.php +++ b/app/Model/Category.php @@ -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); diff --git a/app/Test/Case/Controller/EntriesControllerTest.php b/app/Test/Case/Controller/EntriesControllerTest.php index 6c10397f0..b856840d4 100755 --- a/app/Test/Case/Controller/EntriesControllerTest.php +++ b/app/Test/Case/Controller/EntriesControllerTest.php @@ -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); } diff --git a/app/View/Helper/EntryHHelper.php b/app/View/Helper/EntryHHelper.php index 43c5e6511..1a3cdc01a 100755 --- a/app/View/Helper/EntryHHelper.php +++ b/app/View/Helper/EntryHHelper.php @@ -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); @@ -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 .= '
  • ' . $this->_wrapUl($sub, $subLevel) . '
  • '; } diff --git a/app/View/Users/index.ctp b/app/View/Users/index.ctp index ad3dda425..bd8bfed9f 100755 --- a/app/View/Users/index.ctp +++ b/app/View/Users/index.ctp @@ -12,26 +12,10 @@
    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)); ?>
    @@ -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'])); } diff --git a/app/View/Users/view.ctp b/app/View/Users/view.ctp index 3fab427c1..9275b7167 100644 --- a/app/View/Users/view.ctp +++ b/app/View/Users/view.ctp @@ -273,7 +273,8 @@ diff --git a/composer.json b/composer.json index f85721cc9..db3a3f797 100644 --- a/composer.json +++ b/composer.json @@ -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" }, diff --git a/composer.lock b/composer.lock index 59343ef0e..eec3053b1 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "08666d4ef7841ee6e3079fc974feb69e", + "hash": "f75f051ef37be4121f47bda6fdbfd7b5", "packages": [ { "name": "jbbcode/jbbcode", @@ -109,10 +109,10 @@ }, { "name": "pear-pear.cakephp.org/CakePHP", - "version": "2.5.3", + "version": "2.5.4", "dist": { "type": "file", - "url": "http://pear.cakephp.org/get/CakePHP-2.5.3.tgz", + "url": "http://pear.cakephp.org/get/CakePHP-2.5.4.tgz", "reference": null, "shasum": null }, @@ -120,7 +120,7 @@ "php": ">=5.2.8.0" }, "replace": { - "pear-cakephp/cakephp": "== 2.5.3.0" + "pear-cakephp/cakephp": "== 2.5.4.0" }, "type": "pear-library", "autoload": { @@ -135,17 +135,17 @@ }, { "name": "symfony/console", - "version": "v2.4.8", + "version": "v2.4.9", "target-dir": "Symfony/Component/Console", "source": { "type": "git", "url": "https://github.com/symfony/Console.git", - "reference": "29ef7af8aa6e3c015445f34291ccab9b8019085b" + "reference": "6cdbe19f8f9025a84ccc45c3870e388e424bea5c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Console/zipball/29ef7af8aa6e3c015445f34291ccab9b8019085b", - "reference": "29ef7af8aa6e3c015445f34291ccab9b8019085b", + "url": "https://api.github.com/repos/symfony/Console/zipball/6cdbe19f8f9025a84ccc45c3870e388e424bea5c", + "reference": "6cdbe19f8f9025a84ccc45c3870e388e424bea5c", "shasum": "" }, "require": { @@ -173,24 +173,22 @@ "MIT" ], "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": "http://fabien.potencier.org", - "role": "Lead Developer" - }, { "name": "Symfony Community", "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony Console Component", "homepage": "http://symfony.com", - "time": "2014-07-09 12:44:38" + "time": "2014-08-14 14:51:32" }, { "name": "symfony/options-resolver", - "version": "v2.4.8", + "version": "v2.4.9", "target-dir": "Symfony/Component/OptionsResolver", "source": { "type": "git", @@ -222,15 +220,13 @@ "MIT" ], "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": "http://fabien.potencier.org", - "role": "Lead Developer" - }, { "name": "Symfony Community", "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony OptionsResolver Component", @@ -246,23 +242,23 @@ "packages-dev": [ { "name": "phpunit/php-code-coverage", - "version": "1.2.17", + "version": "1.2.18", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "6ef2bf3a1c47eca07ea95f0d8a902a6340390b34" + "reference": "fe2466802556d3fe4e4d1d58ffd3ccfd0a19be0b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/6ef2bf3a1c47eca07ea95f0d8a902a6340390b34", - "reference": "6ef2bf3a1c47eca07ea95f0d8a902a6340390b34", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/fe2466802556d3fe4e4d1d58ffd3ccfd0a19be0b", + "reference": "fe2466802556d3fe4e4d1d58ffd3ccfd0a19be0b", "shasum": "" }, "require": { "php": ">=5.3.3", "phpunit/php-file-iterator": ">=1.3.0@stable", "phpunit/php-text-template": ">=1.2.0@stable", - "phpunit/php-token-stream": ">=1.1.3@stable" + "phpunit/php-token-stream": ">=1.1.3,<1.3.0" }, "require-dev": { "phpunit/phpunit": "3.7.*@dev" @@ -303,7 +299,7 @@ "testing", "xunit" ], - "time": "2014-03-28 10:53:45" + "time": "2014-09-02 10:13:14" }, { "name": "phpunit/php-file-iterator", @@ -612,17 +608,17 @@ }, { "name": "symfony/yaml", - "version": "v2.5.2", + "version": "v2.5.4", "target-dir": "Symfony/Component/Yaml", "source": { "type": "git", "url": "https://github.com/symfony/Yaml.git", - "reference": "f868ecdbcc0276b6158dfbf08b9e98ce07f014e1" + "reference": "01a7695bcfb013d0a15c6757e15aae120342986f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Yaml/zipball/f868ecdbcc0276b6158dfbf08b9e98ce07f014e1", - "reference": "f868ecdbcc0276b6158dfbf08b9e98ce07f014e1", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/01a7695bcfb013d0a15c6757e15aae120342986f", + "reference": "01a7695bcfb013d0a15c6757e15aae120342986f", "shasum": "" }, "require": { @@ -644,20 +640,18 @@ "MIT" ], "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": "http://fabien.potencier.org", - "role": "Lead Developer" - }, { "name": "Symfony Community", "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony Yaml Component", "homepage": "http://symfony.com", - "time": "2014-07-09 09:05:48" + "time": "2014-08-31 03:22:04" } ], "aliases": [ @@ -667,6 +661,7 @@ "stability-flags": [ ], + "prefer-stable": false, "platform": { "php": ">=5.4.0", "ext-mcrypt": "*"