Wireguard: fix PHP error on import#2400
Conversation
WalkthroughThe WireGuard update import path now assigns AllowedIPs to a local variable ($allowedIPs), uses it when calling ipfilter, and sets subnets1 via "AllowedIPs=" concatenation with that variable. This replaces direct inline retrieval via _var(...). The diff indicates a potential missing semicolon and an extra closing parenthesis in the assignment. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Please see the documentation for more information. Example: reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"
mode: "warning"
instructions: |
Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).Please share your feedback with us on this Discord post. 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. Comment |
🔧 PR Test Plugin AvailableA test plugin has been generated for this PR that includes the modified files. Version: 📥 Installation Instructions:Install via Unraid Web UI:
Alternative: Direct Download
|
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
emhttp/plugins/dynamix/include/update.wireguard.php(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
emhttp/plugins/dynamix/include/update.wireguard.php (1)
emhttp/plugins/dynamix/include/Wrappers.php (1)
_var(106-108)
| $allowedIPs = _var($import,"AllowedIPs:$n") | ||
| ipfilter($allowedIPs); | ||
| if (_var($import,"TYPE:$n") == 0) $var['subnets1'] = "AllowedIPs=".$allowedIPs); | ||
| } |
There was a problem hiding this comment.
Fix syntax errors and wrong subnets mapping (TYPE 0 should use subnets2).
- Missing semicolon after
$allowedIPs = ... - Extra trailing
)at end of assignment - Logic bug: for
TYPE == 0(even),parseInputexpectssubnets2, notsubnets1
Apply this diff:
- $allowedIPs = _var($import,"AllowedIPs:$n")
- ipfilter($allowedIPs);
- if (_var($import,"TYPE:$n") == 0) $var['subnets1'] = "AllowedIPs=".$allowedIPs);
+ $allowedIPs = _var($import, "AllowedIPs:$n");
+ ipfilter($allowedIPs);
+ if ($vpn == 0 && $allowedIPs !== '') {
+ $var['subnets2'] = "AllowedIPs=".$allowedIPs;
+ }Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In emhttp/plugins/dynamix/include/update.wireguard.php around lines 544-547: fix
the syntax and mapping bug by adding the missing semicolon after the $allowedIPs
assignment, remove the extra trailing parenthesis on the assignment line, and
change the mapping so that when _var($import,"TYPE:$n") == 0 you assign to
$var['subnets2'] (not subnets1); keep the ipfilter($allowedIPs) call as-is and
ensure the assignment uses the sanitized $allowedIPs variable.
Summary by CodeRabbit
Refactor
Bug Fixes