Download & Extend

Error message when using searching

Project:Kaltura
Version:7.x-2.x-dev
Component:Code
Category:bug report
Priority:major
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

When I using drupal search to look for the clip, some error message is generated:

Notice:Undefined offset: 0 於 field_kaltura_field_formatter_view() (/var/www/drupal-7.8/sites/all/modules/kaltura/plugins/field_kaltura/field_kaltura.module 中的第 723 行)。
Notice:Undefined offset: 0 於 field_kaltura_field_formatter_view() (/var/www/drupal-7.8/sites/all/modules/kaltura/plugins/field_kaltura/field_kaltura.module 中的第 724 行)。
Warning:mb_strlen() expects parameter 1 to be string, array given 於 drupal_strlen() (/var/www/drupal-7.8/includes/unicode.inc 中的第 441 行)。
Warning:preg_match_all() expects parameter 2 to be string, array given 於 kaltura_replace_tags() (/var/www/drupal-7.8/sites/all/modules/kaltura/includes/kaltura.themeing.inc 中的第 33 行)。
Warning:Invalid argument supplied for foreach() 於 kaltura_replace_tags() (/var/www/drupal-7.8/sites/all/modules/kaltura/includes/kaltura.themeing.inc 中的第 36 行)。
Warning:mb_strlen() expects parameter 1 to be string, array given 於 drupal_strlen() (/var/www/drupal-7.8/includes/unicode.inc 中的第 441 行)。
Warning:preg_match_all() expects parameter 2 to be string, array given 於 kaltura_replace_tags() (/var/www/drupal-7.8/sites/all/modules/kaltura/includes/kaltura.themeing.inc 中的第 33 行)。
Warning:Invalid argument supplied for foreach() 於 kaltura_replace_tags() (/var/www/drupal-7.8/sites/all/modules/kaltura/includes/kaltura.themeing.inc 中的第 36 行)。
Warning:mb_strlen() expects parameter 1 to be string, array given 於 drupal_strlen() (/var/www/drupal-7.8/includes/unicode.inc 中的第 441 行)。
Warning:preg_match_all() expects parameter 2 to be string, array given 於 kaltura_replace_tags() (/var/www/drupal-7.8/sites/all/modules/kaltura/includes/kaltura.themeing.inc 中的第 33 行)。
Warning:Invalid argument supplied for foreach() 於 kaltura_replace_tags() (/var/www/drupal-7.8/sites/all/modules/kaltura/includes/kaltura.themeing.inc 中的第 36 行)。
Warning:htmlspecialchars(): Invalid multibyte sequence in argument 於 check_plain() (/var/www/drupal-7.8/includes/bootstrap.inc 中的第 1521 行)。
Warning:mb_strlen() expects parameter 1 to be string, array given 於 drupal_strlen() (/var/www/drupal-7.8/includes/unicode.inc 中的第 441 行)。
Warning:preg_match_all() expects parameter 2 to be string, array given 於 kaltura_replace_tags() (/var/www/drupal-7.8/sites/all/modules/kaltura/includes/kaltura.themeing.inc 中的第 33 行)。
Warning:Invalid argument supplied for foreach() 於 kaltura_replace_tags() (/var/www/drupal-7.8/sites/all/modules/kaltura/includes/kaltura.themeing.inc 中的第 36 行)。
Warning:htmlspecialchars(): Invalid multibyte sequence in argument 於 check_plain() (/var/www/drupal-7.8/includes/bootstrap.inc 中的第 1521 行)。
Warning:mb_strlen() expects parameter 1 to be string, array given 於 drupal_strlen() (/var/www/drupal-7.8/includes/unicode.inc 中的第 441 行)。
Warning:preg_match_all() expects parameter 2 to be string, array given 於 kaltura_replace_tags() (/var/www/drupal-7.8/sites/all/modules/kaltura/includes/kaltura.themeing.inc 中的第 33 行)。
Warning:Invalid argument supplied for foreach() 於 kaltura_replace_tags() (/var/www/drupal-7.8/sites/all/modules/kaltura/includes/kaltura.themeing.inc 中的第 36 行)。
Warning:mb_strlen() expects parameter 1 to be string, array given 於 drupal_strlen() (/var/www/drupal-7.8/includes/unicode.inc 中的第 441 行)。
Warning:preg_match_all() expects parameter 2 to be string, array given 於 kaltura_replace_tags() (/var/www/drupal-7.8/sites/all/modules/kaltura/includes/kaltura.themeing.inc 中的第 33 行)。
Warning:Invalid argument supplied for foreach() 於 kaltura_replace_tags() (/var/www/drupal-7.8/sites/all/modules/kaltura/includes/kaltura.themeing.inc 中的第 36 行)。

Please note that I have entered tag (both drupal and kaltura) and description for every clip and article I uploaded.

Please help. Thanks.

Kinglok, Fong

Comments

#1

I have tested using both english and tradition chinese in drupal. Both create the same issue.

It seems that line 441 of /var/www/drupal-7.8/includes/unicode.inc
create the problem:

Line Code
438 function drupal_strlen($text) {
439 global $multibyte;
440 if ($multibyte == UNICODE_MULTIBYTE) {
441 return mb_strlen($text);
442 }
443 else {
444 // Do not count UTF-8 continuation bytes.
445 return strlen(preg_replace("/[\x80-\xBF]/", '', $text));
446 }
447 }

#2

Status:active» postponed (maintainer needs more info)

Do you think this is an issue with Kaltura module specifically, then? (That seems likely as Drupal has had a lot more multilingual attention than Kaltura module. But we may need you to provide more detail on how to replicate the bug, as I can't replicate it here.)

#3

Quick check: if you search for a term which returns no Kaltura nodes, do you still see this issue?

#4

As you said, I have done a quick test.

1. I change the drupal language system from Traditional Chinese to English

2. I add an artical with title of "Testing Search", tags of "apple,orange", content of "They are fruits", without any kaltura material.

After step 2, I got
Notice: Undefined offset: 0 in field_kaltura_field_formatter_view() (line 723 of /var/www/drupal-7.8/sites/all/modules/kaltura/plugins/field_kaltura/field_kaltura.module).
Notice: Undefined offset: 0 in field_kaltura_field_formatter_view() (line 724 of /var/www/drupal-7.8/sites/all/modules/kaltura/plugins/field_kaltura/field_kaltura.module).
Notice: Undefined offset: 0 in field_kaltura_field_formatter_view() (line 723 of /var/www/drupal-7.8/sites/all/modules/kaltura/plugins/field_kaltura/field_kaltura.module).
Notice: Undefined offset: 0 in field_kaltura_field_formatter_view() (line 724 of /var/www/drupal-7.8/sites/all/modules/kaltura/plugins/field_kaltura/field_kaltura.module).

3. I manually start the cron job of drupal

and I get the following error
Notice: Undefined offset: 0 in field_kaltura_field_formatter_view() (line 723 of /var/www/drupal-7.8/sites/all/modules/kaltura/plugins/field_kaltura/field_kaltura.module).
Notice: Undefined offset: 0 in field_kaltura_field_formatter_view() (line 724 of /var/www/drupal-7.8/sites/all/modules/kaltura/plugins/field_kaltura/field_kaltura.module).
Notice: Undefined index: en in kaltura_node_update_index() (line 204 of /var/www/drupal-7.8/sites/all/modules/kaltura/kaltura.module).
Warning: Invalid argument supplied for foreach() in kaltura_node_update_index() (line 204 of /var/www/drupal-7.8/sites/all/modules/kaltura/kaltura.module).
Notice: Undefined variable: text in kaltura_node_update_index() (line 214 of /var/www/drupal-7.8/sites/all/modules/kaltura/kaltura.module).

4. I enter "apple" in searching space of drupal and I get the following error

Notice: Undefined offset: 0 in field_kaltura_field_formatter_view() (line 723 of /var/www/drupal-7.8/sites/all/modules/kaltura/plugins/field_kaltura/field_kaltura.module).
Notice: Undefined offset: 0 in field_kaltura_field_formatter_view() (line 724 of /var/www/drupal-7.8/sites/all/modules/kaltura/plugins/field_kaltura/field_kaltura.module).
Warning: mb_strlen() expects parameter 1 to be string, array given in drupal_strlen() (line 441 of /var/www/drupal-7.8/includes/unicode.inc).
Warning: preg_match_all() expects parameter 2 to be string, array given in kaltura_replace_tags() (line 33 of /var/www/drupal-7.8/sites/all/modules/kaltura/includes/kaltura.themeing.inc).
Warning: Invalid argument supplied for foreach() in kaltura_replace_tags() (line 36 of /var/www/drupal-7.8/sites/all/modules/kaltura/includes/kaltura.themeing.inc).

#5

One more thing...

When I try deactivate the "Tradition Chinese" in language setting, the same error still occur:


Warning: mb_strlen() expects parameter 1 to be string, array given in drupal_strlen() (line 441 of /var/www/drupal-7.8/includes/unicode.inc).
Warning: preg_match_all() expects parameter 2 to be string, array given in kaltura_replace_tags() (line 33 of /var/www/drupal-7.8/sites/all/modules/kaltura/includes/kaltura.themeing.inc).
Warning: Invalid argument supplied for foreach() in kaltura_replace_tags() (line 36 of /var/www/drupal-7.8/sites/all/modules/kaltura/includes/kaltura.themeing.inc).

Also, I futher disable the "locale" module, the above error still occur.

Kinglok, Fong

#6

I was getting these same error messages so I added the following code:

In the Kaltura.module on line 218, replaced:

$node->body = kaltura_replace_tags($node->body, FALSE, TRUE);

With:

$node->body = kaltura_replace_tags(@$node->body, FALSE, TRUE);

Then in the file /includes/kaltura.themeing.inc, I added the following code:

if (is_array($content)){
return '';
}

As the first line of the following function on line 19:
function kaltura_replace_tags($content, $is_comment = FALSE, $replace_to_thumb = FALSE, $edit_mix_access = FALSE, $show_embed = FALSE, $content_type = null) {

Although these changes do not permanently fix the problem, they will allow the Search function to work.

#7

$node->body is an array in D7, as opposed to a string it was in D6. So I believe the following might be closer to what we need in kaltura_node_search_result():

<?php
if (isset($node->body)) {
 
$node->body[LANGUAGE_NONE][0]['value'] = kaltura_replace_tags($node->body[LANGUAGE_NONE][0]['value'], FALSE, TRUE);
 
$node->body[LANGUAGE_NONE][0]['safe_value'] = kaltura_replace_tags($node->body[LANGUAGE_NONE][0]['safe_value'], FALSE, TRUE);
}
?>

(EDIT: Added isset check; nodes do not necessarily have the body field)

The kaltura_replace_tags() function is meant to be used in the above way, and therefore if the function can not do anything with the passed in $content, it is expected to return it back intact. If it did not, it would erase all content in every place where it fails to do its job. To follow this pattern, it might be better for the the check in the first line of kaltura_replace_tags() to do the following:

<?php
if (is_array($content)){
  return
$content;
}
?>

#8

Status:postponed (maintainer needs more info)» closed (fixed)

removed function don't seem to have point in the way drupal 7 module is implemented.

#9

Thanks a lot. It solves the problem.

nobody click here