jenkins-bot has submitted this change and it was merged.
Change subject: (bug 63616) incorrect topic timestamp
......................................................................
(bug 63616) incorrect topic timestamp
Normal request block rendering was already checking if a specific block can
be rendered ('discussion' has 3 blocks).
This was not yet the case for API requests. As a result, *all* blocks' render()
methods were called: HeaderBlock, TopicListBlock & BoardHistoryBlock, even if
the requested action is unrelated.
Basically, when API request for action=view was done, BoardHistoryBlock would
also render, even though it only supports action 'history'.
This patch will drastically cut down DB & cache requests, because all history
will no longer be fetched per API request.
It appeared that loading all history at once resulted in faulty workflow
timestamps being saved to cache, somehow. This is now no longer the case since
API calls will no longer call said history render code. I will now look into
why that was saving bad data in the first place ;)
Bug: 63616
Bug: 63346
Change-Id: I866fe0616bd8784932e314390bb2e42010bd79de
---
M includes/Block/Block.php
M includes/api/ApiQueryFlow.php
2 files changed, 33 insertions(+), 8 deletions(-)
Approvals:
Bsitu: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/Block/Block.php b/includes/Block/Block.php
index aba87ba..478f063 100644
--- a/includes/Block/Block.php
+++ b/includes/Block/Block.php
@@ -104,10 +104,32 @@
$this->user = $user;
}
- public function onSubmit( $action, User $user, array $data ) {
+ /**
+ * Returns true of the block can submit the requested action, or false
+ * otherwise.
+ *
+ * @param string $action
+ * @return bool
+ */
+ public function canSubmit( $action ) {
+ return in_array( $this->getActionName( $action ),
$this->supportedPostActions );
+ }
+
+ /**
+ * Returns true of the block can render the requested action, or false
+ * otherwise.
+ *
+ * @param string $action
+ * @return bool
+ */
+ public function canRender( $action ) {
+ return in_array( $this->getActionName( $action ),
$this->supportedGetActions );
+ }
+
+ public function onSubmit( $action, User $user, array $data ) {
/** @noinspection PhpUnusedLocalVariableInspection */
$section = new \ProfileSection( __METHOD__ );
- if ( false === array_search( $this->getActionName( $action ),
$this->supportedPostActions ) ) {
+ if ( !$this->canSubmit( $action ) ) {
return null;
}
@@ -122,7 +144,7 @@
public function onRender( $action, Templating $templating, array
$options ) {
/** @noinspection PhpUnusedLocalVariableInspection */
$section = new \ProfileSection( __METHOD__ );
- if ( !in_array( $this->getActionName( $action ),
$this->supportedGetActions ) ) {
+ if ( !$this->canRender( $action ) ) {
return false;
}
diff --git a/includes/api/ApiQueryFlow.php b/includes/api/ApiQueryFlow.php
index cade49e..7c43017 100644
--- a/includes/api/ApiQueryFlow.php
+++ b/includes/api/ApiQueryFlow.php
@@ -32,12 +32,15 @@
}
$templating = $this->container['templating'];
- $thisBlock = $block->renderAPI( $templating,
$blockParams ) +
- array(
- 'block-name' => $block->getName()
- );
- $blockOutput[] = $thisBlock;
+ if ( $block->canRender( $params['action'] ) ) {
+ $thisBlock = $block->renderAPI( $templating,
$blockParams ) +
+ array(
+ 'block-name' =>
$block->getName()
+ );
+
+ $blockOutput[] = $thisBlock;
+ }
}
$result = array(
--
To view, visit https://gerrit.wikimedia.org/r/124342
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I866fe0616bd8784932e314390bb2e42010bd79de
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Matthias Mullie <[email protected]>
Gerrit-Reviewer: Bsitu <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits