From aaa78172d8a46be8a1c3d35da13b399027d56b8f Mon Sep 17 00:00:00 2001 From: filip Date: Sun, 18 Sep 2016 22:58:36 +0200 Subject: better handling of invalid resource --- langs/lib.php | 3 +++ langs/report_tx_git.php | 11 ++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/langs/lib.php b/langs/lib.php index b984d3223..b00825781 100644 --- a/langs/lib.php +++ b/langs/lib.php @@ -89,6 +89,9 @@ function _po_diff($locale, $resource, $source_l = NULL, $path = NULL, $compared if (is_null($path)) { if (NULL == $source_l) { $source_l = read_translation_file('en', $resource); + if (FALSE == $source_l) { + $source_l = array(array()); + } } $target_l = read_translation_file($locale, $resource); } else { diff --git a/langs/report_tx_git.php b/langs/report_tx_git.php index c7dee5b7d..388ae2615 100644 --- a/langs/report_tx_git.php +++ b/langs/report_tx_git.php @@ -70,14 +70,15 @@ if (!empty($wanted_language) && !empty($wanted_resource_name)) { $details_wanted = TRUE; } +$parsed_tx_file_content = NULL; if ($details_wanted) { $prefixed_resource_name = resource_name_conversion($wanted_resource_name, $wanted_category); $tx_file = tx_call("resource/$prefixed_resource_name/translation/$wanted_language/"); - $tx_file_content = $tx_file['content']; - $tx_file_content = explode("\n", $tx_file_content); - $parsed_tx_file_content = phpmo_parse_po_file($tx_file_content, FALSE); -} else { - $parsed_tx_file_content = NULL; + if (!empty($tx_file)) { + $tx_file_content = $tx_file['content']; + $tx_file_content = explode("\n", $tx_file_content); + $parsed_tx_file_content = phpmo_parse_po_file($tx_file_content, FALSE); + } } // create separate array ($tx_resources_info) and add statistics to it from TX -- cgit v1.2.1