Hello!

We are about to start using salesforce integration in a Drupal 8 instance. Seems like it works, just this single warning:
Warning: count(): Parameter must be an array or an object that implements Countable in Drupal\salesforce_mapping\Plugin\SalesforceMappingField\RecordType::isAllowed() (line 78 of modules/contrib/salesforce/modules/salesforce_mapping/src/Plugin/SalesforceMappingField/RecordType.php).

Drupal\salesforce_mapping\Plugin\SalesforceMappingField\RecordType::isAllowed(Object)
call_user_func(Array, Object) (Line: 316)
Drupal\salesforce_mapping_ui\Form\SalesforceMappingFieldsForm->getDrupalTypeOptions(Object) (Line: 102)
Drupal\salesforce_mapping_ui\Form\SalesforceMappingFieldsForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 519)
Drupal\Core\Form\FormBuilder->retrieveForm('salesforce_mapping_fields_form', Object) (Line: 276)
Drupal\Core\Form\FormBuilder->buildForm('salesforce_mapping_fields_form', Object) (Line: 93)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)

when I visit the page /admin/structure/salesforce/mappings/manage/[map-id]/fields

The signature of RestClient::getRecordTypes() is:

  /**
   * Retrieve all record types for this org.
   *
   * If $name is provided, retrieve record types for the given object type only.
   *
   * @param string $name
   *   Object type name, e.g. Contact, Account, etc.
   *
   * @return array|false
   *   If $name is given, a record type array indexed by developer name.
   *   Otherwise, an array of record type arrays, indexed by object type name.
   *   FALSE if no record types found.
   */
  public function getRecordTypes($name = NULL);

so it may actually return FALSE under some circumstances and we have to account for that within RecordType::isAllowed()

CommentFileSizeAuthor
#2 3067057-php-warning-2.patch702 bytesbucefal91

Comments

bucefal91 created an issue. See original summary.

bucefal91’s picture

Status: Active » Needs review
StatusFileSize
new702 bytes

Here's the patch that accounts for the fact the method could return FALSE.

With this patch applies the PHP warning is gone.

  • AaronBauman committed 0d8c7c6 on 8.x-4.x authored by bucefal91
    Issue #3067057 by bucefal91: Warning: count(): Parameter must be an...
aaronbauman’s picture

Status: Needs review » Fixed

Looks good, thanks for the patch.

bucefal91’s picture

Thanks to you! :)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.