|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2015-04-09 23:41 UTC] berdir@php.net
Description: ------------ This is part of our efforts to get Drupal 8 green on PHP 7, see https://www.drupal.org/node/2454439. This might be related to https://bugs.php.net/bug.php?id=69371, which was a somewhat similar php bug that we found (Similar as in, arrays/array functions behaving strangely). We have a code line like this: array_count_values($form_state->getValue('prefix')) This displays: array_count_values(): Can only count STRING and INTEGER values! Warning NegotiationUrlForm.php 183 Drupal\language\Form\NegotiationUrlForm->validateForm() But the array definitely is valid: Array ( [en] => [fr] => fr ) (en is an empty string, type string) Looping over the array works, accessing the keys works. Trying the same with that array works: $ php7 -r '$array = array("en" => "", "fr" => "fr"); var_dump(array_count_values($array));' array(2) { [""]=> int(1) ["fr"]=> int(1) } Re-creating the array with the same values works: $prefix = ['en' => $form_state->getValue('prefix')['en'], 'fr' => $form_state->getValue('prefix')['fr']]; $count = array_count_values($prefix); So, similar in the other issue, the array or one of those values seems to be in a weird state. I've tracked down the place where this warning is displayed to https://github.com/php/php-src/blob/master/ext/standard/array.c#L3017. If anyone can tell me what to put there to debug the content and type of entry, then I'm more than happy to try that. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Dec 15 03:00:01 2025 UTC |
To reproduce, install D8 (see linked issue, you need gd, curl and some other extensions), install the language module and go to admin/config/regional/language/detection/url, save the form. Doesn't matter if you enter something or not. var_dump() output: array(1) { ["en"]=> string(0) "" }Found a simple repo script. It appears to break when one of the elements in the array is a reference. <?php $foo = [ 'en' => '', 'fr' => 'fr' ]; $bar = [ 'de' => 'de' ]; $bar[] = $foo['en']; var_dump(array_count_values($foo)); $bar[] = &$foo['fr']; var_dump(array_count_values($foo));