fix ContextErrorException: Warning: substr() expects parameter 1 to be string