fix: scope Bulk auto-populate config branch to Document payloads - #2304
fix: scope Bulk auto-populate config branch to Document payloads#2304ruflin wants to merge 1 commit into
Conversation
`Bulk::_processResponse()` had a missing pair of parentheses around the
auto-populate condition:
if ($data instanceof Document && $data->isAutoPopulate()
|| $this->_client->getConfigValue(['document', 'autoPopulate'], false)
)
Because `&&` binds tighter than `||`, the global `document.autoPopulate`
config caused `setVersionParams()` to run on any bulk action data,
including `Script` payloads, polluting them with response metadata they
don't use.
Wrap the disjunction so the `Document` instance check applies to the
whole branch. Add a unit-level regression test that synthesises a bulk
response and asserts a Script's params remain untouched.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR fixes a bug in Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 3/8 reviews remaining, refill in 30 minutes and 42 seconds.Comment |
There was a problem hiding this comment.
Pull request overview
Fixes a boolean operator precedence issue in bulk response processing so the global document.autoPopulate configuration only triggers version-parameter population for Document payloads (and not Script payloads), aligning Bulk behavior with other response-handling paths in the codebase.
Changes:
- Parenthesized the auto-populate condition in
Bulk::_processResponse()soinstanceof Documentscopes the entire check. - Added a unit regression test asserting Script payloads are not populated with version/seq_no/primary_term when global auto-populate is enabled.
- Documented the fix in the changelog.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/Bulk.php | Fixes &&/` |
| tests/BulkTest.php | Adds regression coverage to ensure Script payloads are not mutated by _processResponse() under global auto-populate. |
| CHANGELOG.md | Records the bugfix under Unreleased → Fixed. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Elastica\Bulk::_processResponse()had a precedence bug:Because
&&binds tighter than||, the globaldocument.autoPopulateconfig caused
setVersionParams()to run on any bulk action data —including
Scriptpayloads — polluting them with response metadata(
_version,_seq_no,_primary_term) they have no use for.The fix wraps the disjunction so the
Documentinstance check appliesto the whole condition.
A new unit test synthesises a bulk response and asserts a Script payload
remains untouched. The test fails on the previous code and passes after
the fix (verified locally on PHP 8.5).
Identified during a P0/P1 code-review pass.
Test plan
Summary by CodeRabbit