Some forum code cleanup - #5320
Conversation
|
Code Climate has analyzed commit 35748ff and detected 0 issues on this pull request. The test coverage on the diff in this pull request is 81.8% (80% is the threshold). This pull request will bring the total coverage in the repository to 48.9% (0.0% change). View more on Code Climate. |
241b734 to
4f50dac
Compare
There was a problem hiding this comment.
@rica-carv I have left this branch alone, because the three things inside it want three different answers and I did not want to decide that for you.
The dead-variable removals are fine. $tp in e107forum::__construct(), $e107 in getTrackedThreadList(), $firstpost: all genuinely unused, and your comments asking why they were declared are fair questions. This part could go in on its own tomorrow.
Retiring the LAN shortcodes is a compatibility break. Commenting out sc_threadtitle(), sc_replytitle(), sc_lastpostitle(), sc_infotitle(), sc_newthreadtitle(), sc_postedtitle() and sc_tracktitle() while switching core's template to {LAN=FORUM_0002} is fine for core, which now supplies both sides. It is not fine for a theme carrying its own forum/forum_template.php: those files still contain {THREADTITLE} and friends, and with the methods gone the column headings render as nothing. The safe version of this change is to switch core's template to the {LAN=...} form, which is what the "How it should be???" comment above each block has been asking for, and leave the shortcode methods in place for the templates that still call them. Cheap, and nobody's forum loses its table headers on upgrade.
The redirect in forum_track() will not fire. This part:
if(!$text)
{
e107::redirect();
exit;
}runs at forum.php:369 onwards, but HEADERF was already included at forum.php#L106, two lines before forum_track() is called. The page header is out the door, so header() cannot be sent and the reader gets a "headers already sent" warning on a half-drawn page. Separately, e107::redirect() defaults to 301 (e107_class.php#L4902), so even where it did work the browser would cache "no tracked threads" and refuse to load the page again after the reader tracked something. If the goal is "do not show an empty tracking page", the fix belongs before HEADERF, and as a 302 at most.
The branch also conflicts with master now, in forum_class.php and forum_shortcodes.php.
My suggestion is to split the dead-variable commit out into its own PR so it can land, and let the other two be discussed separately. Happy to do the splitting if you would rather not; just say. @Deltik has the final word on all three.
|
Well, if you can do the splits, go ahead... 👍 |
|
@e107help: Sure, let's land the pure cleanup in a separate pull request of your own. I don't have the capacity for the other parts, so I encourage you and @rica-carv to hash it out. |
|
@rica-carv Following @Deltik's steer above, I've lifted the pure cleanup out into #5876 so it can land on its own. You're credited as co-author on the commit. That's the four dead locals you spotted ( All four of your comments were right. Good news on the
|
None of these four variables is read after it is written: - e107forum::__construct() takes a parser it never uses. - e107forum::getTrackedThreadList() takes an e107 instance it never uses. - plugin_forum_view_shortcodes::sc_track() globals $forum, which appears nowhere else in the method outside a commented-out block. - forum_front::forum_track() captures getTrackedThreadList()'s return into $trackedThreadList purely to test it. The call is kept; only the unused assignment goes. $tracktext is initialised alongside it because it is assigned only inside that branch and concatenated unconditionally afterwards, so a user with no tracked threads reached an undefined variable. The rendered output is unchanged: the branch already produced an empty string's worth of markup in that case, it just warned on the way. Split out of the pure-cleanup portion of e107inc#5320 by rica-carv, at Deltik's request. The deprecations and the redirect in that PR are unrelated to these and stay there for discussion. Co-authored-by: rica-carv <rica-carv@users.noreply.github.com>

Motivation and Context
Forum code has unused variables, and some hardcoded shortcodes. This is probably the start of that changes...
Description
Cleared some variables unecessary inside code scope
How Has This Been Tested?
Tested with v2.3.3
Types of Changes
Checklist