Commit 5c6438d0 authored by catch's avatar catch

Issue #2379811 by Lendude, dawehner: Views tries to render contextual links...

Issue #2379811 by Lendude, dawehner: Views tries to render contextual links when Contextual Links module is disabled
parent a17498c5
......@@ -8,7 +8,7 @@
namespace Drupal\node\Tests\Views;
use Drupal\Component\Serialization\Json;
use Symfony\Component\HttpFoundation\Request;
use Drupal\user\Entity\User;
/**
* Tests views contextual links on nodes.
......@@ -94,4 +94,30 @@ protected function renderContextualLinks($ids, $current_path) {
));
}
/**
* Tests if the node page works if Contextual Links is disabled.
*
* All views have Contextual links enabled by default, even with the
* Contextual links module disabled. This tests if no calls are done to the
* Contextual links module by views when it is disabled.
*
* @see https://www.drupal.org/node/2379811
*/
public function testPageWithDisabledContextualModule() {
\Drupal::service('module_installer')->uninstall(['contextual']);
\Drupal::service('module_installer')->install(['views_ui']);
// Ensure that contextual links don't get called for admin users.
$admin_user = User::load(1);
$admin_user->setPassword('new_password');
$admin_user->pass_raw = 'new_password';
$admin_user->save();
$this->drupalCreateContentType(array('type' => 'page'));
$this->drupalCreateNode(array('promote' => 1));
$this->drupalLogin($admin_user);
$this->drupalGet('node');
}
}
......@@ -308,7 +308,7 @@ function views_page_display_pre_render(array $element) {
*/
function views_preprocess_html(&$variables) {
// Early-return to prevent adding unnecessary JavaScript.
if (!\Drupal::currentUser()->hasPermission('access contextual links')) {
if (!\Drupal::moduleHandler()->moduleExists('contextual') || !\Drupal::currentUser()->hasPermission('access contextual links')) {
return;
}
......@@ -393,8 +393,8 @@ function views_preprocess_html(&$variables) {
*/
function views_add_contextual_links(&$render_element, $location, ViewExecutable $view, $display_id) {
// Do not do anything if the view is configured to hide its administrative
// links.
if ($view->getShowAdminLinks()) {
// links or if the Contextual Links module is not enabled.
if (\Drupal::moduleHandler()->moduleExists('contextual') && $view->getShowAdminLinks()) {
// Also do not do anything if the display plugin has not defined any
// contextual links that are intended to be displayed in the requested
// location.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment