Skip to content

fix: resolve PHP 8.1+ TypeError that hides Save button on Domain Mapping settings (#823)#824

Merged
superdav42 merged 1 commit intomainfrom
feature/auto-20260413-124559
Apr 13, 2026
Merged

fix: resolve PHP 8.1+ TypeError that hides Save button on Domain Mapping settings (#823)#824
superdav42 merged 1 commit intomainfrom
feature/auto-20260413-124559

Conversation

@superdav42
Copy link
Copy Markdown
Collaborator

@superdav42 superdav42 commented Apr 13, 2026

Summary

Fixes the "Domain mapping no way to save" bug (GH#823).

Root cause: DNS_Record_Manager::add_dns_settings() registered dns_record_types_allowed as a multiselect field with options defined as plain strings ('A' => 'A (IPv4 Address)'). The field-multiselect.php template accessed $option['title'] on each option. On PHP 8.1+, accessing a string value with a non-integer string key throws TypeError: 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: Convert dns_record_types_allowed options 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

# Verify no TypeError during domain-mapping form rendering
wp --path=../wordpress --user=admin eval '
$sections = WP_Ultimo()->settings->get_sections();
$section = $sections["domain-mapping"];
$fields = array_filter($section["fields"] ?? [], fn($item) => current_user_can($item["capability"]));
uasort($fields, "wu_sort_by_order");
$fields["save"] = ["type" => "submit", "title" => "Save Settings"];
ob_start();
$form = new \WP_Ultimo\UI\Form("domain-mapping", $fields, ["views" => "admin-pages/fields", "html_attr" => ["data-state" => "{}"]]);
$form->render();
$html = ob_get_clean();
echo (strpos($html, "Save Settings") !== false ? "PASS: Save button present" : "FAIL: Save button missing") . "\n";
'

Visit Settings > Domain Mapping in network admin — the "Save Settings" button now renders correctly on PHP 8.1+.

Resolves #823

Summary by CodeRabbit

  • Refactor
    • Updated DNS record type options data structure for improved consistency.
    • Enhanced multiselect field rendering to support flexible option formats with backward compatibility.

…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
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 13, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d1923a6a-e85d-4bbb-a86b-2d800e22631a

📥 Commits

Reviewing files that changed from the base of the PR and between b2b64c4 and c3f9cf3.

📒 Files selected for processing (2)
  • inc/managers/class-dns-record-manager.php
  • views/admin-pages/fields/field-multiselect.php

📝 Walkthrough

Walkthrough

The DNS record types option structure was refactored from direct string values to associative arrays with a title key. The multiselect field template was updated to support both option formats for backward compatibility during rendering.

Changes

Cohort / File(s) Summary
DNS Record Options Structure
inc/managers/class-dns-record-manager.php
Changed DNS record type keys (A, AAAA, CNAME, MX, TXT) option values from direct translated strings to associative arrays containing a title key with the translated string.
Multiselect Field Rendering
views/admin-pages/fields/field-multiselect.php
Updated option rendering to detect and handle both string and array option formats. Added null-coalescing logic to derive option_title and option_desc with appropriate defaults based on option type.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 DNS records neatly arranged,
In structured arrays, beautifully changed,
Old strings and new arrays both sing,
The multiselect field handles everything! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main bug fix: resolving a PHP 8.1+ TypeError that prevents the Save button from displaying on Domain Mapping settings.
Linked Issues check ✅ Passed The PR directly addresses issue #823 by fixing the TypeError in the Domain Mapping form rendering, restoring the ability to save Domain Mapping settings as required.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the Domain Mapping form rendering issue: DNS option format conversion and multiselect template backward compatibility.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/auto-20260413-124559

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

🔨 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!
Playground support for multisite is very limitied, hopefully it will get better in the future.

🚀 Launch in Playground

Login credentials: admin / password

@github-actions
Copy link
Copy Markdown

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: /

Run DB Queries Memory Before Template Template WP Total LCP TTFB LCP - TTFB
0 41 37.80 MB 863.00 ms (+29.00 ms / +3% ) 151.00 ms (-5.50 ms / -4% ) 1049.00 ms 2040.00 ms 1943.15 ms 86.10 ms (-4.25 ms / -5% )
1 56 49.02 MB 931.00 ms 144.50 ms 1074.50 ms 2046.00 ms 1968.75 ms 80.45 ms

@superdav42 superdav42 merged commit ecfa580 into main Apr 13, 2026
10 of 13 checks passed
@superdav42 superdav42 deleted the feature/auto-20260413-124559 branch April 13, 2026 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Domain mapping no way to save

1 participant