diff --git a/protected/humhub/docs/CHANGELOG.md b/protected/humhub/docs/CHANGELOG.md index ac1fddea79..7b2691f21c 100644 --- a/protected/humhub/docs/CHANGELOG.md +++ b/protected/humhub/docs/CHANGELOG.md @@ -81,6 +81,7 @@ HumHub Change Log - Enh: Made admin base controller method "getAccessRules()" non static - Enh: Created new ImageController for user image and banner handling - Enh: Decreased OEmbed url max length 180chars (acs-ferreira) +- Enh: Added APCu Support 1.2.0-beta.2 (February 24, 2017) -------------------------------- diff --git a/protected/humhub/libs/DynamicConfig.php b/protected/humhub/libs/DynamicConfig.php index a5eb54fdb2..45e961ed75 100644 --- a/protected/humhub/libs/DynamicConfig.php +++ b/protected/humhub/libs/DynamicConfig.php @@ -11,7 +11,6 @@ namespace humhub\libs; use Yii; use yii\helpers\ArrayHelper; - /** * DynamicConfig provides access to the dynamic configuration file. * @@ -109,12 +108,19 @@ class DynamicConfig extends \yii\base\Object // Add Caching $cacheClass = Yii::$app->settings->get('cache.class'); - if (in_array($cacheClass, ['yii\caching\DummyCache', 'yii\caching\ApcCache', 'yii\caching\FileCache'])) { + if (in_array($cacheClass, ['yii\caching\DummyCache', 'yii\caching\FileCache'])) { $config['components']['cache'] = [ 'class' => $cacheClass, 'keyPrefix' => Yii::$app->id ]; + } elseif ($cacheClass == 'yii\caching\ApcCache' && (function_exists('apcu_add') || function_exists('apc_add'))) { + $config['components']['cache'] = [ + 'class' => $cacheClass, + 'keyPrefix' => Yii::$app->id, + 'useApcu' => (function_exists('apcu_add')) + ]; } + // Add User settings $config['components']['user'] = array(); if (Yii::$app->getModule('user')->settings->get('auth.defaultUserIdleTimeoutSec')) { @@ -133,7 +139,7 @@ class DynamicConfig extends \yii\base\Object if (Yii::$app->settings->get('mailer.username')) { $mail['transport']['username'] = Yii::$app->settings->get('mailer.username'); - } else if(!Yii::$app->settings->get('mailer.password')) { + } else if (!Yii::$app->settings->get('mailer.password')) { $mail['transport']['authMode'] = 'null'; } @@ -163,7 +169,7 @@ class DynamicConfig extends \yii\base\Object $config['components']['mailer'] = $mail; $config = ArrayHelper::merge($config, ThemeHelper::getThemeConfig(Yii::$app->settings->get('theme'))); $config['params']['config_created_at'] = time(); - + $config['params']['horImageScrollOnMobile'] = Yii::$app->settings->get('horImageScrollOnMobile'); self::save($config); diff --git a/protected/humhub/libs/SelfTest.php b/protected/humhub/libs/SelfTest.php index 37bee09f90..24d4aef44e 100644 --- a/protected/humhub/libs/SelfTest.php +++ b/protected/humhub/libs/SelfTest.php @@ -204,7 +204,7 @@ class SelfTest } // Checks APC Extension - $title = 'PHP - APC Support'; + $title = 'PHP - APC(u) Support'; if (function_exists('apc_add') || function_exists('apcu_add')) { $checks[] = array( 'title' => Yii::t('base', $title), @@ -214,7 +214,7 @@ class SelfTest $checks[] = array( 'title' => Yii::t('base', $title), 'state' => 'WARNING', - 'hint' => 'Optional - Install APC Extension for APC Caching' + 'hint' => 'Optional - Install APCu Extension for APC Caching' ); } diff --git a/protected/humhub/modules/admin/controllers/SettingController.php b/protected/humhub/modules/admin/controllers/SettingController.php index 7da50ce3d4..58e4fc45ff 100644 --- a/protected/humhub/modules/admin/controllers/SettingController.php +++ b/protected/humhub/modules/admin/controllers/SettingController.php @@ -110,13 +110,7 @@ class SettingController extends Controller return $this->redirect(['/admin/setting/caching']); } - $cacheTypes = array( - 'yii\caching\DummyCache' => Yii::t('AdminModule.controllers_SettingController', 'No caching (Testing only!)'), - 'yii\caching\FileCache' => Yii::t('AdminModule.controllers_SettingController', 'File'), - 'yii\caching\ApcCache' => Yii::t('AdminModule.controllers_SettingController', 'APC'), - ); - - return $this->render('caching', array('model' => $form, 'cacheTypes' => $cacheTypes)); + return $this->render('caching', array('model' => $form, 'cacheTypes' => $form->getTypes())); } /** @@ -197,20 +191,20 @@ class SettingController extends Controller $maxUploadSize = \humhub\libs\Helpers::GetBytesOfPHPIniValue(ini_get('post_max_size')); $fileSizeKey = 'post_max_size'; } - + $maxUploadSize = floor($maxUploadSize / 1024 / 1024); - $maxUploadSizeText = "(".$fileSizeKey."): ".$maxUploadSize; - + $maxUploadSizeText = "(" . $fileSizeKey . "): " . $maxUploadSize; + // Determine currently used ImageLibary $currentImageLibary = 'GD'; if (Yii::$app->getModule('file')->settings->get('imageMagickPath')) { $currentImageLibary = 'ImageMagick'; } - return $this->render('file', ['model' => $form, - 'maxUploadSize' => $maxUploadSize, - 'maxUploadSizeText' => $maxUploadSizeText, - 'currentImageLibary' => $currentImageLibary]); + return $this->render('file', ['model' => $form, + 'maxUploadSize' => $maxUploadSize, + 'maxUploadSizeText' => $maxUploadSizeText, + 'currentImageLibary' => $currentImageLibary]); } /** @@ -242,9 +236,9 @@ class SettingController extends Controller { $logsCount = Log::find()->count(); $dating = Log::find() - ->orderBy('log_time', 'asc') - ->limit(1) - ->one(); + ->orderBy('log_time', 'asc') + ->limit(1) + ->one(); // I wish.. if ($dating) { @@ -264,10 +258,10 @@ class SettingController extends Controller } return $this->render('logs', array( - 'logsCount' => $logsCount, - 'model' => $form, - 'limitAgeOptions' => $limitAgeOptions, - 'dating' => $dating + 'logsCount' => $logsCount, + 'model' => $form, + 'limitAgeOptions' => $limitAgeOptions, + 'dating' => $dating )); } diff --git a/protected/humhub/modules/admin/models/forms/CacheSettingsForm.php b/protected/humhub/modules/admin/models/forms/CacheSettingsForm.php index 8a0d4e2c46..60aadc0a8c 100644 --- a/protected/humhub/modules/admin/models/forms/CacheSettingsForm.php +++ b/protected/humhub/modules/admin/models/forms/CacheSettingsForm.php @@ -58,9 +58,9 @@ class CacheSettingsForm extends Model public function getTypes() { return array( - 'yii\caching\DummyCache' => \Yii::t('AdminModule.forms_CacheSettingsForm', 'No caching (Testing only!)'), + 'yii\caching\DummyCache' => \Yii::t('AdminModule.forms_CacheSettingsForm', 'No caching'), 'yii\caching\FileCache' => \Yii::t('AdminModule.forms_CacheSettingsForm', 'File'), - 'yii\caching\ApcCache' => \Yii::t('AdminModule.forms_CacheSettingsForm', 'APC'), + 'yii\caching\ApcCache' => \Yii::t('AdminModule.forms_CacheSettingsForm', 'APC(u)'), ); } @@ -69,8 +69,8 @@ class CacheSettingsForm extends Model */ public function checkCacheType($attribute, $params) { - if ($this->type == 'yii\caching\ApcCache' && !function_exists('apc_add')) { - $this->addError($attribute, \Yii::t('AdminModule.forms_CacheSettingsForm', "PHP APC Extension missing - Type not available!")); + if ($this->type == 'yii\caching\ApcCache' && !function_exists('apc_add') && !function_exists('apc_addu')) { + $this->addError($attribute, \Yii::t('AdminModule.forms_CacheSettingsForm', "PHP APC(u) Extension missing - Type not available!")); } }