From: Mikael Nordfeldth Date: Wed, 2 Mar 2016 11:33:06 +0000 (+0100) Subject: Introduce a ConfigException X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=d6598e790c837ef9c827c3b2c2c81bbdab27838c;p=quix0rs-gnu-social.git Introduce a ConfigException --- diff --git a/classes/Notice.php b/classes/Notice.php index f8bdbcd340..7484897679 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -507,8 +507,7 @@ class Notice extends Managed_DataObject $notice = new Notice(); $notice->profile_id = $profile_id; - $autosource = common_config('public', 'autosource'); - if ($source && $autosource && in_array($source, $autosource)) { + if ($source && in_array($source, common_config('public', 'autosource'))) { $notice->is_local = Notice::LOCAL_NONPUBLIC; } else { $notice->is_local = $is_local; @@ -823,8 +822,7 @@ class Notice extends Managed_DataObject // Since then we have started just filtering _when_ it gets shown // instead of creating a mixed jumble of differently scoped notices. - $autosource = common_config('public', 'autosource'); - if ($source && $autosource && in_array($source, $autosource)) { + if ($source && in_array($source, common_config('public', 'autosource'))) { $stored->is_local = Notice::LOCAL_NONPUBLIC; } else { $stored->is_local = intval($is_local); diff --git a/lib/configexception.php b/lib/configexception.php new file mode 100644 index 0000000000..5036a43533 --- /dev/null +++ b/lib/configexception.php @@ -0,0 +1,22 @@ + + * @license https://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link https://gnu.io/social + */ + +class ConfigException extends ServerException +{ + public function __construct($message=null) { + parent::__construct($message, 500); + } +} diff --git a/lib/gnusocial.php b/lib/gnusocial.php index 2ad688a790..aecebe2556 100644 --- a/lib/gnusocial.php +++ b/lib/gnusocial.php @@ -432,9 +432,13 @@ class GNUsocial if (common_config('htmlpurifier', 'Cache.DefinitionImpl') === 'Serializer' && !is_dir(common_config('htmlpurifier', 'Cache.SerializerPath'))) { if (!mkdir(common_config('htmlpurifier', 'Cache.SerializerPath'))) { - throw new ServerException('Could not create HTMLPurifier cache dir: '._ve(common_config('htmlpurifier', 'Cache.SerializerPath'))); + throw new ConfigException('Could not create HTMLPurifier cache dir: '._ve(common_config('htmlpurifier', 'Cache.SerializerPath'))); } } + + if (!is_array(common_config('public', 'autosource'))) { + throw new ConfigException('Configuration option public/autosource is not an array.'); + } } /**