From: Alexander Ebert Date: Wed, 29 Jun 2016 13:39:29 +0000 (+0200) Subject: Fix for object id unknown for new html objects X-Git-Tag: 3.0.0_Beta_1~1311 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=ca48bdf88b3a75656dd607d753708ecea537703b;p=GitHub%2FWoltLab%2FWCF.git Fix for object id unknown for new html objects --- 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);