clickstorm / cs_seo

[clickstorm] SEO
Other
33 stars 49 forks source link

PHP Warning : Undefined array key "Percentage" in ModuleWebController.php line 241 #304

Closed TildBJ closed 1 year ago

TildBJ commented 1 year ago

Accessing $results in ModuleWebController will fail because of Type Hinting in \Clickstorm\CsSeo\Domain\Model\Evaluation image

Since getResults() and setResults() pretends to work with arrays, the TYPO3 DataMapper thinks its target Data Type is an array, which actually is a string. Therefore the Data Mapper is not able to map the property and it will end up in setting an empty string in the target Class: image

This Bug is reproducable by setting up TYPO3 11.5 and PHP8.1, installing cs_seo 7.3.1 and open the "SEO" Backend-Module > Evalutation

TildBJ commented 1 year ago

I could provide a PR but i'm not sure how to handle such cases. The data is a kind of array but it will be stored as a string. Storing the data is no problem at all but the datamapper does not now how to map this kind of data to a property. I think the best way to solve this issue is to change the data type of getResults and setResults to string and providing a dedicated getter and setter (e.g. getResultsAsArray) in order to work with arrays. However, I am not sure if this will break backward compatibilty

mhirdes commented 1 year ago

Thanks for your report. I also prefer the solution. Commit is online. Feel free to test https://github.com/clickstorm/cs_seo/commit/c69ec1cef815e27d0ca630ae31f1e87ef806893b