From adca762ee19a557318794f763c3f7805c8c7dbf1 Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Thu, 13 Sep 2018 06:12:13 -0400 Subject: [PATCH] Fix issue processwire/processwire-issues#679 capture Exception in ProcessLanguageTranslator when it throws due to too many directories --- .../LanguageSupport/ProcessLanguageTranslator.module | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/wire/modules/LanguageSupport/ProcessLanguageTranslator.module b/wire/modules/LanguageSupport/ProcessLanguageTranslator.module index 78464430..993c0aea 100644 --- a/wire/modules/LanguageSupport/ProcessLanguageTranslator.module +++ b/wire/modules/LanguageSupport/ProcessLanguageTranslator.module @@ -658,8 +658,17 @@ class ProcessLanguageTranslator extends Process { $find1 = array('$this->_(', '$this->_n(', '$this->_x('); $find2 = array('__(', '_n(', '_x('); + + try { + $dirIterator = new \DirectoryIterator($path); + } catch(\Exception $e) { + $this->warning($e->getMessage()); + $dirIterator = false; + } + + if(!$dirIterator) return array(); - foreach(new \DirectoryIterator($path) as $file) { + foreach($dirIterator as $file) { if($file->isDot()) continue; if(substr($file->getBasename(), 0, 1) == '.') continue; // skip hidden;