Skip to content
This repository has been archived by the owner on Jun 18, 2024. It is now read-only.

Check if ad_integration module exists, before trying to get the service #11

Open
wants to merge 2 commits into
base: 8.x-2.x
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion infinite_base.module
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ function infinite_base_get_all_parents($term) {
* Implements hook_preprocess_node().
*/
function infinite_base_preprocess_node(&$variables) {
if ($variables['view_mode'] == 'full' || $variables['view_mode'] == 'lazyloading') {
if ($variables['view_mode'] == 'full' || $variables['view_mode'] == 'lazyloading' && \Drupal::moduleHandler()->moduleExists('ad_integration')) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this check is wrong, the "&&" operator is binding stronger then the "||" operator, which results in a faulty check, it should be something like this (see additional parenthesis arround the "||" operands):
if ( ($variables['view_mode'] == 'full' || $variables['view_mode'] == 'lazyloading') && \Drupal::moduleHandler()->moduleExists('ad_integration'))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I don't know why I overlooked this. Thanks for the fix.

/* @var \Drupal\ad_integration\AdIntegration $advertisingService */
$advertisingService = \Drupal::service('ad_integration');
if (is_object($advertisingService)) {
Expand Down