Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dotline created an issue. See original summary.

Synflag’s picture

Hi,
I can confirm this. It results in duplicate entries (reduce duplicate entries/pure distinct in views database settings wasn´t helping).
When I turn off natural sort the duplicate entries are gone.
Greetings
Lars

generalredneck’s picture

Looking into this.

generalredneck’s picture

Status: Active » Postponed (maintainer needs more info)

Yall have any idea on how to reproduce this? when are you seeing the notice? what kinda of entities / content are you sorting naturally?

generalredneck’s picture

also see if you have the same issues after upgrading to 2.4

dotline’s picture

FileSize
222.69 KB
138.11 KB

Hey,
Yes i installed the 2.4 and still have the message on the view page.
Sorting on title of a Taxonomy term view has term
See att for pic

Warning: Invalid argument supplied for foreach() in views_join->build_join() (regel 1548 van /data/sites/web/.../www/sites/all/modules/views/includes/handlers.inc).
Warning: Invalid argument supplied for foreach() in views_join->build_join() (regel 1548 van /data/sites/web/.../www/sites/all/modules/views/includes/handlers.inc).
Warning: Invalid argument supplied for foreach() in views_join->build_join() (regel 1548 van /data/sites/web/.../www/sites/all/modules/views/includes/handlers.inc).
Warning: Invalid argument supplied for foreach() in views_join->build_join() (regel 1548 van /data/sites/web/.../www/sites/all/modules/views/includes/handlers.inc).

generalredneck’s picture

@dotline
can you do me 2 more favors.

Turn on view query in views settings and screenshot or copy and paste the query here.

Next if you wouldn't mind dumping the views_natural_sort table and attaching it as a .txt that would be cool.

Lastly how many languages does the site have? Is the one you are sorting the main site language?

dotline’s picture

Version: 7.x-2.3 » 7.x-2.4

Language:

Dutch as default
English active

What do you mean en how dumping the views_natural_sort table

query:

SELECT DISTINCT node.nid AS nid, vns_field_data_title_field.content AS vns_field_data_title_field_content, 'node' AS field_data_field_image_node_entity_type, 'node' AS field_data_title_field_node_entity_type, 'node' AS field_data_field_body_node_entity_type, 'node' AS field_data_body_node_entity_type, 'node' AS field_data_field_link_node_entity_type
FROM
{node} node
LEFT JOIN {field_data_field_product} field_data_field_product ON node.nid = field_data_field_product.entity_id AND (field_data_field_product.entity_type = 'node' AND field_data_field_product.deleted = '0')
LEFT JOIN {commerce_product} commerce_product_field_data_field_product ON field_data_field_product.field_product_product_id = commerce_product_field_data_field_product.product_id
LEFT JOIN {field_data_title_field} field_data_title_field ON node.nid = field_data_title_field.entity_id AND (field_data_title_field.entity_type = 'node' AND field_data_title_field.deleted = '0')
LEFT JOIN {views_natural_sort} vns_field_data_title_field ON field_data_title_field.entity_id = vns_field_data_title_field.eid
WHERE (( (node.status = 1 OR (node.uid = 1 AND 1 <> 0 AND 1 = 1) OR 1 = 1) AND (node.nid IN (SELECT tn.nid AS nid
FROM
{taxonomy_index} tn
WHERE ( (tn.tid = '10') ))) )AND(( (node.type IN ('page', 'licenses_file', 'licenses_role')) )))
ORDER BY vns_field_data_title_field_content ASC

rachelp’s picture

I have the views natural sort module enabled and also receive this error when my search query is two or more words long and one of the words is less than 3 characters long. For example, I get the error when I search "if only" but no error with "this works"

generalredneck’s picture

either show the output of SELECT * from views_natural_sort

Or do a SQL dump of that table

Ryan Osītis’s picture

The issue is due to a fix that was released in the latest version of Views, as discussed here:

https://www.drupal.org/node/1930288

A number of modules, including this one, are experiencing problems due to the change.

https://www.drupal.org/node/2866370

Ryan Osītis’s picture

artis’s picture

This issue is being cause by the $extra parameter on the views sort handler for text fields being a string instead of an array.

Replace the 'extra' parameter on lines 34-36 in /handers/views_natural_sort_handler_sort_text_field.inc with:

      'extra' => array(
        array(
          'field' => 'delta',
          'value' => $this->table_alias . '.delta',
        ),
        array(
          'field' => 'entity_type',
          'value' => $table_data['table']['entity type'],
        ),
        array(
          'field' => 'field',
          'value' => preg_replace('/_value$/', '', $this->field),
        ),
      ),

Patch will follow.

artis’s picture

Title: After update views 7-3.16 » Broken sql left_join in natural sort text fields due to 'extras' parameter not array
Version: 7.x-2.4 » 7.x-2.x-dev
Status: Postponed (maintainer needs more info) » Needs review
FileSize
0 bytes

Changed the Title to be more descriptive of problem.

Attached is patch on 7.x-2.x

Status: Needs review » Needs work

The last submitted patch, 14: fix_left_join_extras_2866668_14.patch, failed testing.

generalredneck’s picture

@artis,
Your patch is 0 bytes. Seems you uploaded an empty file.

generalredneck’s picture

Rolled the patch that was left in #13. Somehow it works without all the mumbo jumbo about having to worry about the VNS alias and what not... Views has gotten smarter over time adding joins it seems. What I would love to see here are tests.

generalredneck’s picture

Status: Needs work » Needs review

Bah forgot the Needs Review status.

generalredneck’s picture

FileSize
87.26 KB

So I went through and started to make tests. The challenge I'm facing is that for some reason the views_natural_sort handler isn't being applied... but only during the tests. I feel strongly that this is a caching thing... but I can't figure it out thus far. Via my debugging... I've found out that views_natural_sort_text_field_get_configured_fields() and views_natrual_sort_text_get_potential_fields() are both working in finding the field, but it seems that the hook over in views_natural_sort_text_field.views.inc doesn't seem to be called during tests. Running drush en views_natural_sort_text_field_test views_ui; drush eval "views_natural_sort_text_field_test_views_create_test_content();" and then navigating to admin/structure/views/view/views_natural_sort_text_field_test/edit shows everything sorting correctly.

I'll add a seperate issue fixes tests, but rest assure that this is something in the works. You can see this over at http://cgit.drupalcode.org/views_natural_sort/log/?h=7.x-2.x-text_field_...

  • generalredneck committed e901b17 on 7.x-2.x
    Issue #2866668 by generalredneck, artis, dotline: Broken sql left_join...
generalredneck’s picture

Status: Needs review » Fixed

Gonna mark this one as fixed and get a new release out so that other people don't have so many problems.

artis’s picture

Well, that's embarrassing (the empty file), but thanks for taking this and running with it.

Status: Fixed » Closed (fixed)

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