Skip to content

Remove legacy global variable usage #3

Description

@Jimmi08

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

global $pref, $tp;

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions