Host and php 8.5 errors on 3.84
1 posts by 1 authors in: Forums > CMS Builder
Last Post: Yesterday at 11:21pm (RSS)
By rez - Yesterday at 11:21pm - edited: Yesterday at 11:27pm
Migrating a site to Hostinger
I'm in the process of migrating a site to Hostinger (PHP 8.x / CMSB v3.84) and ran into a couple of issues. One was a deprecation notice, but the other was a fatal error caused by server-level restrictions.
This suppressed
Issue 2: PHP 8.1+ Deprecation Notice in Media Library (_media)
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
When it happens:Opening the Media Library list view (admin.php?menu=_media).
But pages wouldn't load for the following. I used AI to put together a quick compatibility plugin to handle this. I’d appreciate a quick sanity check.
Fatal error with disk_total_space() and disk_free_space() on Hostinger / shared cloud hosts
disk_total_space and disk_free_space are in PHP's disable_functions list in php.ini.
In PHP 8+, calling a disabled function results in a fatal Call to undefined function error. Even though core uses the @ suppression operator (e.g., @disk_total_space(__DIR__)), @ does not catch or suppress fatal undefined function errors in PHP.
I may have more control in shared space hPanel to toggle some things off (don't know yet, coming from cPanel) but the plugin solution seems to work.
Both errors have been resolved with the simple plugin. Am I good?
Why Did This Happen?
On Hostinger Cloud / shared hosting, PHP hasdisk_total_spaceanddisk_free_spacelisted in the server'sdisable_functionsdirective inphp.ini(standard cloud container security to prevent users from querying server-wide hardware partitions).
InteractiveTools core code calls:
@disk_total_space(__DIR__)inGeneral Settings(to display the server disk space bar).@disk_free_space(...)inBackup and Restore(to check free space before database snapshots).
In PHP, when a function is indisable_functions, PHP disables it completely. Because the function doesn't exist, PHP throws a fatalCall to undefined functionerror (the@suppression operator in PHP does not suppress undefined function fatal errors).
The Clean Solution (Zero Core Edits)
Following the rule to keep InteractiveTools core files 100% clean and upgrade-safe, we implemented this via CMSB's officialPlugin Architecture:
-
Created a Compatibility Plugin:
manage/plugins/hostinger_compatibility.phpBecause PHP's
disable_functionsprevents the internal function from being declared, PHP allows userland plugins to safely define the function as a polyfill:<?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 & Verified: Both General Settings and Backup and Restore now load and execute with zero errors.