Some full quotes were not recognized as such
authorAlexander Ebert <ebert@woltlab.com>
Sun, 23 Apr 2017 17:00:57 +0000 (19:00 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Sun, 23 Apr 2017 17:01:04 +0000 (19:01 +0200)
The changes actually work around the legacy behavior of the creation of
`QuotedMessage` objects, that did not use the existing data if a quote
is an actual full quote.

wcfsetup/install/files/lib/system/message/quote/AbstractMessageQuoteHandler.class.php
wcfsetup/install/files/lib/system/message/quote/MessageQuoteManager.class.php
wcfsetup/install/files/lib/system/message/quote/QuotedMessage.class.php

index d7b280408219255ce17e5248e5a202b4e07f71b5..8d8e550a75b5cb6f1973311cf98f501f55ad95e8 100644 (file)
@@ -30,6 +30,8 @@ abstract class AbstractMessageQuoteHandler extends SingletonFactory implements I
         */
        public function render(array $data, $supportPaste = false) {
                $messages = $this->getMessages($data);
+               $this->overrideIsFullQuote($messages);
+               
                $userIDs = $userProfiles = [];
                foreach ($messages as $message) {
                        $userID = $message->getUserID();
@@ -44,7 +46,7 @@ abstract class AbstractMessageQuoteHandler extends SingletonFactory implements I
                }
                
                WCF::getTPL()->assign([
-                       'messages' => $this->getMessages($data),
+                       'messages' => $messages,
                        'supportPaste' => $supportPaste,
                        'userProfiles' => $userProfiles
                ]);
@@ -57,6 +59,7 @@ abstract class AbstractMessageQuoteHandler extends SingletonFactory implements I
         */
        public function renderQuotes(array $data, $render = true, $renderAsString = true) {
                $messages = $this->getMessages($data);
+               $this->overrideIsFullQuote($messages);
                
                $renderedQuotes = [];
                foreach ($messages as $message) {
@@ -74,6 +77,20 @@ abstract class AbstractMessageQuoteHandler extends SingletonFactory implements I
                return $renderedQuotes;
        }
        
+       /**
+        * Overrides the full quote flag for given message.
+        * 
+        * @param       QuotedMessage[]         $messages
+        */
+       protected function overrideIsFullQuote(array $messages) {
+               foreach ($messages as $message) {
+                       $quoteIDs = $message->getQuoteIDs();
+                       foreach ($quoteIDs as $quoteID) {
+                               $message->setOverrideIsFullQuote($quoteID, MessageQuoteManager::getInstance()->isFullQuote($quoteID));
+                       }
+               }
+       }
+       
        /**
         * Returns a list of QuotedMessage objects.
         * 
index ad7249d87d8e0e267411242c0f8e4f079a527f7e..fce83b3419b18fc1ea1a2f56ac8e93a3977ac8e5 100644 (file)
@@ -608,6 +608,16 @@ class MessageQuoteManager extends SingletonFactory {
                $this->updateSession();
        }
        
+       /**
+        * Returns true if a quote id represents a full quote.
+        * 
+        * @param       string          $quoteID
+        * @return      boolean
+        */
+       public function isFullQuote($quoteID) {
+               return isset($this->quoteData[$quoteID . '_fq']);
+       }
+       
        /**
         * Updates data stored in session,
         */
index 9d6918c5c0bacf3c6b9bfc130e169af4028ec7c4..d0286a4a9b03f6e0aa818f57feac91a29c99aefb 100644 (file)
@@ -34,6 +34,12 @@ class QuotedMessage implements \Countable, \Iterator {
         */
        public $object = null;
        
+       /**
+        * overrides full quote flag
+        * @var boolean[]
+        */
+       public $overrideIsFullQuote = [];
+       
        /**
         * list of quotes (shortened)
         * @var string[]
@@ -92,6 +98,25 @@ class QuotedMessage implements \Countable, \Iterator {
                return $this->object->$name();
        }
        
+       /**
+        * Overrides the full quote flag.
+        * 
+        * @param       string          $quoteID
+        * @param       boolean         $overrideIsFullQuote
+        */
+       public function setOverrideIsFullQuote($quoteID, $overrideIsFullQuote) {
+               $this->overrideIsFullQuote[$quoteID] = $overrideIsFullQuote;
+       }
+       
+       /**
+        * Returns the list of quote ids for this message.
+        * 
+        * @return      string[]
+        */
+       public function getQuoteIDs() {
+               return array_keys($this->quotes);
+       }
+       
        /**
         * Returns the full quote by quote id.
         * 
@@ -113,6 +138,10 @@ class QuotedMessage implements \Countable, \Iterator {
         * @return      boolean
         */
        public function isFullQuote($quoteID) {
+               if (isset($this->overrideIsFullQuote[$quoteID])) {
+                       return $this->overrideIsFullQuote[$quoteID];
+               }
+               
                if (isset($this->fullQuotes[$quoteID]) && $this->quotes[$quoteID] != $this->fullQuotes[$quoteID]) {
                        // full quotes are parsed and differ from their original
                        return true;