From ca48bdf88b3a75656dd607d753708ecea537703b Mon Sep 17 00:00:00 2001 From: Alexander Ebert <ebert@woltlab.com> Date: Wed, 29 Jun 2016 15:39:29 +0200 Subject: [PATCH] Fix for object id unknown for new html objects --- .../lib/system/html/IHtmlProcessor.class.php | 2 +- .../html/input/HtmlInputProcessor.class.php | 15 +++++++++++++-- .../html/output/HtmlOutputProcessor.class.php | 6 +++++- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/wcfsetup/install/files/lib/system/html/IHtmlProcessor.class.php b/wcfsetup/install/files/lib/system/html/IHtmlProcessor.class.php index 16bc22da9b..7233cc082f 100644 --- a/wcfsetup/install/files/lib/system/html/IHtmlProcessor.class.php +++ b/wcfsetup/install/files/lib/system/html/IHtmlProcessor.class.php @@ -18,7 +18,7 @@ interface IHtmlProcessor { * @param string $objectType object type identifier * @param integer $objectID object id */ - public function process($html, $objectType, $objectID); + public function process($html, $objectType, $objectID = 0); /** * Returns the parsed html. diff --git a/wcfsetup/install/files/lib/system/html/input/HtmlInputProcessor.class.php b/wcfsetup/install/files/lib/system/html/input/HtmlInputProcessor.class.php index 72f89cfda2..be243403e2 100644 --- a/wcfsetup/install/files/lib/system/html/input/HtmlInputProcessor.class.php +++ b/wcfsetup/install/files/lib/system/html/input/HtmlInputProcessor.class.php @@ -36,8 +36,10 @@ class HtmlInputProcessor extends AbstractHtmlProcessor { /** * @inheritDoc */ - public function process($html, $objectType, $objectID) { - $this->setContext($objectType, $objectID); + public function process($html, $objectType, $objectID = 0) { + // object id is always `0` during input processing but is set + // before saving embedded objects + $this->setContext($objectType, 0); // enforce consistent newlines $html = StringUtil::unifyNewlines($html); @@ -87,6 +89,15 @@ class HtmlInputProcessor extends AbstractHtmlProcessor { return $this->htmlInputNodeProcessor; } + /** + * Sets the new object id. + * + * @param integer $objectID object id + */ + public function setObjectID($objectID) { + $this->context['objectID'] = $objectID; + } + /** * @return IHtmlInputFilter */ diff --git a/wcfsetup/install/files/lib/system/html/output/HtmlOutputProcessor.class.php b/wcfsetup/install/files/lib/system/html/output/HtmlOutputProcessor.class.php index e0fb3f0365..b0daa4b875 100644 --- a/wcfsetup/install/files/lib/system/html/output/HtmlOutputProcessor.class.php +++ b/wcfsetup/install/files/lib/system/html/output/HtmlOutputProcessor.class.php @@ -28,7 +28,11 @@ class HtmlOutputProcessor extends AbstractHtmlProcessor { /** * @inheritDoc */ - public function process($html, $objectType, $objectID) { + public function process($html, $objectType, $objectID = 0) { + if ($objectID === 0) { + throw new \UnexpectedValueException('Object id cannot be 0 for output processing.'); + } + $this->setContext($objectType, $objectID); $this->getHtmlOutputNodeProcessor()->setOutputType($this->outputType); -- 2.20.1