2

I have a website which I need to move but it seems that it doesn't work with PHP7.3.12 due to some old PHP funtions and the old 5.x is not an option this time :(

Firstly I had an error:

Deprecated: __autoload() is deprecated, use spl_autoload_register() instead in /var/www/vhosts/dddd.eu/bbbgg.cdddd.eu/in_site/autoload.php on line 3

Fatal error: Uncaught Error: Call to undefined function sg_load() in /var/www/vhosts/dddd.eu/bbbgg.cdddd.eu/in_site/core/libraries/sql.class/sql.class.php:2 Stack trace: #0 /var/www/vhosts/dddd.eu/bbbgg.cdddd.eu/in_site/autoload.php(83): require_once() #1 [internal function]: __autoload('SQL') #2 /var/www/vhosts/dddd.eu/bbbgg.cdddd.eu/in_site/config.php(70): spl_autoload_call('SQL') #3 /var/www/vhosts/dddd.eu/bbbgg.cdddd.eu/index.php(14): include_once('/var/www/vhosts...') #4 {main} thrown in /var/www/vhosts/dddd.eu/bbbgg.cdddd.eu/in_site/core/libraries/sql.class/sql.class.php on line 2

I fixed the line 3 by changing it from __autoload($ClassName) to spl_autoload_register($ClassName)

Which caused me a new error:

Fatal error: Cannot redeclare spl_autoload_register() in /var/www/vhosts/dddd.eu/bbbgg.cdddd.eu/in_site/autoload.php on line 129

Here is the whole code of autoload.php - https://pastebin.com/1Qj3pFPH

What can cause this issue?

twelvell
  • 257
  • 1
  • 8
  • 19

1 Answers1

8

If I just look at your code I notice that you use __autoload as the name of your callable autoload function. I would not use that name since it has been used in the past, and might, as you discovered, trigger a deprecation error. You also cannot replace it by spl_autoload_register because that is an existing PHP function. So try this:

<?php

 function myAutoload($ClassName) 
 {
   .... code ....
 }

 spl_autoload_register('myAutoload');

It can also be useful to check the PHP manual for spl_autoload_register().

KIKO Software
  • 15,283
  • 3
  • 18
  • 33
  • Thank you, it might be a part of the issues. I just discovered that other files of whole website are compiled by SourceGuardian, and it might be the another reason because I need to install a decompiler. – twelvell Nov 26 '19 at 11:41