We defined a route under which a visitor of the website can find some information about how to get data related to the currently shown entity:
aw_api.open_data.info:
path: '/open-data/info/{entity_type}/{entity_id}/{related_entity_type}'
defaults:
_controller: 'Drupal\aw_api\Controller\OpenDataInfoController::build'
_title_callback: 'Drupal\aw_api\Controller\OpenDataInfoController::title'
related_entity_type: ''
requirements:
_custom_access: 'Drupal\aw_api\Controller\OpenDataInfoController::access'
The method definition of the access check method looks as following:
public function access(AccountInterface $account, string $entity_type, int $entity_id, string $related_entity_type = '')
We now see log entries from time to time as the following:
TypeError: Drupal\aw_api\Controller\OpenDataInfoController::access(): Argument #3 ($entity_id) must be of type int, string given in Drupal\aw_api\Controller\OpenDataInfoController->access() (line 76 of modules\custom\aw_api\src\Controller\OpenDataInfoController.php).
It is the case when the path /open-data/info/core/scripts/transliteration_data.php.txt was called what seems to be done by scraper or any kind of software.
I know wonder how we can avoid this error? The page is only a WSOD what is not the problem as such a page should never be reached but we would like to avoid this error message in the logs.
By now I think the only solution seems to be to remove the type hinting from the method definition?!