jenkins-bot has submitted this change and it was merged.
Change subject: Read board content from master db
......................................................................
Read board content from master db
createWorkflowLoader would create a new workflow because it
couldn't find the existing workflow (since it read from slaves)
The result was a different workflow id than the header we're
looking to modify, so the whole thing blew up.
Bug: T112784
Change-Id: I0e65385d2d470ce1170924ec66e51df454fc841f
---
M includes/Import/OptInController.php
1 file changed, 24 insertions(+), 6 deletions(-)
Approvals:
Sbisson: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/Import/OptInController.php
b/includes/Import/OptInController.php
index 465e6f8..2bc4d26 100644
--- a/includes/Import/OptInController.php
+++ b/includes/Import/OptInController.php
@@ -6,6 +6,8 @@
use DateTimeZone;
use DerivativeContext;
use Flow\Collection\HeaderCollection;
+use Flow\Content\BoardContent;
+use Flow\Exception\InvalidDataException;
use Flow\NotificationController;
use Flow\OccupationController;
use Flow\Parsoid\Utils;
@@ -396,13 +398,23 @@
* @throws \Flow\Exception\InvalidDataException
*/
private function editBoardDescription( Title $title, callable
$newDescriptionCallback, $format = 'html' ) {
- /** @var WorkflowLoaderFactory $loader */
- $factory = Container::get( 'factory.loader.workflow' );
+ /*
+ * We could use WorkflowLoaderFactory::createWorkflowLoader
+ * to get to the workflow ID, but that uses WikiPage::factory
+ * to build the wikipage & get the content. For most requests,
+ * that'll be better (it reads from slaves), but we really
+ * need to read from master here.
+ * We'll need WorkflowLoader further down anyway, but we'll
+ * then have the correct workflow ID to initialize it with!
+ */
+ $page = WikiPage::newFromID( $title->getArticleID(),
WikiPage::READ_LATEST );
+ $content = $page->getContent();
+ if ( !$content instanceof BoardContent ) {
+ throw new InvalidDataException( 'Could not find board
page for ' . $title->getPrefixedDBkey() );
+ }
+ $workflowId = $content->getWorkflowId();
- /** @var WorkflowLoader $loader */
- $loader = $factory->createWorkflowLoader( $title );
-
- $collection = HeaderCollection::newFromId(
$loader->getWorkflow()->getId() );
+ $collection = HeaderCollection::newFromId( $workflowId );
$revision = $collection->getLastRevision();
$content = $revision->getContent();
@@ -420,6 +432,12 @@
),
);
+ /** @var WorkflowLoaderFactory $loader */
+ $factory = Container::get( 'factory.loader.workflow' );
+
+ /** @var WorkflowLoader $loader */
+ $loader = $factory->createWorkflowLoader( $title, $workflowId );
+
$blocks = $loader->getBlocks();
$blocksToCommit = $loader->handleSubmit(
--
To view, visit https://gerrit.wikimedia.org/r/239151
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I0e65385d2d470ce1170924ec66e51df454fc841f
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Matthias Mullie <[email protected]>
Gerrit-Reviewer: Matthias Mullie <[email protected]>
Gerrit-Reviewer: Sbisson <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits