Skip to content

Conversation

@marcusquinn
Copy link
Contributor

Fix issue #49: Add null checks to prevent errors in domain mapping

Description

This PR addresses issue #49 where domain mapping is broken in 2.4.0-beta. The error occurs when trying to call get_path() on a site object that doesn't exist, resulting in a fatal error:

PHP Fatal error: Uncaught Error: Call to a member function get_path() on false in inc/class-domain-mapping.php:476

Changes Made

  • Added null checks in the replace_url method to verify that both the mapping and site objects exist before trying to use them
  • Added similar checks in the mangle_url method to prevent errors when the site doesn't exist
  • Added checks in the fix_srcset method to ensure we have a valid mapping before processing
  • Improved code organization by storing the site object in a variable for better readability

Benefits

  • Prevents fatal errors when a domain mapping exists but the associated site doesn't
  • Gracefully falls back to the original URL when a mapping is invalid
  • Improves overall stability of the domain mapping functionality

Testing

  1. Set up a domain mapping for a site
  2. Delete the site but keep the domain mapping
  3. Try to access the mapped domain
  4. Verify that no fatal errors occur

Fixes #49

@superdav42 superdav42 self-requested a review July 4, 2025 21:39
Copy link
Collaborator

@superdav42 superdav42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me

@superdav42 superdav42 merged commit 8ce5313 into Multisite-Ultimate:main Jul 4, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Domain mapping broken in 2.4.0-beta

2 participants