Create linked drupal user account rule is_active boolean

Created on 6 April 2022, about 2 years ago
Updated 9 May 2024, about 1 month ago

Problem/Motivation

I believe the fields on the Create linked drupal user account related to "Activate account" (and possibly others) may have stopped working with the following commit: https://git.drupalcode.org/project/civicrm_entity/-/commit/321713088b57d...

Steps to reproduce

  • Create a rule that fires the "Create linked drupal user account" action.
  • Add "FALSE" in the "Activate account" field.
  • Run the rule.
  • Should see the related user is active.

Proposed resolution

As seen added here about 4 months ago, are checks to see if the field is empty: https://git.drupalcode.org/project/civicrm_entity/-/commit/321713088b57d...

if (empty($is_active)) {
  $is_active = $this->getContextDefinition('is_active')->getDefaultValue();
}

However, I believe the Boolean field, if set to FALSE is tripping this check, and thus always setting it to be TRUE. See https://www.php.net/manual/en/function.empty.php for explanation: "Determine whether a variable is considered to be empty. A variable is considered empty if it does not exist or if its value equals false"

See the following simplified example:

<?php

$is_active = FALSE;

print "initial:" . json_encode($is_active) . "<br />"; // initial:false

if (empty($is_active)) {
  $is_active = TRUE;
}

print "after:" . json_encode($is_active); // after:true

Suggest changing this to"$is_active !== NULL" or similar maybe?

πŸ› Bug report
Status

Fixed

Version

3.1

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States Dan_Rogers Driggs, ID

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024