e107inc / e107

e107 Bootstrap CMS (Content Management System) v2 with PHP, MySQL, HTML5, jQuery and Twitter Bootstrap. Issue Discussion Room: https://gitter.im/e107inc/e107
https://e107.org
GNU General Public License v3.0
322 stars 214 forks source link

Fatal error with PHP 8.2 #4961

Closed Digioso closed 1 year ago

Digioso commented 1 year ago

Bug Description

From my webserver logfile: [Mon Jan 30 08:47:17.964055 2023] [proxy_fcgi:error] [pid 549159:tid 281473405612224] [client 88.130.87.199:0] AH01071: Got error 'PHP message: PHP Fatal error: Uncaught Error: Undefined constant "PRELINK" in /home/digioso/web/baod.de/public_html/e107_themes/GuildWars/theme.php:157\nStack trace:\n#0 /home/digioso/web/baod.de/public_html/class2.php(1078): require_once()\n#1 /home/digioso/web/baod.de/public_html/index.php(58): require_once('...')\n#2 {main}\n thrown in /home/digioso/web/baod.de/public_html/e107_themes/GuildWars/theme.php on line 157'

How to Reproduce

Steps to reproduce the behavior:

  1. Use PHP 8.2
  2. Open Website
  3. Browser gets status code 500
  4. See error in webserver logfile

Expected Behavior

No error.

Server Information

PHP Operating System

Linux digioso.net 5.15.0-1027-oracle #33-Ubuntu SMP Fri Jan 6 16:30:16 UTC 2023 aarch64 
Ubuntu 22.04

PHP Version

PHP Version 8.2.1

PHP Modules

bcmath bz2 calendar cgi-fcgi Core ctype curl date dom exif FFI fileinfo filter ftp gd gettext hash iconv imagick imap intl json ldap libxml mbstring mysqli mysqlnd openssl pcre PDO pdo_mysql pdo_pgsql pgsql Phar posix pspell random readline Reflection session shmop SimpleXML soap sockets sodium SPL standard sysvmsg sysvsem sysvshm tokenizer xml xmlreader xmlwriter xsl Zend OPcache zip zlib

Client Information

Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/109.0

Additional Information

When I switch PHP back to PHP 7.4 the main website is loading without problems.

Deltik commented 1 year ago

This is a bug with your theme, GuildWars, not a bug within the e107 core.

The theme is trying to access an undefined constant, PRELINK, which has been disallowed since PHP 8.0:

A number of warnings have been converted into Error exceptions:

  • […]
  • Attempting to access unqualified constants which are undefined. Previously, unqualified constant accesses resulted in a warning and were interpreted as strings.

You will have to fix this in the theme. Some options:

Digioso commented 1 year ago

Thanks!

I fixed it doing this:

define("PRELINK", ""); define("POSTLINK", ""); define("LINKSTART", "<img src='".THEME."images/bullet2.gif' alt='' />&nbsp;"); define("LINKEND", "<br />"); define("LINKALIGN", "left"); define("LINKDISPLAY", 2);

Basically I added quotation marks to the name of the constant as described here: https://www.php.net/manual/en/function.define.php Funny enough all other constants were defined correctly with quotation marks in the theme.php file - except for the above.