TOP_EXITS (serendipity_plugin_topexits) kills admin page under PHP 8.0

Found a bug? Tell us!!
Post Reply
erAck
Regular
Posts: 236
Joined: Mon Feb 16, 2015 1:20 am

TOP_EXITS (serendipity_plugin_topexits) kills admin page under PHP 8.0

Post by erAck »

Hi,

With s9y 2.4.0 if TOP_EXITS (serendipity_plugin_topexits) is installed, running under PHP 8.0 browsing serendipity_admin.php already logged in bails out with status 500; using `$serendipity['production'] = false` reveals

Code: Select all

Fatal Error: Uncaught Error: Undefined constant "TOP_EXITS" in include/plugin_api.inc.php:686 Stack trace:
#0 plugins/serendipity_event_spartacus/serendipity_event_spartacus.php(767): serendipity_plugin_api::load_plugin('serendipity_plu...')
#1 plugins/serendipity_event_spartacus/serendipity_event_spartacus.php(746): serendipity_event_spartacus->checkPlugin(Array, Array, 'sidebar')
#2 plugins/serendipity_event_spartacus/serendipity_event_spartacus.php(800): serendipity_event_spartacus->getCachedPlugins(Array, 'sidebar')
#3 plugins/serendipity_event_spartacus/serendipity_event_spartacus.php(1164): serendipity_event_spartacus->buildList('cached', 'sidebar')
#4 plugins/serendipity_event_spartacus/serendipity_event_spartacus.php(1340): serendipity_event_spartacus->count_plugin_upgrades()
#5 include/plugin_api.inc.php(1188): serendipity_event_spartacus->event_hook('backend_plugins...', Object(serendipity_property_bag), '', NULL)
#6 include/admin/overview.inc.php(66): serendipity_plugin_api::hook_event('backend_plugins...', '')
#7 serendipity_admin.php(214): include('...')
#8 {main} thrown in include/plugin_api.inc.php on line 686.
Deleting serendipity_plugin_topexits helps.

Fwiw, already under PHP 7.4 there are warnings about TOP_EXITS and SHOWS_TOP_EXIT like

Code: Select all

Warning: Use of undefined constant TOP_EXITS - assumed 'TOP_EXITS' (this will throw an Error in a future version of PHP) in include/plugin_api.inc.php on line 686.

Warning: Use of undefined constant TOP_EXITS - assumed 'TOP_EXITS' (this will throw an Error in a future version of PHP) in plugins/serendipity_plugin_topexits/serendipity_plugin_topexits.php on line 8.
onli
Regular
Posts: 2825
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: TOP_EXITS (serendipity_plugin_topexits) kills admin page under PHP 8.0

Post by onli »

Right, that plugin just used these two constants and never defines them. I think this could be the right solution: Add the usual

Code: Select all

@serendipity_plugin_api::load_language(dirname(__FILE__));
to the beginning of the plugin, then add a file UTF-8/lang_en.inc.php to the plugin that defines the two constants, something like this:

Code: Select all

@define('TOP_EXITS',                       "Top Exits");
@define('SHOWS_TOP_EXIT',                    "Shows the most common exit urls");
Do you agree? Maybe you could test this out and push a PR to additional_plugins?
erAck
Regular
Posts: 236
Joined: Mon Feb 16, 2015 1:20 am

Re: TOP_EXITS (serendipity_plugin_topexits) kills admin page under PHP 8.0

Post by erAck »

It looks like serendipity_plugin_topexits assumed it could use TOP_EXITS and SHOWS_TOP_EXIT defined by serendipity_plugin_entrylinks. serendipity_event_karma has a related comment

// TOP_EXITS is a language constant of serendipity_plugin_entrylinks. To keep old behaviour we use it here, but
// check for its existence to make PHP 8 happy

That whole thing may depend on plugins' order and serendipity_plugin_entrylinks not being loaded before serendipity_plugin_topexits but I didn't check.
erAck
Regular
Posts: 236
Joined: Mon Feb 16, 2015 1:20 am

Re: TOP_EXITS (serendipity_plugin_topexits) kills admin page under PHP 8.0

Post by erAck »

Similar for serendipity_event_statistics that wants to use TOP_REFERRER and TOP_EXITS and breaks the Statistics in admin. I'll create another PR.

Edit: https://github.com/s9y/additional_plugins/pull/149
onli
Regular
Posts: 2825
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: TOP_EXITS (serendipity_plugin_topexits) kills admin page under PHP 8.0

Post by onli »

I merged both :)
Post Reply