EBernhardson (WMF) has submitted this change and it was merged.
Change subject: Insert flow definitions via maint script
......................................................................
Insert flow definitions via maint script
Change-Id: I638220418636fa9a982756522873bf72aaaf916b
---
M Flow.php
M flow.sql
A maintenance/FlowInsertDefaultDefinitions.php
3 files changed, 75 insertions(+), 7 deletions(-)
Approvals:
EBernhardson (WMF): Verified; Looks good to me, approved
diff --git a/Flow.php b/Flow.php
index 75e8cff..4f90656 100755
--- a/Flow.php
+++ b/Flow.php
@@ -43,6 +43,8 @@
$dir = __DIR__ . '/';
$wgExtensionMessagesFiles['Flow'] = $dir . 'Flow.i18n.php';
+$wgAutoloadClasses['FlowInsertDefaultDefinitions'] = $dir .
'maintenance/FlowInsertDefaultDefinitions.php';
+
// Classes fulfilling the mediawiki extension architecture
// note: SRP would say a 'FlowHooks' class should not exist
$wgAutoloadClasses['FlowHooks'] = $dir . 'Hooks.php';
diff --git a/flow.sql b/flow.sql
index b6ef1fd..75248cd 100644
--- a/flow.sql
+++ b/flow.sql
@@ -136,10 +136,3 @@
CREATE UNIQUE INDEX /*i*/flow_tree_node_pk ON /*_*/flow_tree_node
(tree_ancestor_id, tree_descendant_id);
CREATE UNIQUE INDEX /*i*/flow_tree_constraint ON /*_*/flow_tree_node
(tree_descendant_id, tree_depth);
-
--- These dont belong here
-INSERT INTO flow_definition
- ( definition_id, definition_wiki, definition_name, definition_type,
definition_options )
- VALUES
- ( unhex('4ffebfa36a3155f2416080027a082220'), 'wiki', 'topic', 'topic',
NULL ), -- UUID 6645733872243863389540699858102420002
- ( unhex('4ffebfa368b155f2416080027a082220'), 'wiki', 'discussion',
'discussion',
unhex("613a323a7b733a31393a22746f7069635f646566696e6974696f6e5f6964223b4f3a31353a22466c6f775c4d6f64656c5c55554944223a313a7b733a31343a22002a0062696e61727956616c7565223b733a31363a224ffebfa36a3155f2416080027a082220223b7d733a363a22756e69717565223b623a313b7d")
); -- 6645733872272877609211450958295368226
diff --git a/maintenance/FlowInsertDefaultDefinitions.php
b/maintenance/FlowInsertDefaultDefinitions.php
new file mode 100644
index 0000000..f474ea5
--- /dev/null
+++ b/maintenance/FlowInsertDefaultDefinitions.php
@@ -0,0 +1,73 @@
+<?php
+
+use Flow\Model\UUID;
+
+/**
+ * Remove invalid events from echo_event and echo_notification
+ *
+ * @ingroup Maintenance
+ */
+require_once ( getenv( 'MW_INSTALL_PATH' ) !== false
+ ? getenv( 'MW_INSTALL_PATH' ) . '/maintenance/Maintenance.php'
+ : dirname( __FILE__ ) . '/../../../maintenance/Maintenance.php' );
+
+/**
+ * Maintenance script that removes invalid notifications
+ *
+ * @ingroup Maintenance
+ */
+class FlowInsertDefaultDefinitions extends Maintenance {
+
+ public function execute() {
+ $dbw = MWEchoDbFactory::getDB( DB_MASTER );
+
+ $res = $dbw->select(
+ /* table */'flow_definition',
+ /* select */'definition_id',
+ /* conds */array( 'definition_name' => 'topic' ),
+ __METHOD__
+ );
+ if ( $res ) {
+ $res = $res->fetchRow();
+ }
+ if ( !isset( $res['definition_id'] ) ) {
+ $this->insertDefinitions();
+ }
+
+ }
+
+ protected function insertDefinitions( DatabaseBase $dbw ) {
+ $topicId = UUID::create();
+ $discussionId = UUID::create();
+
+ $dbw->insert(
+ 'flow_definition',
+ array(
+ 'definition_id' => $topicId->getBinary(),
+ 'definition_wiki' => wfWikiId(),
+ 'definition_name' => 'topic',
+ 'definition_type' => 'topic',
+ 'definition_options' => null
+ ),
+ __METHOD__
+ );
+
+ $dbw->insert(
+ 'flow_definition',
+ array(
+ 'definition_id' => $discussionId->getBinary(),
+ 'definition_wiki' => wfWikiId(),
+ 'definition_name' => 'discussion',
+ 'definition_type' => 'discussion',
+ 'definition_options' => serialize( array(
+ 'topic_definition_id' => $topicId,
+ 'unique' => true,
+ ) ),
+ ),
+ __METHOD__
+ );
+ }
+}
+
+$maintClass = 'FlowInsertDefaultDefinitions'; // Tells it to run the class
+require_once( RUN_MAINTENANCE_IF_MAIN );
--
To view, visit https://gerrit.wikimedia.org/r/81079
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I638220418636fa9a982756522873bf72aaaf916b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: EBernhardson (WMF) <[email protected]>
Gerrit-Reviewer: EBernhardson (WMF) <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits