Skip to content
This repository was archived by the owner on Sep 29, 2025. It is now read-only.

Fix PHP 8.4 compatibility issues - Resolves fatal error and warnings#23

Open
nukeador wants to merge 1 commit into
masterfrom
php84-compatibility
Open

Fix PHP 8.4 compatibility issues - Resolves fatal error and warnings#23
nukeador wants to merge 1 commit into
masterfrom
php84-compatibility

Conversation

@nukeador
Copy link
Copy Markdown

Summary

This PR resolves critical PHP 8.4 compatibility issues that were preventing the ISOC WordPress theme from functioning properly on modern PHP versions.

Issues Fixed

Root Causes

  1. Undefined Constant: The OD_ENV constant was referenced but never defined, causing fatal errors that prevented front-end loading
  2. Missing Array Key: The theme creates a "Not found" page but the color array didn't include this key, generating PHP 8+ warnings

Changes Made

1. Fixed Undefined Constant (footer.php)

// Before
<?php if(OD_ENV == 'local') : ?>

// After  
<?php if(defined('OD_ENV') && OD_ENV == 'local') : ?>

2. Fixed Array Key Issue (od/includes/hooks-setup.php)

// Added missing color entry
$aBaseColors = array(
    'News'          => 'beige',
    'Events'        => 'blue',
    'European news' => 'turquoise',
    'About'         => 'purple',
    'Contact'       => 'yellow',
    'Not found'     => 'beige'  // ← Added this line
);

// Added safety fallback
$color = isset($aBaseColors[$oPage->post_title]) ? $aBaseColors[$oPage->post_title] : 'beige';

Testing Environment

  • WordPress: 6.8.2
  • PHP: 8.4.13
  • Database: MySQL 8.0
  • Environment: Docker containerized testing

Test Results

Before Fixes ❌

  • Fatal error on front-end preventing page load
  • PHP warnings in admin area
  • Theme partially functional

After Fixes ✅

  • Front-end loads completely without errors
  • Admin area works without warnings
  • All theme functionality preserved
  • Plugin dependency notices work correctly

Plugin Dependencies

Theme continues to properly handle required/recommended plugins:

  • Required: Advanced Custom Fields, Events Manager
  • Recommended: Regenerate Thumbnails, Wordfence Security

Backwards Compatibility

✅ These fixes are fully backwards compatible with older PHP versions (7.4+) and maintain all existing functionality.

Related Issues


Tested and verified working on PHP 8.4.13 with full WordPress functionality intact.

- Fix undefined array key 'Not found' in hooks-setup.php by adding missing color entry and safety fallback
- Fix undefined constant OD_ENV in footer.php by adding proper defined() check
- Theme now loads without fatal errors or warnings on PHP 8.4.13

Fixes #[issue-number]
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use of undefined constant OD_ENV Undefined Constant

1 participant