fixed artisan optimize crash
Merge pull request #3176 from slik/bugfix/artisan_optimize_crash

[5.0] Fixed artisan optimize crash