Fix for object id unknown for new html objects
authorAlexander Ebert <ebert@woltlab.com>
Wed, 29 Jun 2016 13:39:29 +0000 (15:39 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 29 Jun 2016 13:39:36 +0000 (15:39 +0200)
wcfsetup/install/files/lib/system/html/IHtmlProcessor.class.php
wcfsetup/install/files/lib/system/html/input/HtmlInputProcessor.class.php
wcfsetup/install/files/lib/system/html/output/HtmlOutputProcessor.class.php

index 16bc22da9b69066897da96ac2357718c00aee6b7..7233cc082fc01b93b8610c53872568b8b01ad482 100644 (file)
@@ -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.
index 72f89cfda24cff2b1467b5e8690c7627c815f3a6..be243403e27da2238e92c81d4d7ae7c62ef2d10a 100644 (file)
@@ -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
         */
index e0fb3f036505d105c640b1f285dbaacc36b84939..b0daa4b875784a52c5f4d45aa42c3296298aaef0 100644 (file)
@@ -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);