Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WHERE clause ignored in pods_ui() #5387

Closed
RobEarls opened this issue Jun 6, 2019 · 3 comments

Comments

Projects
None yet
3 participants
@RobEarls
Copy link

commented Jun 6, 2019

Issue Overview

When you call pods_ui() with a WHERE clause, it is never used.

Expected Behavior

Only the rows matching the WHERE clause should be shown

Current Behavior

All rows are returned. (...LIMIT works fine)

Steps to Reproduce (for bugs)

  1. Create a POD called pub, with a field "lessee" (NB: Mine is a relationship field) (Note

  2. Set up options... And call pods_ui()
    $where_params = array(
    'lessee.id' => '3'
    );
    $options = array(
    'pod' => "pub",
    'where' => $where_params,
    "limit" => 313 // Note random number here
    );
    pods_ui($options)

  3. Add &pods_debug_sql=1 to the URL

  4. Note that the result is ALL rows.

  5. Also note the SQL generated is unaffected by the WHERE clause.

SELECT DISTINCT
t., d.
FROM wp_posts AS t
LEFT JOIN wp_pods_pub AS d ON d.id = t.ID
WHERE ( ( t.post_status IN ( "publish" ) ) AND ( t.post_type = "pub" ) )
ORDER BY t.menu_order, t.post_title, t.post_date
LIMIT 0, 313 // Note the random number, to identify the right SQL.

Possible Solution

WordPress Environment

``` WordPress Version: 5.2.1

PHP Version: 7.0.33

MySQL Version: 5.6.39

Server Software: Apache/2.4.39 (cPanel) OpenSSL/1.0.2r mod_bwlimited/1.4

Your User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.80 Safari/537.36

Session Save Path: /var/cpanel/php/sessions/ea-php70

Session Save Path Exists: Yes

Session Save Path Writeable: Yes

Session Max Lifetime: 1440

Opcode Cache:

Apc: No
Memcached: No
OPcache: Yes
Redis: No
Object Cache:

APC: No
APCu: No
Memcache: No
Memcached: No
Redis: No
WPDB Prefix: wp_

WP Multisite Mode: No

WP Memory Limit: 40M

Current Memory Usage: 22.702M

Current Memory Usage (real): 8.000M

Pods Network-Wide Activated: No

Pods Install Location: /home/....../public_html/wp-content/plugins/pods/

Pods Tableless Mode Activated: No

Pods Light Mode Activated: No

Currently Active Theme: Twenty Nineteen

Currently Active Plugins:

Advanced Custom Fields: 5.8.0
Advanced Custom Fields: Image Aspect Ratio Crop: 2.0.3
CIO Custom Fields Importer Pro: 1.01
Code Snippets: 2.13.3
Pods - Custom Content Types and Fields: 2.7.12
UpdraftPlus - Backup/Restore: 1.16.14
WP All Import: 3.5.0

</details>

## Pods Package Export (helpful!)
<!-- Please include the Pods Package Export as it will be helpful in reproducing your issues. -->
<!-- To access: Pods Admin, Components, Migrate: Packages, Enable. -->
<!-- Then Pods Admin, Migrate: Packages, Export and Copy and Paste the JSON here OR -->
<!-- Save to a text file and upload to this bug report -->

{"meta":{"version":"2.7.12","build":1559824352},"pods":{"5":{"id":5,"name":"pub","label":"Pubs","description":"","type":"post_type","storage":"table","object":"","alias":"","fields":{"lessee":{"id":7,"name":"lessee","label":"Lessee","description":"","help":"","class":"","type":"pick","weight":0,"pick_object":"user","pick_val":"","sister_id":"","required":"0","unique":"0","pick_format_type":"single","pick_format_single":"dropdown","pick_format_multi":"checkbox","pick_allow_add_new":"1","pick_taggable":"0","pick_show_icon":"1","pick_show_edit_link":"1","pick_show_view_link":"1","pick_limit":"0","pick_user_role":[],"pick_post_status":["publish"],"admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"rest_read":"0","rest_write":"0","rest_pick_response":"array","rest_pick_depth":"2","pick_select_text":"","pick_table_id":"","pick_table_index":"","pick_display":"","pick_where":"","pick_orderby":"","pick_groupby":""},"house_number":{"id":8,"name":"house_number","label":"House number","description":"","help":"","class":"","type":"text","weight":1,"pick_object":"","pick_val":"","sister_id":"","required":"0","unique":"0","text_allow_shortcode":"0","text_allow_html":"0","text_allowed_html_tags":"strong em a ul ol li b i","text_max_length":"255","pick_post_status":["publish"],"admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"rest_read":"0","rest_write":"0","rest_pick_response":"array","rest_pick_depth":"2","text_repeatable":"0","text_placeholder":""},"street":{"id":9,"name":"street","label":"Street","description":"","help":"","class":"","type":"text","weight":2,"pick_object":"","pick_val":"","sister_id":"","required":"1","unique":"0","text_allow_shortcode":"0","text_allow_html":"0","text_allowed_html_tags":"strong em a ul ol li b i","text_max_length":"255","pick_post_status":["publish"],"admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"rest_read":"0","rest_write":"0","rest_pick_response":"array","rest_pick_depth":"2","text_repeatable":"0","text_placeholder":""},"city":{"id":10,"name":"city","label":"City","description":"","help":"","class":"","type":"text","weight":3,"pick_object":"","pick_val":"","sister_id":"","required":"1","unique":"0","text_allow_shortcode":"0","text_allow_html":"0","text_allowed_html_tags":"strong em a ul ol li b i","text_max_length":"255","pick_post_status":["publish"],"admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"rest_read":"0","rest_write":"0","rest_pick_response":"array","rest_pick_depth":"2","text_repeatable":"0","text_placeholder":""},"postcode":{"id":11,"name":"postcode","label":"Postcode","description":"","help":"","class":"","type":"text","weight":4,"pick_object":"","pick_val":"","sister_id":"","required":"1","unique":"0","text_allow_shortcode":"0","text_allow_html":"0","text_allowed_html_tags":"strong em a ul ol li b i","text_max_length":"255","pick_post_status":["publish"],"admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"rest_read":"0","rest_write":"0","rest_pick_response":"array","rest_pick_depth":"2","text_repeatable":"0","text_placeholder":""},"osd_name":{"id":15,"name":"osd_name","label":"OSD Name","description":"","help":"","class":"","type":"pick","weight":5,"pick_object":"post_type","pick_val":"osd_name","sister_id":"","required":"1","unique":"0","pick_format_type":"single","pick_format_single":"dropdown","pick_format_multi":"checkbox","pick_allow_add_new":"1","pick_taggable":"0","pick_show_icon":"1","pick_show_edit_link":"1","pick_show_view_link":"1","pick_limit":"0","pick_user_role":[],"pick_post_status":["publish"],"admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"rest_read":"0","rest_write":"0","rest_pick_response":"array","rest_pick_depth":"2","pick_select_text":"","pick_table_id":"","pick_table_index":"","pick_display":"","pick_where":"","pick_orderby":"","pick_groupby":""},"bdm":{"id":16,"name":"bdm","label":"BDM","description":"","help":"","class":"","type":"pick","weight":6,"pick_object":"post_type","pick_val":"bdm","sister_id":"","required":"1","unique":"0","pick_format_type":"single","pick_format_single":"dropdown","pick_format_multi":"checkbox","pick_allow_add_new":"1","pick_taggable":"0","pick_show_icon":"1","pick_show_edit_link":"1","pick_show_view_link":"1","pick_limit":"0","pick_user_role":[],"pick_post_status":["publish"],"admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"rest_read":"0","rest_write":"0","rest_pick_response":"array","rest_pick_depth":"2","pick_select_text":"","pick_table_id":"","pick_table_index":"","pick_display":"","pick_where":"","pick_orderby":"","pick_groupby":""},"segmentation":{"id":17,"name":"segmentation","label":"Segmentation","description":"","help":"","class":"","type":"pick","weight":7,"pick_object":"post_type","pick_val":"main_segmentation","sister_id":"","required":"0","unique":"0","pick_format_type":"single","pick_format_single":"dropdown","pick_format_multi":"checkbox","pick_allow_add_new":"1","pick_taggable":"0","pick_show_icon":"1","pick_show_edit_link":"1","pick_show_view_link":"1","pick_limit":"0","pick_user_role":[],"pick_post_status":["publish"],"admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"rest_read":"0","rest_write":"0","rest_pick_response":"array","rest_pick_depth":"2","pick_select_text":"","pick_table_id":"","pick_table_index":"","pick_display":"","pick_where":"","pick_orderby":"","pick_groupby":""},"premium_wines":{"id":12532,"name":"premium_wines","label":"Premium Wines","description":"","help":"","class":"","type":"pick","weight":8,"pick_object":"custom-simple","pick_val":"","sister_id":"","pick_custom":"None\nPremium 1\nPremium 2\nPremium 3\nPremium 4\n","required":"1","unique":"0","pick_format_type":"single","pick_format_single":"dropdown","pick_format_multi":"checkbox","pick_allow_add_new":"1","pick_taggable":"0","pick_show_icon":"1","pick_show_edit_link":"1","pick_show_view_link":"1","pick_limit":"0","pick_user_role":[],"pick_post_status":["publish"],"admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"rest_read":"0","rest_write":"0","rest_pick_response":"array","rest_pick_depth":"2","default_value":"None","pick_select_text":"","pick_table_id":"","pick_table_index":"","pick_display":"","pick_where":"","pick_orderby":"","pick_groupby":""},"mainstream_wines":{"id":12533,"name":"mainstream_wines","label":"Mainstream Wines","description":"","help":"","class":"","type":"pick","weight":9,"pick_object":"custom-simple","pick_val":"","sister_id":"","pick_custom":"None\nMainstream 1\nMainstream 2\nMainstream 3\nMainstream 4","required":"0","unique":"0","pick_format_type":"single","pick_format_single":"dropdown","pick_format_multi":"checkbox","pick_allow_add_new":"1","pick_taggable":"0","pick_show_icon":"1","pick_show_edit_link":"1","pick_show_view_link":"1","pick_limit":"0","pick_user_role":[],"pick_post_status":["publish"],"admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"rest_read":"0","rest_write":"0","rest_pick_response":"array","rest_pick_depth":"2","default_value":"None","pick_select_text":"","pick_table_id":"","pick_table_index":"","pick_display":"","pick_where":"","pick_orderby":"","pick_groupby":""},"community_wines":{"id":12534,"name":"community_wines","label":"Community Wines","description":"","help":"","class":"","type":"pick","weight":10,"pick_object":"custom-simple","pick_val":"","sister_id":"","pick_custom":"None\nCommunity 1\nCommunity 2\nCommunity 3\nCommunity 4","required":"0","unique":"0","pick_format_type":"single","pick_format_single":"dropdown","pick_format_multi":"checkbox","pick_allow_add_new":"1","pick_taggable":"0","pick_show_icon":"1","pick_show_edit_link":"1","pick_show_view_link":"1","pick_limit":"0","pick_user_role":[],"pick_post_status":["publish"],"admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"rest_read":"0","rest_write":"0","rest_pick_response":"array","rest_pick_depth":"2","default_value":"None","pick_select_text":"","pick_table_id":"","pick_table_index":"","pick_display":"","pick_where":"","pick_orderby":"","pick_groupby":""},"value_wines":{"id":12535,"name":"value_wines","label":"Value Wines","description":"","help":"","class":"","type":"pick","weight":11,"pick_object":"custom-simple","pick_val":"","sister_id":"","pick_custom":"None\nValue 1\nValue 2\nValue 3\nValue 4","required":"0","unique":"0","pick_format_type":"single","pick_format_single":"dropdown","pick_format_multi":"checkbox","pick_allow_add_new":"1","pick_taggable":"0","pick_show_icon":"1","pick_show_edit_link":"1","pick_show_view_link":"1","pick_limit":"0","pick_user_role":[],"pick_post_status":["publish"],"admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"rest_read":"0","rest_write":"0","rest_pick_response":"array","rest_pick_depth":"2","default_value":"None","pick_select_text":"","pick_table_id":"","pick_table_index":"","pick_display":"","pick_where":"","pick_orderby":"","pick_groupby":""}},"show_in_menu":"1","label_singular":"Pub","public":"0","show_ui":"1","supports_title":"1","supports_editor":"0","publicly_queryable":"0","exclude_from_search":"0","capability_type":"custom","capability_type_custom":"view_pubs_menu","capability_type_extra":"1","has_archive":"0","hierarchical":"0","rewrite":"1","rewrite_with_front":"1","rewrite_feeds":"0","rewrite_pages":"1","query_var":"1","can_export":"1","default_status":"draft","supports_author":"0","supports_thumbnail":"0","supports_excerpt":"0","supports_trackbacks":"0","supports_custom_fields":"0","supports_comments":"0","supports_revisions":"0","supports_page_attributes":"0","supports_post_formats":"0","built_in_taxonomies_category":"0","built_in_taxonomies_link_category":"0","built_in_taxonomies_post_tag":"0","show_in_nav_menus":"1","show_in_admin_bar":"0","pfat_enable":"0","pfat_run_outside_loop":"0","pfat_append_single":"append","pfat_filter_single":"the_content","pfat_append_archive":"append","pfat_filter_archive":"the_content","rest_enable":"0","read_all":"0","write_all":"0","menu_position":"13","menu_name":"My Pod Pubs"},"12550":{"id":12550,"name":"user","label":"User","description":"","type":"user","storage":"meta","object":"user","alias":"","fields":{"manager":{"id":12551,"name":"manager","label":"Manager","description":"","help":"","class":"","type":"pick","weight":0,"pick_object":"user","pick_val":"","sister_id":"","required":"1","pick_format_type":"single","pick_format_single":"dropdown","pick_format_multi":"checkbox","pick_allow_add_new":"0","pick_taggable":"0","pick_show_icon":"1","pick_show_edit_link":"1","pick_show_view_link":"1","pick_limit":"0","pick_user_role":["area_bdm","bdm","management"],"pick_post_status":["publish"],"admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"rest_read":"0","rest_write":"0","rest_pick_response":"array","rest_pick_depth":"2","unique":"0","pick_select_text":"","pick_table_id":"","pick_table_index":"","pick_display":"","pick_where":"","pick_orderby":"","pick_groupby":""}},"show_in_menu":1,"rest_enable":"0","read_all":"0","write_all":"0"}}}


## Workaround or Alternate Solution Until Bug is Addressed
<!-- We will complete this section, or if you've already found a workaround, -->
<!-- you can add it here -->

## Related Issues and/or PRs
<!-- List related issues or PRs against other branches:  -->
@issue-label-bot

This comment has been minimized.

Copy link

commented Jun 6, 2019

Issue-Label Bot is automatically applying the label Type: Bug to this issue, with a confidence of 0.96. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

@issue-label-bot issue-label-bot bot added the Type: Bug label Jun 6, 2019

@JoryHogeveen

This comment has been minimized.

Copy link
Member

commented Jun 6, 2019

Hello @RobEarls,

After testing I can confirm the where parameter works different. The where parameter is based on the action for the table (manage or reorder).
In your case this would work:

$where_params = array(
   'manage' => array(
      'lessee.id = 3',
   ),
);
$options = array(
   'pod' => "pub",
   'where' => $where_params,
   "limit" => 313 // Note random number here
);
pods_ui($options)

@sc0ttkclark @jimtrue I can understand the confusion here since it's not documented that way (https://pods.io/docs/code/pods-ui/).
From what I understand in the documentation the where parameter should be appended to both manage and reorder actions correct?

@RobEarls

This comment has been minimized.

Copy link
Author

commented Jun 6, 2019

Thanks that worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.