From 69a8836910789d73f3aac86a55957d124885cd2d Mon Sep 17 00:00:00 2001 From: Samuel Amoser Date: Tue, 18 Aug 2020 15:16:07 +0200 Subject: [PATCH] PATCH: Prevents calling strpos with empty needle We happen to run into this warning: ``` [Warning] strpos(): Empty needle Line 2618 in ./framework/i18n/i18n.php 2618 strpos($theme, (string)Config::inst()->get('SSViewer', 'theme')) === 0 ``` I suggest to test the needle against emptyness before invoking strpos. --- i18n/i18n.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/i18n/i18n.php b/i18n/i18n.php index 909d3d1df..35c0c8723 100644 --- a/i18n/i18n.php +++ b/i18n/i18n.php @@ -2614,8 +2614,10 @@ class i18n extends SS_Object implements TemplateGlobalProvider, Flushable { $themesBase = Director::baseFolder() . '/themes'; if(is_dir($themesBase)) { foreach(scandir($themesBase) as $theme) { + $themename = (string)Config::inst()->get('SSViewer', 'theme'); if( - strpos($theme, (string)Config::inst()->get('SSViewer', 'theme')) === 0 + !empty($themename) + && strpos($theme, $themename) === 0 && file_exists("{$themesBase}/{$theme}/lang/") ) { $filename = $adapter->getFilenameForLocale($locale);