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

...tring