gpt4 book ai didi

arrays - array_flip() :Can only flip STRING and INTEGER values! 在 DrupalDefaultEntityController->load()

转载 作者:IT王子 更新时间:2023-10-29 00:57:35 24 4
gpt4 key购买 nike

我最近将我的模块迁移到 Drupal7(在 PHP 版本 5.3.1 上),现在我收到以下错误:

    * Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 178 of C:\Users\akulkarni\Desktop\xampp\htdocs\servicecasting\includes\entity.inc).
* Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 178 of C:\Users\akulkarni\Desktop\xampp\htdocs\servicecasting\includes\entity.inc).
* Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 178 of C:\Users\akulkarni\Desktop\xampp\htdocs\servicecasting\includes\entity.inc).
* Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->cacheGet() (line 354 of C:\Users\akulkarni\Desktop\xampp\htdocs\servicecasting\includes\entity.inc).
* Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 178 of C:\Users\akulkarni\Desktop\xampp\htdocs\servicecasting\includes\entity.inc).
* Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->cacheGet() (line 354 of C:\Users\akulkarni\Desktop\xampp\htdocs\servicecasting\includes\entity.inc).
* Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 178 of C:\Users\akulkarni\Desktop\xampp\htdocs\servicecasting\includes\entity.inc).
* Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->cacheGet() (line 354 of C:\Users\akulkarni\Desktop\xampp\htdocs\servicecasting\includes\entity.inc).

我也尝试将其他模块和核心升级到最新版本,如此处所述 http://drupal.org/node/1022736

实体 7.x-1.x-dev (2011-Jan-24),查看 7.x-3.x-dev (2011-Jan-22),Drupal 核心 7.x-dev (2011-Jan-24),profile2 7.x-1.0-beta1,引用 7.x-2.x-dev (2011-Jan-14),ctools 7.x-1.0-alpha2

我无法弄清楚究竟是什么导致了这个错误?

编辑:

根据http://php.net/manual/en/function.array-flip.php ,

array_flip() returns an array in flip order, i.e. keys from trans become values and values from trans become keys.

Note that the values of trans need to be valid keys, i.e. they need to be either integer or string. A warning will be emitted if a value has the wrong type, and the key/value pair in question will not be flipped.

我在 entity.inc 的第 178 行之前完成了 var_dump($ids); ( $passed_ids = !empty($ids) ? array_flip($ids) : FALSE;)

在我看来,键/值对总是格式正确(?)。

array
0 =>
array
'nid' => string '6' (length=1)

array
0 =>
array
'uid' => string '1' (length=1)

array
0 => string '0' (length=1)

array
0 =>
array
'nid' => string '7' (length=1)

array
0 =>
array
'nid' => string '4' (length=1)

array
0 =>
array
'nid' => string '8' (length=1)

最佳答案

此错误的最常见原因是使用带有数组作为参数的 something_load() 函数。这不再受支持,因为现在需要为此使用 load_multiple() 函数。

D6 中的示例:

<?php
// Using array with the id was already discouraged in D6 but still worked.
$user = user_load(array('uid' => 1));
$user = user_load(array('name' => 'admin'));
?>

Drupal 7:

<?php
// Argument to a load() function *must* be a single id
$user = user_load(1);

// Querying for another attribute is a bit more complex.
// Note that using reset(user_load_multiple() directly is not E_STRICT compatible.
$users = user_load_multiple(array(), array('name' => 'admin'));
$user = reset($users);
?>

因此,捕获这些最简单的方法是搜索“_load(array)”。

关于arrays - array_flip() :Can only flip STRING and INTEGER values! 在 DrupalDefaultEntityController->load(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4798047/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com