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

Fix a potential malformed query issue in the relationships_query hook #24

Merged
merged 2 commits into from Nov 27, 2018

Conversation

Projects
None yet
2 participants
@litzinger
Copy link
Contributor

litzinger commented Nov 27, 2018

Overview

When the relationships_query hook is called multiple times from within Bloqs, once for each instance of a block, the first query is fine, but subsequent queries are malformed.

I can't find a way to fix this in Bloqs, b/c the SQL string passed to the hook is malformed before Bloqs even gets to handle it.

Good query:

FROM (`exp_relationships` as L0)
LEFT JOIN `exp_relationships` as L1 ON `L0`.`child_id` = `L1`.`parent_id` OR L1.parent_id = NULL
WHERE `L0`.`fluid_field_data_id` =  0
AND `L0`.`grid_field_id` =  0
AND `L0`.`parent_id` IN (540) 
ORDER BY `L0`.`order` asc

Malformed query:

FROM (`exp_relationships` as L0, `exp_relationships` as L0)
LEFT JOIN `exp_relationships` as L1 ON `L0`.`child_id` = `L1`.`parent_id` OR L1.parent_id = NULL
LEFT JOIN `exp_relationships` as L1 ON `L0`.`child_id` = `L1`.`parent_id` OR L1.parent_id = NULL
WHERE `L0`.`fluid_field_data_id` =  0
AND `L0`.`grid_field_id` =  0
AND `L0`.`parent_id` IN (540) 
AND `L0`.`fluid_field_data_id` =  0
AND `L0`.`grid_field_id` IN (8, '0') 
AND `L0`.`grid_row_id` IN (540) 
ORDER BY `L0`.`order` asc, `L0`.`order` asc

Nature of This Change

  • πŸ› Fixes a bug
  • πŸš€ Implements a new feature
  • πŸ› Refactors existing code
  • πŸ’… Fixes coding style
  • βœ… Adds tests
  • πŸ‘½ Adds new dependency
  • πŸ”₯ Removes unused files / code
  • πŸ”’ Improves security

Is this backwards compatible?

  • Yes
  • No

litzinger added some commits Nov 27, 2018

@kevincupp kevincupp merged commit 194a36b into ExpressionEngine:stability Nov 27, 2018

2 checks passed

ci/circleci: test_php_56 Your tests passed on CircleCI!
Details
ci/circleci: test_php_71 Your tests passed on CircleCI!
Details
@kevincupp

This comment has been minimized.

Copy link
Contributor

kevincupp commented Nov 27, 2018

Darn singletons. Thanks!

kevincupp added a commit that referenced this pull request Dec 6, 2018

Always select a default channel form author on channel settings save
If the author is NULL, the shared form view will automatically select
the first option, which is what happens for new channels.

Closes #24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment