Answers.Body: <p>Its a bug in CiviCRM and is not handled properly for D8, you can fix this by applying below patch</p>
  
  <pre><code>diff --git a/CRM/Report/Form/Instance.php b/CRM/Report/Form/Instance.php
  index 8f00408a17..965949e21c 100644
  --- a/CRM/Report/Form/Instance.php
  +++ b/CRM/Report/Form/Instance.php
  @@ -112,7 +112,13 @@ class CRM_Report_Form_Instance {
       if (function_exists('user_roles')) {
         $user_roles_array = user_roles();
         foreach ($user_roles_array as $key =&gt; $value) {
  -        $user_roles[$value] = $value;
  +        if (is_object($value) &amp;&amp; is_a($value, 'Drupal\user\Entity\Role')) {
  +          $value = $value-&gt;label();
  +        }
  +        else {
  +          $key = $value;
  +        }
  +        $user_roles[$key] = $value;
         }
         $grouprole = $form-&gt;addElement('advmultiselect',
           'grouprole',
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-16T18:54:17.133Z
Answers.Text: There is an official patch recently committed. See https://github.com/civicrm/civicrm-core/pull/15318/files and you'll also need https://github.com/civicrm/civicrm-core/pull/16273 for it to enforce access.
Answers.UserDisplayName: Demerit
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-16T18:21:48.793Z
Answers.LastActivityDate: 2020-01-16T18:21:48.793Z
Answers.UserDisplayName: Pradeep Nayak
Body: <p>I'm using Drupal 8 / Civi 5.11</p>
  
  <p>I get the following errors on the screen multiple times (one for each Drupal role in my system) when I attempt to create a new report in CiviCRM (CiviCRM->Admin->CiviReports->Create New Report From Template -- using Constituent Summary, for example):</p>
  
  <pre><code>Warning: Illegal offset type in CRM_Report_Form_Instance::buildForm() (line 135 of /var/www/site/vendor/civicrm/civicrm-core/CRM/Report/Form/Instance.php).
  </code></pre>
  
  <p>It appears that on line 135, the Drupal roles are being iterated and assumed to be strings.  They are, in fact, objects in Drupal 8.</p>
  
  <p>Does anyone know if this is a bug already reported/being work on?  I've looked at the issue queue but haven't turned anything up.</p>
  
  <p>Is my system, perhaps, just misconfigured and it's not a bug after all?</p>
  
Tags: <reports><drupal-8>
Title: Warning: Illegal offset type (multiple) when creating new report from template (D8/Civi5.11)
ThreadText: # Warning: Illegal offset type (multiple) when creating new report from template (D8/Civi5.11)
  
  (Asked by: username_0 on 2020-01-16)
  
  I'm using Drupal 8 / Civi 5.11
  I get the following errors on the screen multiple times (one for each Drupal role in my system) when I attempt to create a new report in CiviCRM (CiviCRM->Admin->CiviReports->Create New Report From Template -- using Constituent Summary, for example):
  Warning: Illegal offset type in CRM_Report_Form_Instance::buildForm() (line 135 of /var/www/site/vendor/civicrm/civicrm-core/CRM/Report/Form/Instance.php).
  
  It appears that on line 135, the Drupal roles are being iterated and assumed to be strings.  They are, in fact, objects in Drupal 8.
  Does anyone know if this is a bug already reported/being work on?  I've looked at the issue queue but haven't turned anything up.
  Is my system, perhaps, just misconfigured and it's not a bug after all?
  
  **Tags:** reports, drupal-8
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-01-16. Score: 1 | Accepted answer
  
  Its a bug in CiviCRM and is not handled properly for D8, you can fix this by applying below patch
  diff --git a/CRM/Report/Form/Instance.php b/CRM/Report/Form/Instance.php
  index 8f00408a17..965949e21c 100644
  --- a/CRM/Report/Form/Instance.php
  +++ b/CRM/Report/Form/Instance.php
  @@ -112,7 +112,13 @@ class CRM_Report_Form_Instance {
       if (function_exists('user_roles')) {
         $user_roles_array = user_roles();
         foreach ($user_roles_array as $key => $value) {
  -        $user_roles[$value] = $value;
  +        if (is_object($value) && is_a($value, 'Drupal\user\Entity\Role')) {
  +          $value = $value->label();
  +        }
  +        else {
  +          $key = $value;
  +        }
  +        $user_roles[$key] = $value;
         }
         $grouprole = $form->addElement('advmultiselect',
           'grouprole',
  
  > **Comments:**
  > **username_2**: There is an official patch recently committed. See https://github.com/civicrm/civicrm-core/pull/15318/files and you'll also need https://github.com/civicrm/civicrm-core/pull/16273 for it to enforce access.  
  
  ---
  
  