Fix for Call to a member function isVisible() on a non-object https://drupal.org/node/2262703