Added additional condition to prevent variable from being accessed when it hasn't been set.
Merge pull request #391 from christianselig/7.x

Added additional condition to prevent variable from being accessed when ...