From: Alexander Ebert Date: Sun, 23 Apr 2017 17:00:57 +0000 (+0200) Subject: Some full quotes were not recognized as such X-Git-Tag: 3.0.5~43 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=1d9d9296a85e5adeaf997f321cfecfb83081db7e;p=GitHub%2FWoltLab%2FWCF.git Some full quotes were not recognized as such 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. --- diff --git a/wcfsetup/install/files/lib/system/message/quote/AbstractMessageQuoteHandler.class.php b/wcfsetup/install/files/lib/system/message/quote/AbstractMessageQuoteHandler.class.php index d7b2804082..8d8e550a75 100644 --- a/wcfsetup/install/files/lib/system/message/quote/AbstractMessageQuoteHandler.class.php +++ b/wcfsetup/install/files/lib/system/message/quote/AbstractMessageQuoteHandler.class.php @@ -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. * diff --git a/wcfsetup/install/files/lib/system/message/quote/MessageQuoteManager.class.php b/wcfsetup/install/files/lib/system/message/quote/MessageQuoteManager.class.php index ad7249d87d..fce83b3419 100644 --- a/wcfsetup/install/files/lib/system/message/quote/MessageQuoteManager.class.php +++ b/wcfsetup/install/files/lib/system/message/quote/MessageQuoteManager.class.php @@ -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, */ diff --git a/wcfsetup/install/files/lib/system/message/quote/QuotedMessage.class.php b/wcfsetup/install/files/lib/system/message/quote/QuotedMessage.class.php index 9d6918c5c0..d0286a4a9b 100644 --- a/wcfsetup/install/files/lib/system/message/quote/QuotedMessage.class.php +++ b/wcfsetup/install/files/lib/system/message/quote/QuotedMessage.class.php @@ -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;