Closed fredericalpers closed 1 year ago
@fredericalpers I checked again in the source code, The variable being passed to the "getLabel" function is the "$recordRaw" variable which the value of the variable as follows:
$recordRaw = $this->_recordsRaw[$this->_currentEstate['id']]['elements'];
So logically, $recordRaw will only accept null when we pass an "Id" which doesn't exist on the Enterprise system (but this will not happen in reality, because this "Id" always exists in the response API result) => My solutions: We will add logic that returns "the default value" for "$recordRaw" variable which is "an empty array." $recordRaw = $this->_recordsRaw[$this->_currentEstate['id']]['elements'] ?? [];
Please give me your opinion on my comment?
@yeneastgate I will get back to you asap:)
$recordRaw = $this->_recordsRaw[$this->_currentEstate['id']]['elements'];
So logically, $recordRaw will only accept null when we pass an "Id" which doesn't exist on the Enterprise system (but this will not happen in reality, because this "Id" always exists in the response API result) => My solutions: We will add logic that returns "the default value" for "$recordRaw" variable which is "an empty array." $recordRaw = $this->_recordsRaw[$this->_currentEstate['id']]['elements'] ?? [];
@dai-eastgate please go ahead and implement the suggested solution. thank you :)
@fredericalpers I fixed it. Please check it, thanks
@dai-eastgate thank you, we will test it as soon as possible :)
Currrent state
A customers website (very old website) keeps crashing with critical errors a few times a day after updating the plugin. Since we can not reproduce the critical error, please investigate.
Error message
[17-Aug-2023 11:52:22 UTC] PHP Fatal error: Uncaught TypeError: Argument 1 passed to onOffice\WPlugin\Types\EstateStatusLabel::getLabel() must be of the type array, null given, called in /www/htdocs/w01ad851/15789.onofficeweb.com/htdocs/wp-content/plugins/onoffice-for-wp-websites/plugin/EstateList.php on line 492 and defined in /www/htdocs/w01ad851/15789.onofficeweb.com/htdocs/wp-content/plugins/onoffice-for-wp-websites/plugin/Types/EstateStatusLabel.php:77 Stack trace: #0 /www/htdocs/w01ad851/15789.onofficeweb.com/htdocs/wp-content/plugins/onoffice-for-wp-websites/plugin/EstateList.php(492): onOffice\WPlugin\Types\EstateStatusLabel->getLabel(NULL) #1 /www/htdocs/w01ad851/15789.onofficeweb.com/htdocs/wp-content/plugins/onoffice-personalized/templates/estate/default.php(131): onOffice\WPlugin\EstateList->estateIterator() #2 /www/htdocs/w01ad851/15789.onofficeweb.com/htdocs/wp-content/plugins/onoffice-for-wp-websites/plugin/Template.php(118): include('/www/htdocs/w01...') #3 /www/htdocs/w01ad851/15789.onofficeweb.com/htdocs/wp-content/plugins/onoffice-fo in /www/htdocs/w01ad851/15789.onofficeweb.com/htdocs/wp-content/plugins/onoffice-for-wp-websites/plugin/Types/EstateStatusLabel.php on line 77
Desired state
Please implement a check in the plugin that an array is indeed passed to EstateStatusLabel::getLabel().