Host and php 8.x errors on 3.84

3 posts by 2 authors in: Forums > CMS Builder
Last Post: 13 hours ago   (RSS)

By rez - October 16 - edited: October 20

Hostinger Migration: PHP 8.x compatibility & disable_functions fatal error

Migrating a site to Hostinger Cloud (CMSB v3.84, testing on PHP 8.1 and 8.5) and ran into two issues:

1. Media Library Deprecation Notice (PHP 8.1+)
- Error: Deprecated: Using null as an array offset is deprecated, use an empty string instead in /lib/menus/default/list_functions.php on line 284
- Trigger: Viewing the Media Library list (admin.php?menu=_media)
- Workaround: Suppressed for now. Edit: set to PHP 8.1

2. Fatal Error: disk_total_space() and disk_free_space()
- Issue: Hostinger disables both functions via disable_functions in php.ini.
- Cause: In PHP 8+, invoking a disabled function throws a fatal "Call to undefined function" error. CMSB core uses @disk_total_space(), but the @ operator does not suppress fatal undefined function errors in PHP 8. This breaks General Settings and Backup and Restore.
- Solution: Because disabled internal functions are not declared, I created a drop-in polyfill plugin (manage/plugins/hostinger_compatibility.php) to safely define them without touching core

<?php
/*
Plugin Name: Hostinger Cloud Compatibility
Description: Provides safe polyfills for Hostinger-disabled PHP functions (disk_total_space, disk_free_space).
Version: 1.00
CMS Version Required: 3.00
*/

if ( ! function_exists('disk_total_space') ) {
    function disk_total_space(string $directory): float|false {
        return 500 * 1024 * 1024 * 1024; // 500 GB fallback
    }
}

if ( ! function_exists('disk_free_space') ) {
    function disk_free_space(string $directory): float|false {
        return 250 * 1024 * 1024 * 1024; // 250 GB fallback
    }
}

Tested and verified on Hostinger - General Settings and Backups now run clean. Sanity check appreciated if core plans to handle disabled space functions differently in future or if I am misunderstanding things.
NOTE: I should probably make this return unverified instead of made-up values.

Thanks Dave. I have since discovered a list of functions I can disable in hPanel that can also resolve this but it's not default as you mentioned.