Unactioned Review Feedback
Source PR: #751
File: inc/checkout/class-cart.php
Reviewers: coderabbit
Findings: 2
Max severity: critical
HIGH: coderabbit (coderabbitai[bot])
File: inc/checkout/class-cart.php:2224
π οΈ Refactor suggestion | π Major
Use Yoda condition per coding guidelines.
As per coding guidelines, production code should use Yoda conditions ('value' === $var):
- if ($this->cart_type === 'reactivation') {
+ if ('reactivation' === $this->cart_type) {
return false;
}
The logic itself is correct β blocking trial periods for reactivation carts prevents abuse where customers could repeatedly cancel and resubscribe to get unlimited trials.
π Committable suggestion
βΌοΈ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
if ('reactivation' === $this->cart_type) {
return false;
}
π€ Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@inc/checkout/class-cart.php` around lines 2222 - 2224, Replace the non-Yoda
comparison in the reactivation cart check so it follows coding guidelines:
locate the conditional that currently reads ($this->cart_type ===
'reactivation') in the Cart class (use the $this->cart_type symbol to find it)
and change it to the Yoda form ('reactivation' === $this->cart_type) while
preserving the early return (return false;) and surrounding logic.
β
Addressed in commit 955de38
CRITICAL: coderabbit (coderabbitai[bot])
File: inc/checkout/class-cart.php:932
β οΈ Potential issue | π΄ Critical
π§© Analysis chain
π Script executed:
#!/bin/bash
# Verify the return structure of get_addon_products()
rg -n -A 20 "public function get_addon_products\(\)" inc/models/class-membership.php
Repository: Ultimate-Multisite/ultimate-multisite
Length of output: 573
π Script executed:
#!/bin/bash
# Check the exact code at lines 921-925
sed -n '918,926p' inc/checkout/class-cart.php | cat -n
# Also verify the add_product() method signature to ensure the proposed fix is compatible
rg -n "public function add_product" inc/checkout/class-cart.php -A 5
Repository: Ultimate-Multisite/ultimate-multisite
Length of output: 711
Critical bug: get_addon_products() iteration destructures array incorrectly.
The function returns an array of associative arrays: [['quantity' => 1, 'product' => Product], ...], but the foreach loop iterates as foreach ($addon_products as $addon_id => $quantity), which yields numeric indices (0, 1, 2...) as $addon_id and the full associative array as $quantity.
This causes add_product((int) $addon_id, (int) $quantity) to add product IDs 0, 1, 2... (which don't exist) instead of the actual product IDs from the Product objects. Addon products will not be added to the cart during reactivation.
Fix
$addon_products = $membership->get_addon_products();
foreach ($addon_products as $addon_data) {
$product = $addon_data['product'];
$this->add_product($product->get_id(), (int) $addon_data['quantity']);
}
π Committable suggestion
βΌοΈ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
$addon_products = $membership->get_addon_products();
foreach ($addon_products as $addon_data) {
$product = $addon_data['product'];
$this->add_product($product->get_id(), (int) $addon_data['quantity']);
}
π€ Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@inc/checkout/class-cart.php` around lines 921 - 925, The foreach over
$membership->get_addon_products() is unpacking items incorrectly; change the
loop to iterate each item (e.g. foreach ($addon_products as $item)) and extract
the product and quantity from the associative keys (item['product'] and
item['quantity']), then call $this->add_product using the actual product ID (for
Product objects call get_id(), otherwise cast the product value to int) and the
quantity cast to int; update the block around get_addon_products(), the foreach,
and the $this->add_product call accordingly so addon products are added with
correct IDs and quantities.
β
Addressed in commit 54e2589
Auto-generated by quality-feedback-helper.sh scan-merged. Review each finding and either fix the code or dismiss with a reason.
To approve or decline, use one of:
sudo aidevops approve issue <number> -- cryptographically signs approval for automated dispatch
- Comment
declined: <reason> -- closes this issue (include your reason after the colon)
aidevops.sh v3.6.166 automated scan.
Unactioned Review Feedback
Source PR: #751
File:
inc/checkout/class-cart.phpReviewers: coderabbit
Findings: 2
Max severity: critical
HIGH: coderabbit (coderabbitai[bot])
File:
inc/checkout/class-cart.php:2224π οΈ Refactor suggestion | π Major
Use Yoda condition per coding guidelines.
As per coding guidelines, production code should use Yoda conditions (
'value' === $var):The logic itself is correct β blocking trial periods for reactivation carts prevents abuse where customers could repeatedly cancel and resubscribe to get unlimited trials.
π Committable suggestion
π€ Prompt for AI Agents
β Addressed in commit 955de38
View comment
CRITICAL: coderabbit (coderabbitai[bot])
File:
β οΈ Potential issue | π΄ Critical
inc/checkout/class-cart.php:932π§© Analysis chain
π Script executed:
Repository: Ultimate-Multisite/ultimate-multisite
Length of output: 573
π Script executed:
Repository: Ultimate-Multisite/ultimate-multisite
Length of output: 711
Critical bug:
get_addon_products()iteration destructures array incorrectly.The function returns an array of associative arrays:
[['quantity' => 1, 'product' => Product], ...], but the foreach loop iterates asforeach ($addon_products as $addon_id => $quantity), which yields numeric indices (0, 1, 2...) as$addon_idand the full associative array as$quantity.This causes
add_product((int) $addon_id, (int) $quantity)to add product IDs 0, 1, 2... (which don't exist) instead of the actual product IDs from the Product objects. Addon products will not be added to the cart during reactivation.Fix
$addon_products = $membership->get_addon_products(); foreach ($addon_products as $addon_data) { $product = $addon_data['product']; $this->add_product($product->get_id(), (int) $addon_data['quantity']); }π Committable suggestion
π€ Prompt for AI Agents
β Addressed in commit 54e2589
View comment
Auto-generated by
quality-feedback-helper.sh scan-merged. Review each finding and either fix the code or dismiss with a reason.To approve or decline, use one of:
sudo aidevops approve issue <number>-- cryptographically signs approval for automated dispatchdeclined: <reason>-- closes this issue (include your reason after the colon)aidevops.sh v3.6.166 automated scan.