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.

Hi rez,

Thanks so much for the detailed report and the workaround!

We've added both fixes for the next release (v3.85): the Media Library deprecation notice, and fallbacks for when a host disables disk_total_space() or disk_free_space(). Your plugin will work around it until then.

We want to support the default configurations of big providers like Hostinger Cloud, so reports like this help. Feel free to post anything else you run into.

Thanks!

Dave Edis - Senior Developer
interactivetools.com