From e2ac2b3272bc75f7f596cce687b6c67f4a965e3e Mon Sep 17 00:00:00 2001 From: volga629-1 <59034879+volga629-1@users.noreply.github.com> Date: Mon, 8 Dec 2025 10:09:11 -0500 Subject: [PATCH] Number translate bug PHP Fatal error: Uncaught Error: Cannot access private property xml (#7656) * Number translation through exception unable load private property PHP Fatal error: Uncaught Error: Cannot access private property Under class defined ``` private $xml; ``` You can't access this properly under private constant * Fix private property access under class for import() PHP Fatal error: Uncaught Error: Cannot access private property. --- app/number_translations/app_defaults.php | 11 ++++++----- .../resources/classes/number_translations.php | 10 ++++++++++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/app/number_translations/app_defaults.php b/app/number_translations/app_defaults.php index 5c2ecab04c..3f0d128ccb 100644 --- a/app/number_translations/app_defaults.php +++ b/app/number_translations/app_defaults.php @@ -32,16 +32,17 @@ if ($num_rows == 0) { //get the array of xml files - $xml_list = glob($_SERVER["PROJECT_ROOT"] . "/*/*/resources/switch/conf/number_translation/*.xml"); - - //number_translation class + $dir = dirname(__DIR__, 2) . "/app/number_translations/resources/switch/conf/number_translation"; + //number_translation class $number_translation = new number_translations; //process the xml files + $xml_list = array_diff(scandir($dir), array('..', '.')); foreach ($xml_list as $xml_file) { //get and parse the xml - $number_translation->xml = file_get_contents($xml_file); - $number_translation->import(); + $file_content = file_get_contents($dir . '/' . $xml_file); + $number_translation->getxml($file_content); + $number_translation->import(); } //check for existing configuration diff --git a/app/number_translations/resources/classes/number_translations.php b/app/number_translations/resources/classes/number_translations.php index d1ef8afc69..1053e9dd70 100644 --- a/app/number_translations/resources/classes/number_translations.php +++ b/app/number_translations/resources/classes/number_translations.php @@ -86,6 +86,16 @@ class number_translations { $parameters['number_translation_name'] = $name; return $this->database->select($sql, $parameters, 'column') != 0 ? true : false; } + + /** + * + * Load properly private property xml + * @param string $file_content content of template files. + */ + public function getxml($file_content) { + $this->xml = $file_content; + return $this->xml; + } /** * Imports a number translation from either XML or JSON format.