Matthias Mullie has uploaded a new change for review. https://gerrit.wikimedia.org/r/190448
Change subject: Revert "Get rid of complex unused code" ...................................................................... Revert "Get rid of complex unused code" Apparently, we're still relying on that in RevisionFormatter, using for e.g. history. This reverts commit 65bbc23f0a92718864e4727be73e3d8a01d34add. Change-Id: I2992fac7dd352b54ceba9b3d28cc94620c61d1e7 --- M handlebars/compiled/flow_block_topic.handlebars.php M handlebars/compiled/flow_block_topic_moderate_post.handlebars.php M handlebars/compiled/flow_block_topic_moderate_topic.handlebars.php M handlebars/compiled/flow_block_topiclist.handlebars.php M handlebars/compiled/flow_post.handlebars.php M handlebars/flow_post_moderation_state.handlebars M includes/Templating.php 7 files changed, 49 insertions(+), 20 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow refs/changes/48/190448/1 diff --git a/handlebars/compiled/flow_block_topic.handlebars.php b/handlebars/compiled/flow_block_topic.handlebars.php index 51e69d5..97204b2 100644 --- a/handlebars/compiled/flow_block_topic.handlebars.php +++ b/handlebars/compiled/flow_block_topic.handlebars.php @@ -38,7 +38,7 @@ </div> ' : '').'</div> ';},'flow_topic_moderation_flag' => function ($cx, $in) {return '<span class="wikiglyph'.LCRun3::hbch($cx, 'ifCond', array(array(((isset($in['moderateState']) && is_array($in)) ? $in['moderateState'] : null),'===','lock'),array()), $in, false, function($cx, $in) {return ' wikiglyph-lock';}).''.LCRun3::hbch($cx, 'ifCond', array(array(((isset($in['moderateState']) && is_array($in)) ? $in['moderateState'] : null),'===','hide'),array()), $in, false, function($cx, $in) {return ' wikiglyph-flag';}).''.LCRun3::hbch($cx, 'ifCond', array(array(((isset($in['moderateState']) && is_array($in)) ? $in['moderateState'] : null),'===','delete'),array()), $in, false, function($cx, $in) {return ' wikiglyph-trash';}).'"></span> -';},'flow_post_moderation_state' => function ($cx, $in) {return ''.((LCRun3::ifvar($cx, ((isset($in['replyToId']) && is_array($in)) ? $in['replyToId'] : null))) ? ' '.LCRun3::ch($cx, 'l10n', array(array(LCRun3::ch($cx, 'concat', array(array('flow-',((isset($in['moderateState']) && is_array($in)) ? $in['moderateState'] : null),'-post-content'),array()), 'raw'),((isset($in['moderator']['name']) && is_array($in['moderator'])) ? $in['moderator']['name'] : null)),array()), 'encq').'' : ' '.LCRun3::ch($cx, 'l10n', array(array(LCRun3::ch($cx, 'concat', array(array('flow-',((isset($in['moderateState']) && is_array($in)) ? $in['moderateState'] : null),'-title-content'),array()), 'raw'),((isset($in['moderator']['name']) && is_array($in['moderator'])) ? $in['moderator']['name'] : null)),array()), 'encq').'').'';},'flow_topic_titlebar_summary' => function ($cx, $in) {return '<div class="flow-topic-summary-container"> +';},'flow_post_moderation_state' => function ($cx, $in) {return ''.((LCRun3::ifvar($cx, ((isset($in['replyToId']) && is_array($in)) ? $in['replyToId'] : null))) ? ''.LCRun3::ch($cx, 'l10n', array(array(LCRun3::ch($cx, 'concat', array(array('flow-',((isset($in['moderateState']) && is_array($in)) ? $in['moderateState'] : null),'-post-content'),array()), 'raw'),((isset($in['moderator']['name']) && is_array($in['moderator'])) ? $in['moderator']['name'] : null)),array()), 'encq').'' : ''.LCRun3::ch($cx, 'l10n', array(array(LCRun3::ch($cx, 'concat', array(array('flow-',((isset($in['moderateState']) && is_array($in)) ? $in['moderateState'] : null),'-title-content'),array()), 'raw'),((isset($in['moderator']['name']) && is_array($in['moderator'])) ? $in['moderator']['name'] : null)),array()), 'encq').'').'';},'flow_topic_titlebar_summary' => function ($cx, $in) {return '<div class="flow-topic-summary-container"> '.LCRun3::p($cx, 'flow_errors', array(array($in),array())).''.((LCRun3::ifvar($cx, ((isset($in['summary']) && is_array($in)) ? $in['summary'] : null))) ? ' <div class="flow-topic-summary"> '.LCRun3::ch($cx, 'escapeContent', array(array(((isset($in['summary']['format']) && is_array($in['summary'])) ? $in['summary']['format'] : null),((isset($in['summary']['content']) && is_array($in['summary'])) ? $in['summary']['content'] : null)),array()), 'encq').' </div> diff --git a/handlebars/compiled/flow_block_topic_moderate_post.handlebars.php b/handlebars/compiled/flow_block_topic_moderate_post.handlebars.php index 82e73b9..96aef45 100644 --- a/handlebars/compiled/flow_block_topic_moderate_post.handlebars.php +++ b/handlebars/compiled/flow_block_topic_moderate_post.handlebars.php @@ -68,7 +68,7 @@ title="'.htmlentities((string)((isset($in['links']['block']['title']) && is_array($in['links']['block'])) ? $in['links']['block']['title'] : null), ENT_QUOTES, 'UTF-8').'">'.LCRun3::ch($cx, 'l10n', array(array('blocklink'),array()), 'encq').'</a></span>' : '').') </span> ' : '').'</span> -';},'flow_post_moderation_state' => function ($cx, $in) {return ''.((LCRun3::ifvar($cx, ((isset($in['replyToId']) && is_array($in)) ? $in['replyToId'] : null))) ? ' '.LCRun3::ch($cx, 'l10n', array(array(LCRun3::ch($cx, 'concat', array(array('flow-',((isset($in['moderateState']) && is_array($in)) ? $in['moderateState'] : null),'-post-content'),array()), 'raw'),((isset($in['moderator']['name']) && is_array($in['moderator'])) ? $in['moderator']['name'] : null)),array()), 'encq').'' : ' '.LCRun3::ch($cx, 'l10n', array(array(LCRun3::ch($cx, 'concat', array(array('flow-',((isset($in['moderateState']) && is_array($in)) ? $in['moderateState'] : null),'-title-content'),array()), 'raw'),((isset($in['moderator']['name']) && is_array($in['moderator'])) ? $in['moderator']['name'] : null)),array()), 'encq').'').'';},'flow_post_meta_actions' => function ($cx, $in) {return '<div class="flow-post-meta"> +';},'flow_post_moderation_state' => function ($cx, $in) {return ''.((LCRun3::ifvar($cx, ((isset($in['replyToId']) && is_array($in)) ? $in['replyToId'] : null))) ? ''.LCRun3::ch($cx, 'l10n', array(array(LCRun3::ch($cx, 'concat', array(array('flow-',((isset($in['moderateState']) && is_array($in)) ? $in['moderateState'] : null),'-post-content'),array()), 'raw'),((isset($in['moderator']['name']) && is_array($in['moderator'])) ? $in['moderator']['name'] : null)),array()), 'encq').'' : ''.LCRun3::ch($cx, 'l10n', array(array(LCRun3::ch($cx, 'concat', array(array('flow-',((isset($in['moderateState']) && is_array($in)) ? $in['moderateState'] : null),'-title-content'),array()), 'raw'),((isset($in['moderator']['name']) && is_array($in['moderator'])) ? $in['moderator']['name'] : null)),array()), 'encq').'').'';},'flow_post_meta_actions' => function ($cx, $in) {return '<div class="flow-post-meta"> <span class="flow-post-meta-actions"> '.((LCRun3::ifvar($cx, ((isset($in['actions']['reply']) && is_array($in['actions'])) ? $in['actions']['reply'] : null))) ? ' <a href="'.htmlentities((string)((isset($in['actions']['reply']['url']) && is_array($in['actions']['reply'])) ? $in['actions']['reply']['url'] : null), ENT_QUOTES, 'UTF-8').'" title="'.htmlentities((string)((isset($in['actions']['reply']['title']) && is_array($in['actions']['reply'])) ? $in['actions']['reply']['title'] : null), ENT_QUOTES, 'UTF-8').'" diff --git a/handlebars/compiled/flow_block_topic_moderate_topic.handlebars.php b/handlebars/compiled/flow_block_topic_moderate_topic.handlebars.php index 99f4282..49fab3f 100644 --- a/handlebars/compiled/flow_block_topic_moderate_topic.handlebars.php +++ b/handlebars/compiled/flow_block_topic_moderate_topic.handlebars.php @@ -68,7 +68,7 @@ title="'.htmlentities((string)((isset($in['links']['block']['title']) && is_array($in['links']['block'])) ? $in['links']['block']['title'] : null), ENT_QUOTES, 'UTF-8').'">'.LCRun3::ch($cx, 'l10n', array(array('blocklink'),array()), 'encq').'</a></span>' : '').') </span> ' : '').'</span> -';},'flow_post_moderation_state' => function ($cx, $in) {return ''.((LCRun3::ifvar($cx, ((isset($in['replyToId']) && is_array($in)) ? $in['replyToId'] : null))) ? ' '.LCRun3::ch($cx, 'l10n', array(array(LCRun3::ch($cx, 'concat', array(array('flow-',((isset($in['moderateState']) && is_array($in)) ? $in['moderateState'] : null),'-post-content'),array()), 'raw'),((isset($in['moderator']['name']) && is_array($in['moderator'])) ? $in['moderator']['name'] : null)),array()), 'encq').'' : ' '.LCRun3::ch($cx, 'l10n', array(array(LCRun3::ch($cx, 'concat', array(array('flow-',((isset($in['moderateState']) && is_array($in)) ? $in['moderateState'] : null),'-title-content'),array()), 'raw'),((isset($in['moderator']['name']) && is_array($in['moderator'])) ? $in['moderator']['name'] : null)),array()), 'encq').'').'';},'flow_post_meta_actions' => function ($cx, $in) {return '<div class="flow-post-meta"> +';},'flow_post_moderation_state' => function ($cx, $in) {return ''.((LCRun3::ifvar($cx, ((isset($in['replyToId']) && is_array($in)) ? $in['replyToId'] : null))) ? ''.LCRun3::ch($cx, 'l10n', array(array(LCRun3::ch($cx, 'concat', array(array('flow-',((isset($in['moderateState']) && is_array($in)) ? $in['moderateState'] : null),'-post-content'),array()), 'raw'),((isset($in['moderator']['name']) && is_array($in['moderator'])) ? $in['moderator']['name'] : null)),array()), 'encq').'' : ''.LCRun3::ch($cx, 'l10n', array(array(LCRun3::ch($cx, 'concat', array(array('flow-',((isset($in['moderateState']) && is_array($in)) ? $in['moderateState'] : null),'-title-content'),array()), 'raw'),((isset($in['moderator']['name']) && is_array($in['moderator'])) ? $in['moderator']['name'] : null)),array()), 'encq').'').'';},'flow_post_meta_actions' => function ($cx, $in) {return '<div class="flow-post-meta"> <span class="flow-post-meta-actions"> '.((LCRun3::ifvar($cx, ((isset($in['actions']['reply']) && is_array($in['actions'])) ? $in['actions']['reply'] : null))) ? ' <a href="'.htmlentities((string)((isset($in['actions']['reply']['url']) && is_array($in['actions']['reply'])) ? $in['actions']['reply']['url'] : null), ENT_QUOTES, 'UTF-8').'" title="'.htmlentities((string)((isset($in['actions']['reply']['title']) && is_array($in['actions']['reply'])) ? $in['actions']['reply']['title'] : null), ENT_QUOTES, 'UTF-8').'" diff --git a/handlebars/compiled/flow_block_topiclist.handlebars.php b/handlebars/compiled/flow_block_topiclist.handlebars.php index a668a89..a9f2acf 100644 --- a/handlebars/compiled/flow_block_topiclist.handlebars.php +++ b/handlebars/compiled/flow_block_topiclist.handlebars.php @@ -144,7 +144,7 @@ </div> </form> ' : '').'';},'flow_topic_moderation_flag' => function ($cx, $in) {return '<span class="wikiglyph'.LCRun3::hbch($cx, 'ifCond', array(array(((isset($in['moderateState']) && is_array($in)) ? $in['moderateState'] : null),'===','lock'),array()), $in, false, function($cx, $in) {return ' wikiglyph-lock';}).''.LCRun3::hbch($cx, 'ifCond', array(array(((isset($in['moderateState']) && is_array($in)) ? $in['moderateState'] : null),'===','hide'),array()), $in, false, function($cx, $in) {return ' wikiglyph-flag';}).''.LCRun3::hbch($cx, 'ifCond', array(array(((isset($in['moderateState']) && is_array($in)) ? $in['moderateState'] : null),'===','delete'),array()), $in, false, function($cx, $in) {return ' wikiglyph-trash';}).'"></span> -';},'flow_post_moderation_state' => function ($cx, $in) {return ''.((LCRun3::ifvar($cx, ((isset($in['replyToId']) && is_array($in)) ? $in['replyToId'] : null))) ? ' '.LCRun3::ch($cx, 'l10n', array(array(LCRun3::ch($cx, 'concat', array(array('flow-',((isset($in['moderateState']) && is_array($in)) ? $in['moderateState'] : null),'-post-content'),array()), 'raw'),((isset($in['moderator']['name']) && is_array($in['moderator'])) ? $in['moderator']['name'] : null)),array()), 'encq').'' : ' '.LCRun3::ch($cx, 'l10n', array(array(LCRun3::ch($cx, 'concat', array(array('flow-',((isset($in['moderateState']) && is_array($in)) ? $in['moderateState'] : null),'-title-content'),array()), 'raw'),((isset($in['moderator']['name']) && is_array($in['moderator'])) ? $in['moderator']['name'] : null)),array()), 'encq').'').'';},'flow_topic_titlebar_summary' => function ($cx, $in) {return '<div class="flow-topic-summary-container"> +';},'flow_post_moderation_state' => function ($cx, $in) {return ''.((LCRun3::ifvar($cx, ((isset($in['replyToId']) && is_array($in)) ? $in['replyToId'] : null))) ? ''.LCRun3::ch($cx, 'l10n', array(array(LCRun3::ch($cx, 'concat', array(array('flow-',((isset($in['moderateState']) && is_array($in)) ? $in['moderateState'] : null),'-post-content'),array()), 'raw'),((isset($in['moderator']['name']) && is_array($in['moderator'])) ? $in['moderator']['name'] : null)),array()), 'encq').'' : ''.LCRun3::ch($cx, 'l10n', array(array(LCRun3::ch($cx, 'concat', array(array('flow-',((isset($in['moderateState']) && is_array($in)) ? $in['moderateState'] : null),'-title-content'),array()), 'raw'),((isset($in['moderator']['name']) && is_array($in['moderator'])) ? $in['moderator']['name'] : null)),array()), 'encq').'').'';},'flow_topic_titlebar_summary' => function ($cx, $in) {return '<div class="flow-topic-summary-container"> '.LCRun3::p($cx, 'flow_errors', array(array($in),array())).''.((LCRun3::ifvar($cx, ((isset($in['summary']) && is_array($in)) ? $in['summary'] : null))) ? ' <div class="flow-topic-summary"> '.LCRun3::ch($cx, 'escapeContent', array(array(((isset($in['summary']['format']) && is_array($in['summary'])) ? $in['summary']['format'] : null),((isset($in['summary']['content']) && is_array($in['summary'])) ? $in['summary']['content'] : null)),array()), 'encq').' </div> diff --git a/handlebars/compiled/flow_post.handlebars.php b/handlebars/compiled/flow_post.handlebars.php index abaed23..e31011a 100644 --- a/handlebars/compiled/flow_post.handlebars.php +++ b/handlebars/compiled/flow_post.handlebars.php @@ -47,7 +47,7 @@ title="'.htmlentities((string)((isset($in['links']['block']['title']) && is_array($in['links']['block'])) ? $in['links']['block']['title'] : null), ENT_QUOTES, 'UTF-8').'">'.LCRun3::ch($cx, 'l10n', array(array('blocklink'),array()), 'encq').'</a></span>' : '').') </span> ' : '').'</span> -';},'flow_post_moderation_state' => function ($cx, $in) {return ''.((LCRun3::ifvar($cx, ((isset($in['replyToId']) && is_array($in)) ? $in['replyToId'] : null))) ? ' '.LCRun3::ch($cx, 'l10n', array(array(LCRun3::ch($cx, 'concat', array(array('flow-',((isset($in['moderateState']) && is_array($in)) ? $in['moderateState'] : null),'-post-content'),array()), 'raw'),((isset($in['moderator']['name']) && is_array($in['moderator'])) ? $in['moderator']['name'] : null)),array()), 'encq').'' : ' '.LCRun3::ch($cx, 'l10n', array(array(LCRun3::ch($cx, 'concat', array(array('flow-',((isset($in['moderateState']) && is_array($in)) ? $in['moderateState'] : null),'-title-content'),array()), 'raw'),((isset($in['moderator']['name']) && is_array($in['moderator'])) ? $in['moderator']['name'] : null)),array()), 'encq').'').'';},'flow_post_meta_actions' => function ($cx, $in) {return '<div class="flow-post-meta"> +';},'flow_post_moderation_state' => function ($cx, $in) {return ''.((LCRun3::ifvar($cx, ((isset($in['replyToId']) && is_array($in)) ? $in['replyToId'] : null))) ? ''.LCRun3::ch($cx, 'l10n', array(array(LCRun3::ch($cx, 'concat', array(array('flow-',((isset($in['moderateState']) && is_array($in)) ? $in['moderateState'] : null),'-post-content'),array()), 'raw'),((isset($in['moderator']['name']) && is_array($in['moderator'])) ? $in['moderator']['name'] : null)),array()), 'encq').'' : ''.LCRun3::ch($cx, 'l10n', array(array(LCRun3::ch($cx, 'concat', array(array('flow-',((isset($in['moderateState']) && is_array($in)) ? $in['moderateState'] : null),'-title-content'),array()), 'raw'),((isset($in['moderator']['name']) && is_array($in['moderator'])) ? $in['moderator']['name'] : null)),array()), 'encq').'').'';},'flow_post_meta_actions' => function ($cx, $in) {return '<div class="flow-post-meta"> <span class="flow-post-meta-actions"> '.((LCRun3::ifvar($cx, ((isset($in['actions']['reply']) && is_array($in['actions'])) ? $in['actions']['reply'] : null))) ? ' <a href="'.htmlentities((string)((isset($in['actions']['reply']['url']) && is_array($in['actions']['reply'])) ? $in['actions']['reply']['url'] : null), ENT_QUOTES, 'UTF-8').'" title="'.htmlentities((string)((isset($in['actions']['reply']['title']) && is_array($in['actions']['reply'])) ? $in['actions']['reply']['title'] : null), ENT_QUOTES, 'UTF-8').'" diff --git a/handlebars/flow_post_moderation_state.handlebars b/handlebars/flow_post_moderation_state.handlebars index ad46b66..271313d 100644 --- a/handlebars/flow_post_moderation_state.handlebars +++ b/handlebars/flow_post_moderation_state.handlebars @@ -1,7 +1,5 @@ {{~#if replyToId~}} - {{!-- Messages: flow-hide-post-content, flow-delete-post-content, flow-suppress-post-content --}} {{l10n (concat "flow-" moderateState "-post-content") moderator.name}} {{~else~}} - {{!-- Messages: flow-hide-title-content, flow-delete-title-content, flow-suppress-title-content --}} {{l10n (concat "flow-" moderateState "-title-content") moderator.name}} {{~/if~}} diff --git a/includes/Templating.php b/includes/Templating.php index 4138633..9c85032 100644 --- a/includes/Templating.php +++ b/includes/Templating.php @@ -221,22 +221,53 @@ ); } - if ( !$allowed ) { - throw new FlowException( 'Insufficient permissions to see content for rev_id = ' . $revision->getRevisionId()->getAlphadecimal() ); - } + if ( $allowed ) { + // html format + if ( $format === 'html' ) { + // Parsoid doesn't render redlinks & doesn't strip bad images + try { + $content = $this->contentFixer->getContent( $revision ); + } catch ( \Exception $e ) { + wfDebugLog( 'Flow', __METHOD__ . ': Failed fix content for rev_id = ' . $revision->getRevisionId()->getAlphadecimal() ); + \MWExceptionHandler::logException( $e ); - if ( $format !== 'html' ) { - return $revision->getContent( $format ); - } + $content = wfMessage( 'flow-stub-post-content' )->parse(); + } + // all other formats + } else { + $content = $revision->getContent( $format ); + } - // Parsoid doesn't render redlinks & doesn't strip bad images - try { - return $this->contentFixer->getContent( $revision ); - } catch ( \Exception $e ) { - wfDebugLog( 'Flow', __METHOD__ . ': Failed fix content for rev_id = ' . $revision->getRevisionId()->getAlphadecimal() ); - \MWExceptionHandler::logException( $e ); + return $content; + } else { + $revision = $this->getModeratedRevision( $revision ); + $username = $this->usernames->get( + wfWikiId(), + $revision->getModeratedByUserId(), + $revision->getModeratedByUserIp() + ); - return wfMessage( 'flow-stub-post-content' )->parse(); + // get revision type to make more precise message + $state = $revision->getModerationState(); + $type = $revision->getRevisionType(); + if ( $revision instanceof PostRevision && $revision->isTopicTitle() ) { + $type = 'title'; + } + + // Messages: flow-hide-post-content, flow-delete-post-content, flow-suppress-post-content + // flow-hide-title-content, flow-delete-title-content, flow-suppress-title-content + $message = wfMessage( "flow-$state-$type-content", $username )->rawParams( $this->getUserLinks( $revision ) ); + if ( !$message->exists() ) { + wfDebugLog( 'Flow', __METHOD__ . ': Failed to locate message for moderated content: ' . $message->getKey() ); + + $message = wfMessage( 'flow-error-other' ); + } + + if ( $format === 'html' ) { + return $message->escaped(); + } else { + return $message->text(); + } } } -- To view, visit https://gerrit.wikimedia.org/r/190448 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I2992fac7dd352b54ceba9b3d28cc94620c61d1e7 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Flow Gerrit-Branch: master Gerrit-Owner: Matthias Mullie <mmul...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits