prevent PHP errors and enhance logging

fixes #10094

@butonic @schiesbn  please review and test - THX
documentation above says that we will return a array. Wouldn't it be better to return a empty array in this case?