Background
Three remaining global declarations in the plugin are leftovers from older
e107 patterns and can be replaced with the modern e107:: accessor API or
removed entirely.
chatbox_menu.php:22
global $e107cache, $e107;
$e107 is declared but never used anywhere in the file.
$e107cache is used once (line 124) and can be replaced with
e107::getCache()->clear('nq_chatbox'). The same accessor pattern is
already used in this file on line 233 (e107::getCache()->retrieve(...)),
so this would be a consistency win as well.
chatbox_menu.php:236
This declaration sits inside an if (...) block at file scope, not inside
a function. PHP's global keyword has no effect outside function scope —
it's a no-op here. Both $pref and $tp are already assigned at file
scope on lines 24–25 via e107::getPref() and e107::getParser(), so
they're in scope already. The declaration can simply be deleted.
This is likely a leftover from a prior refactor where this if block was
once inside a function and someone removed the function wrapper without
cleaning up the global.
Why a separate issue
These changes don't affect runtime behavior (the legacy globals work, just
ineffectively or redundantly), so they don't belong in any of the
behavior-changing PRs we're working on. Doing them as a small dedicated
cleanup keeps each PR's diff focused on one concern.
Changes
chatbox_menu.php
- Line 22: remove
global $e107cache, $e107; entirely.
- Line 124: change
$e107cache->clear('nq_chatbox'); to
e107::getCache()->clear('nq_chatbox');.
- Line 236: remove
global $pref, $tp; entirely.
Verification
- Posting a message still clears the cache (verifiable: post once, then
immediately load page — new message must appear without delay).
- Sidebar widget renders identically in both
cb_layer === 1 and
cb_layer === 2 modes.
- Standalone
chat.php page renders identically.
Out of scope
Other modernization candidates (extract() of $pref, $sql global
implicit usage, etc.) if found in later passes — separate issues.
Background
Three remaining
globaldeclarations in the plugin are leftovers from oldere107 patterns and can be replaced with the modern
e107::accessor API orremoved entirely.
chatbox_menu.php:22$e107is declared but never used anywhere in the file.$e107cacheis used once (line 124) and can be replaced withe107::getCache()->clear('nq_chatbox'). The same accessor pattern isalready used in this file on line 233 (
e107::getCache()->retrieve(...)),so this would be a consistency win as well.
chatbox_menu.php:236This declaration sits inside an
if (...)block at file scope, not insidea function. PHP's
globalkeyword has no effect outside function scope —it's a no-op here. Both
$prefand$tpare already assigned at filescope on lines 24–25 via
e107::getPref()ande107::getParser(), sothey're in scope already. The declaration can simply be deleted.
This is likely a leftover from a prior refactor where this
ifblock wasonce inside a function and someone removed the function wrapper without
cleaning up the
global.Why a separate issue
These changes don't affect runtime behavior (the legacy globals work, just
ineffectively or redundantly), so they don't belong in any of the
behavior-changing PRs we're working on. Doing them as a small dedicated
cleanup keeps each PR's diff focused on one concern.
Changes
chatbox_menu.phpglobal $e107cache, $e107;entirely.$e107cache->clear('nq_chatbox');toe107::getCache()->clear('nq_chatbox');.global $pref, $tp;entirely.Verification
immediately load page — new message must appear without delay).
cb_layer === 1andcb_layer === 2modes.chat.phppage renders identically.Out of scope
Other modernization candidates (
extract()of$pref,$sqlglobalimplicit usage, etc.) if found in later passes — separate issues.