gnucash-htdocs beta: Multiple changes pushed

John Ralls jralls at code.gnucash.org
Thu Jan 12 16:56:28 EST 2023


Updated	 via  https://github.com/Gnucash/gnucash-htdocs/commit/a546d2d5 (commit)
	 via  https://github.com/Gnucash/gnucash-htdocs/commit/ca5cb318 (commit)
	 via  https://github.com/Gnucash/gnucash-htdocs/commit/048fed30 (commit)
	from  https://github.com/Gnucash/gnucash-htdocs/commit/19f2e396 (commit)



commit a546d2d598a16ffb17c3ca879cfd45583cb94f0a
Merge: 19f2e39 ca5cb31
Author: John Ralls <jralls at ceridwen.us>
Date:   Thu Jan 12 13:56:11 2023 -0800

    Merge branch 'master' into beta


commit ca5cb31803b3918ee79af6979e05ce38b074c2a1
Author: John Ralls <jralls at ceridwen.us>
Date:   Thu Jan 12 13:37:13 2023 -0800

    Protect against empty arrays/NULL array references in gettext.php.

diff --git a/externals/gettext.php b/externals/gettext.php
index a121f9c..de50b8c 100644
--- a/externals/gettext.php
+++ b/externals/gettext.php
@@ -139,16 +139,18 @@ class gettext_reader {
    */
   function load_tables() {
     if (is_array($this->cache_translations) &&
-      is_array($this->table_originals) &&
-      is_array($this->table_translations))
+        is_array($this->table_originals) &&
+        is_array($this->table_translations))
       return;
 
     /* get original and translations tables */
-    if (!is_array($this->table_originals)) {
+      if ($this->table_originals &&
+          !is_array($this->table_originals)) {
       $this->STREAM->seekto($this->originals);
       $this->table_originals = $this->readintarray($this->total * 2);
     }
-    if (!is_array($this->table_translations)) {
+      if ($this->table_translations &&
+          !is_array($this->table_translations)) {
       $this->STREAM->seekto($this->translations);
       $this->table_translations = $this->readintarray($this->total * 2);
     }

commit 048fed3089749a9e08ef7c8a6003d2491a584070
Author: John Ralls <jralls at ceridwen.us>
Date:   Thu Jan 12 13:29:29 2023 -0800

    Fix three PHP8 warnings about indexing empty arrays.

diff --git a/externals/header.phtml b/externals/header.phtml
index 4bb81f0..61ca38c 100644
--- a/externals/header.phtml
+++ b/externals/header.phtml
@@ -21,15 +21,17 @@
   {
       if (isset($lang) && $lang != "") {
           $get_parms["lang"] = $lang;
+          if (in_array($get_parms["lang"],
+                       array_values($GLOBALS["supported_languages"]), TRUE) ||
+                       array_key_exists($get_parms["lang"],
+                                        $GLOBALS["supported_languages"])) {
+              $url_get_query = http_build_query($get_parms);
+              $lang_href = "$page"."?"."$url_get_query";
+          } else {
+              $lang_href = "$page";
+          }
+          return $lang_href;
       }
-      if (in_array($get_parms["lang"], array_values($GLOBALS["supported_languages"]), TRUE) ||
-           array_key_exists($get_parms["lang"], $GLOBALS["supported_languages"])) {
-          $url_get_query = http_build_query($get_parms);
-          $lang_href = "$page"."?"."$url_get_query";
-      } else {
-          $lang_href = "$page";
-      }
-      return $lang_href;
   }
 
    $input_filter_args = array('lang' => FILTER_SANITIZE_STRING);
diff --git a/lang.php b/lang.php
index 87601f6..2495ba2 100644
--- a/lang.php
+++ b/lang.php
@@ -63,10 +63,12 @@ if (count($languages) > 1) {
     foreach ($languages as $item)
     {
         $parts = explode(";", $item);
-        if (!$parts[1]) {
-            $ranked_langs[$parts[0]] = 1.0;
-        } else {
-            $ranked_langs[$parts[0]] = (float)substr($parts[1], 2);
+        if ($parts) {
+            if (!$parts[1]) {
+                $ranked_langs[$parts[0]] = 1.0;
+            } else {
+                $ranked_langs[$parts[0]] = (float)substr($parts[1], 2);
+            }
         }
     }
     arsort($ranked_langs, SORT_NUMERIC);



Summary of changes:
 externals/gettext.php  | 10 ++++++----
 externals/header.phtml | 18 ++++++++++--------
 lang.php               | 10 ++++++----
 3 files changed, 22 insertions(+), 16 deletions(-)



More information about the gnucash-changes mailing list