Problem/Motivation

When Drupal requires you to enable some PHP extensions we get the next error:

Array to string conversion
/var/www/html/d8.loc/core/includes/install.core.inc:2181
/var/www/html/d8.loc/core/includes/install.core.inc:1028

An array is set for the requirements (core/modules/system/system.install in line 242), but string is expected.
E.g. we use 'description' element as string in install.core.inc (line 2181).

Proposed resolution

Render inline_template before set to requirements.

Remaining tasks

None

User interface changes

None

API changes

None

Issue fork drupal-2864980

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

  • 2864980-array-to-string Comparecompare
  • Error loading live previews.

Comments

alan-ps created an issue. See original summary.

alan-ps’s picture

Status: Active » Needs review
StatusFileSize
new647 bytes

This is a possible solution.

Status: Needs review » Needs work

The last submitted patch, 2: 2864980-2-array-to-string-conversion.patch, failed testing.

alan-ps’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 2: 2864980-2-array-to-string-conversion.patch, failed testing.

alan-ps’s picture

Status: Needs work » Needs review

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

manuel garcia’s picture

Running into a very similar situation, though this time the line seems to be on core/includes/install.core.inc:2257

$failures[] = $requirement['title'] . ': ' . $requirement['value'] . "\n\n" . $requirement['description'];

The description is of type inline_template.

Changing that line to this solves the problem, however I doubt it is the correct solution:
$failures[] = $requirement['title'] . ': ' . $requirement['value'] . "\n\n" . $requirement['description']['#context']['error'] . ' ' . $requirement['description']['#context']['description'];

manuel garcia’s picture

Status: Needs review » Reviewed & tested by the community

Ran into this again, and took me a while to track down again, only to realize that it was this issue again. Regarding my previous comment, I didnt read properly the description, it is the same issue as described.

I have tested the patch and it solves the issue, and is simple enough. Setting to RTBC.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests, +Needs steps to reproduce

I think there are other related issues. @Manuel Garcia can you give the full stack trace and steps to reproduce. Plus we need test coverage.

manuel garcia’s picture

Regarding tests, was afraid it was going to be the case - no clue how to even start on that.

Here is the stack trace:

Drupal\Tests\smartsite_profile\Functional\SmartsiteProfileTest::testSmartsiteProfileDefaults
Array to string conversion

/var/www/smartsite/app/core/includes/install.core.inc:2257
/var/www/smartsite/app/core/includes/install.core.inc:1075
/var/www/smartsite/app/core/includes/install.core.inc:686
/var/www/smartsite/app/core/includes/install.core.inc:564
/var/www/smartsite/app/core/includes/install.core.inc:120
/var/www/smartsite/app/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php:309
/var/www/smartsite/app/core/tests/Drupal/Tests/BrowserTestBase.php:1051
/var/www/smartsite/app/core/tests/Drupal/Tests/BrowserTestBase.php:490
/var/www/smartsite/app/profiles/smartsite_profile/tests/src/Functional/SmartsiteProfileBrowserTestBase.php:39
/var/www/smartsite/app/profiles/smartsite_profile/tests/src/Functional/SmartsiteProfileTest.php:43

Our test does nothing special when setting up (just adds a few users).

I believe the way to replicate this error would be to remove a few of the php extensions required from your system.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

DaFeliX made their first commit to this issue’s fork.

DaFeliX’s picture

Hi all,

I also encountered this issue, so I took some time to pick this up.

What I did:

1. Make the code testable - I extracted the logic to a separate class, this allows the code to be tested
2. Wrote tests for the current state
3. Used the patch from alan-ps and wrote a additional assert to make sure that the description is an actual string

Feel free to comment on the fork.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

mstrelan’s picture

Status: Needs work » Closed (duplicate)
Related issues: +#2833864: Unmet installation requirements may contain render elements

I believe this is a duplicate of #2833864: Unmet installation requirements may contain render elements which has been fixed.