From 70443a52640450caed1e6dff81da35a57f3daf9c Mon Sep 17 00:00:00 2001 From: "J. King" Date: Mon, 25 Feb 2019 23:59:48 -0500 Subject: [PATCH] Make parent re-association on context clone more restrictive --- lib/Context/Context.php | 1 + lib/Context/ExclusionContext.php | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/Context/Context.php b/lib/Context/Context.php index df45dc6..4ae2e87 100644 --- a/lib/Context/Context.php +++ b/lib/Context/Context.php @@ -9,6 +9,7 @@ namespace JKingWeb\Arsse\Context; use JKingWeb\Arsse\Misc\Date; class Context extends ExclusionContext { + /** @var ExclusionContext */ public $not; public $reverse = false; public $limit = 0; diff --git a/lib/Context/ExclusionContext.php b/lib/Context/ExclusionContext.php index 6a662f2..b2954e3 100644 --- a/lib/Context/ExclusionContext.php +++ b/lib/Context/ExclusionContext.php @@ -32,9 +32,9 @@ class ExclusionContext { public function __clone() { if ($this->parent) { - $p = debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS | \DEBUG_BACKTRACE_PROVIDE_OBJECT, 2)[1]['object'] ?? null; - if ($p instanceof self) { - $this->parent = $p; + $t = debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS | \DEBUG_BACKTRACE_PROVIDE_OBJECT, 2)[1]; + if (($t['object'] ?? null) instanceof self && $t['function'] === "__clone") { + $this->parent = $t['object']; } } }