From: Alexander Ebert Date: Wed, 29 Jun 2016 14:43:23 +0000 (+0200) Subject: Improved implementation of objectID handling X-Git-Tag: 3.0.0_Beta_1~1310 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=fa6c14d530a4c00e64d232efd9902fe17322bd93;p=GitHub%2FWoltLab%2FWCF.git Improved implementation of objectID handling --- diff --git a/wcfsetup/install/files/lib/system/html/IHtmlProcessor.class.php b/wcfsetup/install/files/lib/system/html/IHtmlProcessor.class.php index 7233cc082f..577ef30804 100644 --- a/wcfsetup/install/files/lib/system/html/IHtmlProcessor.class.php +++ b/wcfsetup/install/files/lib/system/html/IHtmlProcessor.class.php @@ -11,15 +11,6 @@ namespace wcf\system\html; * @since 3.0 */ interface IHtmlProcessor { - /** - * Processes the input html string. - * - * @param string $html html string - * @param string $objectType object type identifier - * @param integer $objectID object id - */ - 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 be243403e2..0ab678ae1b 100644 --- a/wcfsetup/install/files/lib/system/html/input/HtmlInputProcessor.class.php +++ b/wcfsetup/install/files/lib/system/html/input/HtmlInputProcessor.class.php @@ -34,12 +34,14 @@ class HtmlInputProcessor extends AbstractHtmlProcessor { protected $htmlInputNodeProcessor; /** - * @inheritDoc + * Processes the input html string. + * + * @param string $html html string + * @param string $objectType object type identifier + * @param integer $objectID object id */ 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); + $this->setContext($objectType, $objectID); // enforce consistent newlines $html = StringUtil::unifyNewlines($html); 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 b0daa4b875..4e05849298 100644 --- a/wcfsetup/install/files/lib/system/html/output/HtmlOutputProcessor.class.php +++ b/wcfsetup/install/files/lib/system/html/output/HtmlOutputProcessor.class.php @@ -26,13 +26,13 @@ class HtmlOutputProcessor extends AbstractHtmlProcessor { protected $outputType = 'text/html'; /** - * @inheritDoc + * Processes the input html string. + * + * @param string $html html string + * @param string $objectType object type identifier + * @param integer $objectID object id */ - public function process($html, $objectType, $objectID = 0) { - if ($objectID === 0) { - throw new \UnexpectedValueException('Object id cannot be 0 for output processing.'); - } - + public function process($html, $objectType, $objectID) { $this->setContext($objectType, $objectID); $this->getHtmlOutputNodeProcessor()->setOutputType($this->outputType); @@ -61,6 +61,18 @@ class HtmlOutputProcessor extends AbstractHtmlProcessor { return $this->getHtmlOutputNodeProcessor()->getHtml(); } + /** + * @inheritdoc + * @throws \InvalidArgumentException + */ + public function setContext($objectType, $objectID) { + if (!$objectID) { + throw new \InvalidArgumentException("Output processor requires a valid objectID."); + } + + parent::setContext($objectType, $objectID); + } + /** * Returns the output node processor instance. *