Jeroen De Dauw has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/50627


Change subject: Add MessageReporter since core CR is slow as usual
......................................................................

Add MessageReporter since core CR is slow as usual

Change-Id: I8575626363e2e57e66016ee5448df4249ab4e9f0
---
M repo/config/Wikibase.experimental.php
A repo/includes/MessageReporter.php
2 files changed, 132 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/27/50627/1

diff --git a/repo/config/Wikibase.experimental.php 
b/repo/config/Wikibase.experimental.php
index bb3a70c..e2c7650 100644
--- a/repo/config/Wikibase.experimental.php
+++ b/repo/config/Wikibase.experimental.php
@@ -45,6 +45,13 @@
 $wgAutoloadClasses['Wikibase\QueryContent']                    = $dir . 
'includes/content/QueryContent.php';
 $wgAutoloadClasses['Wikibase\QueryHandler']                    = $dir . 
'includes/content/QueryHandler.php';
 
+
+if ( !class_exists( 'MessageReporter' ) ) {
+       $wgAutoloadClasses['MessageReporter'] = $dir . 
'includes/MessageReporter.php';
+       $wgAutoloadClasses['ObservableMessageReporter'] = $dir . 
'includes/MessageReporter.php';
+}
+
+
 $wgAPIModules['wbremovequalifiers']                            = 
'Wikibase\Repo\Api\RemoveQualifiers';
 $wgAPIModules['wbsetqualifier']                                        = 
'Wikibase\Repo\Api\SetQualifier';
 $wgAPIModules['wbsetstatementrank']                            = 
'Wikibase\Api\SetStatementRank';
diff --git a/repo/includes/MessageReporter.php 
b/repo/includes/MessageReporter.php
new file mode 100644
index 0000000..fd13294
--- /dev/null
+++ b/repo/includes/MessageReporter.php
@@ -0,0 +1,125 @@
+<?php
+
+// NOTE: This copy is here in WB now so I am not blocked for months
+// while people complain about whitespace on CR. This file will
+// either go if it finally gets merged into core or will be changed
+// to be in WB NS is people are to ignorant to see the point of it and not 
merge.
+
+/**
+ * Interface for objects that can report messages.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @since 1.21
+ * @file
+ *
+ * @licence GNU GPL v2+
+ * @author Jeroen De Dauw < jeroended...@gmail.com >
+ */
+interface MessageReporter {
+
+       /**
+        * Report the provided message.
+        *
+        * @since 1.21
+        *
+        * @param string $message
+        */
+       public function reportMessage( $message );
+
+}
+
+/**
+ * Message reporter that reports messages by passing them along to all
+ * registered handlers.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @since 1.21
+ * @file
+ *
+ * @licence GNU GPL v2+
+ * @author Jeroen De Dauw < jeroended...@gmail.com >
+ */
+class ObservableMessageReporter implements MessageReporter {
+
+       /**
+        * @since 1.21
+        *
+        * @var MessageReporter[]
+        */
+       protected $reporters = array();
+
+       /**
+        * @since 1.21
+        *
+        * @var callable[]
+        */
+       protected $callbacks = array();
+
+       /**
+        * @see MessageReporter::report
+        *
+        * @since 1.21
+        *
+        * @param string $message
+        */
+       public function reportMessage( $message ) {
+               foreach ( $this->reporters as $reporter ) {
+                       $reporter->reportMessage( $message );
+               }
+
+               foreach ( $this->callbacks as $callback ) {
+                       call_user_func( $callback, $message );
+               }
+       }
+
+       /**
+        * Register a new message reporter.
+        *
+        * @since 1.21
+        *
+        * @param MessageReporter $reporter
+        */
+       public function registerMessageReporter( MessageReporter $reporter ) {
+               $this->reporters[] = $reporter;
+       }
+
+       /**
+        * Register a callback as message reporter.
+        *
+        * @since 1.21
+        *
+        * @param callable $handler
+        */
+       public function registerReporterCallback( $handler ) {
+               $this->callbacks[] = $handler;
+       }
+
+}

-- 
To view, visit https://gerrit.wikimedia.org/r/50627
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8575626363e2e57e66016ee5448df4249ab4e9f0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw <jeroended...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to