From cbe7e31f68d4ca2bfcd53dffdb130f1f84be3343 Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Sun, 24 Oct 2021 15:54:43 +0200 Subject: Split up BigPipe "enabled" method into two methods Split up the "enabled" method of the BigPipe class into two methods, one to check if the pipelining mode is currently enabled ("isEnabled") and another one to enable/disable the pipelining mode ("setEnabled"). This change prevents that a single method has two different jobs, which can be confusing for programmers who didn't wrote the code but only use them. Now there are two clearly named methods for exactly one job. --- async.php | 2 +- include/classes/BigPipe/BigPipe.php | 19 +++++++++++-------- include/classes/BigPipe/Pagelet.php | 4 ++-- include/pagelets.php | 2 +- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/async.php b/async.php index 3d444c8..a82c91a 100644 --- a/async.php +++ b/async.php @@ -29,7 +29,7 @@ require_once 'include/pagelets.php'; \n"; } } diff --git a/include/classes/BigPipe/Pagelet.php b/include/classes/BigPipe/Pagelet.php index 0358df6..bd50c4b 100644 --- a/include/classes/BigPipe/Pagelet.php +++ b/include/classes/BigPipe/Pagelet.php @@ -150,7 +150,7 @@ class Pagelet extends Item { # Flush pagelet immediately #=============================================================================== public function flush() { - if(BigPipe::enabled()) { + if(BigPipe::isEnabled()) { $pageletHTML = str_replace(["\r", "\n", "\t"], '', $this->getHTML()); $pageletHTML = str_replace('--', '--', $pageletHTML); @@ -169,7 +169,7 @@ class Pagelet extends Item { #=============================================================================== public function __toString() { $pageletHTML = "<{$this->tagName} id=\"{$this->getID()}\">"; - $pageletHTML .= !BigPipe::enabled() ? $this->getHTML() : $this->tagHTML; + $pageletHTML .= !BigPipe::isEnabled() ? $this->getHTML() : $this->tagHTML; $pageletHTML .= "tagName}>"; return $pageletHTML; diff --git a/include/pagelets.php b/include/pagelets.php index ed1f8a0..2fc1c9b 100644 --- a/include/pagelets.php +++ b/include/pagelets.php @@ -22,7 +22,7 @@ if(isset($_GET['bigpipe']) AND $_GET['bigpipe'] === '0') { # will be present at the original position within the HTML response (and all # external stylesheets and javascripts will be displayed as simple or #