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.
This commit is contained in:
volga629-1
2025-12-08 10:09:11 -05:00
committed by GitHub
parent 807c6e2f46
commit e2ac2b3272
2 changed files with 16 additions and 5 deletions

View File

@@ -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

View File

@@ -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.