fix: resolve PHP 8.1+ TypeError that hides Save button on Domain Mapping settings (#823)#824
Conversation
…ing settings
The dns_record_types_allowed multiselect field in DNS_Record_Manager registered
options as plain strings ('A' => 'A (IPv4 Address)'), but the field-multiselect.php
template expected array format (['title' => '...']). On PHP 8.1+, accessing a string
with a non-integer string key ($string['title']) throws a TypeError, which interrupted
form rendering before the Save Settings button could be rendered.
Fix:
- Convert dns_record_types_allowed options to array format with 'title' key
- Harden field-multiselect.php template to support both string and array option
formats for backward compatibility
Fixes #823
|
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 (2)
📝 WalkthroughWalkthroughThe DNS record types option structure was refactored from direct string values to associative arrays with a Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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. Comment |
🔨 Build Complete - Ready for Testing!📦 Download Build Artifact (Recommended)Download the zip build, upload to WordPress and test:
🌐 Test in WordPress Playground (Very Experimental)Click the link below to instantly test this PR in your browser - no installation needed! Login credentials: |
|
Performance Test Results Performance test results for c59a9ae are in 🛎️! Note: the numbers in parentheses show the difference to the previous (baseline) test run. Differences below 2% or 0.5 in absolute values are not shown. URL:
|
Summary
Fixes the "Domain mapping no way to save" bug (GH#823).
Root cause:
DNS_Record_Manager::add_dns_settings()registereddns_record_types_allowedas a multiselect field with options defined as plain strings ('A' => 'A (IPv4 Address)'). Thefield-multiselect.phptemplate accessed$option['title']on each option. On PHP 8.1+, accessing a string value with a non-integer string key throwsTypeError: Cannot access offset of type string on string, which interrupted form rendering before the Save Settings button could be output.Changes:
inc/managers/class-dns-record-manager.php: Convertdns_record_types_allowedoptions from plain strings to the['title' => '...']array format expected by the multiselect template.views/admin-pages/fields/field-multiselect.php: Harden the template to support both string and array option formats for backward compatibility with any existing multiselect fields that use plain strings.Testing
Visit Settings > Domain Mapping in network admin — the "Save Settings" button now renders correctly on PHP 8.1+.
Resolves #823
Summary by CodeRabbit