I have site, where main language is russian and user can't select answer as best answer. I tried to debug it and what I see in the question_answer.pages.inc
$node->{$qtype[$node->type]['answer']}[$node->language][0]['value'] = ($action == 'deselect') ? NULL : $cid;
if I print_r($node); I see:
[field_question_best] => Array
(
[ru] => Array
(
[0] => Array
(
[value] => 72
)
)
)
and after node_save() field is still empty. If I add value manually through the node edit form and print_r($node); i see
[field_question_best] => Array
(
[und] => Array
(
[0] => Array
(
[value] => 72
)
)
)
So this field have no language. And when I change row to
$node->{$qtype[$node->type]['answer']}[LANGUAGE_NONE][0]['value'] = ($action == 'deselect') ? NULL : $cid;
everything works like a charm.
May be numeric field is not translatable, so we need everywhere in a module use LANGUAGE_NONE instead of $node->language?
Comment | File | Size | Author |
---|---|---|---|
#9 | question_answer.diff | 1.62 KB | vpiotr |
#8 | question_answer.pages_.inc_.patch | 700 bytes | vpiotr |
#8 | question_answer.module.patch | 1.42 KB | vpiotr |
#4 | field_translatable_state_check-1790400-4.patch | 4.46 KB | Cray Flatline |
Comments
Comment #1
jcisio CreditAttribution: jcisio commentedThat could be it. If we found somewhere when a numeric field is marked translatable = FALSE (or a text field with translatable = TRUE), I'll be comfortable to change that code. I searched in the field and locale modules but did not find it ;(
Comment #2
Cray Flatline CreditAttribution: Cray Flatline commentedI'm not sure but I think we have to look field settings in the field_config table. We need to get row for our field and look for value of "translatable". If it is set to 1 - we should use $node->language. Otherwise, we should use LANGUAGE_NONE.
I will try to debug it on a dev environment, but it is not so easy for me, because my drupal kung-fu is not so strong :)
Comment #3
Cray Flatline CreditAttribution: Cray Flatline commentedI can try to fix it using field_info_field($field_name) to retrieve field info, but I'm not sure I'm enough to correctly create a patch. Or it's better if you make it by yourself?
Comment #4
Cray Flatline CreditAttribution: Cray Flatline commentedI've created patch for this issue. Please review it, because It's my first patch ;)
I've tested it on my local environment, it works correctly.
Comment #5
jcisio CreditAttribution: jcisio commentedThere were a few locale support changes in the last Drupal 7 minor releases. We should check it with the last release.
Comment #6
Maks CreditAttribution: Maks commentedAfter applying this patch I had a lot of errors: Notice: Undefined index: rubrics в функции question_answer_preprocess() (строка 187 в файле /home/****/****/*****/sites/all/modules/question_answer/question_answer.module).
"rubrics" - the machine name of the content type, but this bug is present with all content types
--------
У меня не важный английский, поэтому повторю на русском.
После применения патча, постоянно куча ошибок в Журнале: Notice: Undefined index: rubrics в функции question_answer_preprocess() (строка 187 в файле /home/****/****/*****/sites/all/modules/question_answer/question_answer.module).
В данном случае указана ошибка с типом Рубрики, но это происходит и со всеми остальными типами.
Также, не понятно что именно должно выводиться, как выбранный комментарий: Сам комментарий или только ссылка на него? У меня выводится Имя и Дата, как ссылка на сам комментарий.
С уважением,
Comment #7
jcisio CreditAttribution: jcisio commentedComment #8
vpiotr CreditAttribution: vpiotr commentedQuick workaround:
There is a problem with saving field to database using a selected (not unknown / default) node language.
I don't know why, but in the attachment you can find workaround.
1) Patch question_answer.pages.inc to save "selected answer" field using "undefined" language.
2) Patch question_answer.module to load "selected answer"
a) using selected language and if not found:
b) using "undefined language"
This patch will work even when saving in selected language will be fixed.
Comment #9
vpiotr CreditAttribution: vpiotr commentedA more safe version of my patch in attachment (use it instead of my previous patch for file "question_answer.module").
Comment #10
jcisio CreditAttribution: jcisio commentedA hunk in the .pages.inc file in #8 was missing in #9. Also coding standards are not respected.
Comment #10.0
jcisio CreditAttribution: jcisio commentedfixed some typo