When I enable the unique settings in the scope for the node only I get a message "The author and language fields are not supported within the scope of a single node.".

How can I enable this?

CommentFileSizeAuthor
#8 unique.png60.67 KBetomilin

Comments

arithmetric’s picture

Title: Can't enable unique field on node scope » Can't use author or language with single node scope
Status: Active » Closed (works as designed)

The single node scope is intended for comparing multiple fields of the same type from a single node against each other. Since there is only one author and language per node, it's not clear how or against what these would be compared.

I hope this clarifies the error message.

rwhitehead’s picture

Cannot enable single node scope as rogerpfaff above.

I understand the error message as explained by detour but I do not have locale module enabled (so no language checkbox! - and default value=NULL in module for language) and I do not check "Author" field.

I have tried all combinations of unique fields selected not selected then saved node then tried to set "single node" scope and always get the message "The author and language fields are not supported within the scope of a single node."
Please give us a clue as to why we cannot set this principle feature?
Quite to happy to hack the unique_field.module validation as a quick fix? (I'm looking at this now!)

etomilin’s picture

Component: Miscellaneous » Code
Category: support » bug
Status: Closed (works as designed) » Active

I'm also getting "The author and language fields are not supported within the scope of a single node" with "Single node only" option. And no, I'm not selecting author or language as a unique fileds.

etomilin’s picture

It seems the problem is in line 413 of unique_field.module:
if ($form_state['values']['unique_field_fields'][UNIQUE_FIELD_FIELDS_AUTHOR] == UNIQUE_FIELD_FIELDS_AUTHOR || $form_state['values']['unique_field_fields'][UNIQUE_FIELD_FIELDS_LANGUAGE] == UNIQUE_FIELD_FIELDS_LANGUAGE) {
This check is always passed for some reason.
I'm not a PHP expert, but I think it fails because $form_state['values']['unique_field_fields'][...] returns int(0) if corresponding field is not checked, and UNIQUE_FIELD_FIELDS_AUTHOR/NAME are strings. I'm not sure how PHP handles such situations, but it seems like a cause of a problem.

I changed this line to
if ($form_state['values']['unique_field_fields'][UNIQUE_FIELD_FIELDS_AUTHOR] <> '0' || $form_state['values']['unique_field_fields'][UNIQUE_FIELD_FIELDS_LANGUAGE] <> '0') {
and it fixed the problem for me.

arithmetric’s picture

Version: 6.x-1.2 » 6.x-1.x-dev
Status: Active » Closed (fixed)

This is fixed in the latest dev version (dated 2010-Nov-19 or later).

etomilin’s picture

Version: 6.x-1.x-dev » 6.x-1.3
Status: Closed (fixed) » Active

I'm afraid this issue is still active.
Just updated to 1.3 and I'm still getting 'The author, language, and taxonomy fields are not supported within the scope of a single node.'
And I have only one nodereference field set as unique for this node type.

arithmetric’s picture

Version 1.3 includes a change that should be equivalent to what you suggested in #4. Could you attach a screenshot of the settings you're using to get this error?

etomilin’s picture

StatusFileSize
new60.67 KB

Sure. Sorry for a lot of Russian on it. Most of Unique field setting are untraslated, so I hope it won't be a problem.
The author field is named "Автор". There is no language field since Multilingual support is turned off.
field_oopt_doc_link is multi-valued nodereference field.

etomilin’s picture

Checked it briefly.
"if" expression on line 478 in form validation function evaluates as TRUE in my case:
if ($fval && ($fname === UNIQUE_FIELD_FIELDS_AUTHOR) || ($fname === UNIQUE_FIELD_FIELDS_LANGUAGE) || (strpos($fname, UNIQUE_FIELD_FIELDS_TAXONOMY) === 0)) {

To be more precise, this part of expression makes it TRUE:
(strpos($fname, UNIQUE_FIELD_FIELDS_TAXONOMY) === 0)
Not sure I get the idea of this particular expression or how it was intended to work.
Here is a dump of $form_state['values']['unique_field_fields'] for the form on my screenshot:
Array ( [field_oopt_doc_link] => field_oopt_doc_link [title] => 0 [name] => 0 [field_gis_flag] => 0 [field_gis_comment] => 0 [field_gis_comment2] => 0 [field_status] => 0 [field_creation_date_planned] => 0 [field_reorganized_from] => 0 [field_reorganized_comment] => 0 [field_liquidation_date] => 0 [field_cat] => 0 [field_significance] => 0 [field_status_international] => 0 [field_doc_bio] => 0 [field_doc_vbo] => 0 [field_doc_kot] => 0 [field_doc_unesco] => 0 [field_doc_net] => 0 [field_oopt_network] => 0 [field_profile] => 0 [field_creation_date] => 0 [field__political_devision] => 0 [field_cadastr] => 0 [field_cadastr2] => 0 [field_clast] => 0 [field_oopt_area] => 0 [field_gp] => 0 [field_oopt_area_water] => 0 [field_oopt_area_non_withdrawn] => 0 [field_borders] => 0 [field_nature_features] => 0 [field_oopt_area_safe] => 0 [field_biology] => 0 [field_explanation] => 0 [field_zoning] => 0 [field_negative_influence] => 0 [field_protected] => 0 [field_oopt_included] => 0 [taxonomy:1] => 0 [taxonomy:2] => 0 [taxonomy:3] => 0 [taxonomy:4] => 0 [taxonomy:5] => 0 [taxonomy:10] => 0 [taxonomy:6] => 0 )
Expression strpos($fname, UNIQUE_FIELD_FIELDS_TAXONOMY) === 0 obviously returns TRUE for elements like [taxonomy:1] => 0 thus failing form validation.

arithmetric’s picture

Version: 6.x-1.3 » 6.x-1.x-dev
Status: Active » Fixed

Thanks for following up with me on this. I found a bug in the validation logic. I've committed a fix. Could you test if the new development release resolves this (dated 2010/12/05 or later)?

etomilin’s picture

New dev version works perfectly. Thanks.

arithmetric’s picture

Excellent. Thanks for reviewing. I'll roll a new stable version soon.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.