prevent PHP errors and enhance logging

fixes #10094

@butonic @schiesbn  please review and test - THX