Adamw has uploaded a new change for review.

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


Change subject: More core prequel for Amazon
......................................................................

More core prequel for Amazon

Change-Id: I4f1e8ad97b9c1775b4cff76a1147f626e6e625aa
---
M SmashPig/Core/Http/Request.php
M SmashPig/Core/Listeners/ListenerBase.php
M SmashPig/Core/Listeners/RestListener.php
M SmashPig/Core/Messages/ListenerMessage.php
4 files changed, 29 insertions(+), 11 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/PaymentsListeners 
refs/changes/23/61923/1

diff --git a/SmashPig/Core/Http/Request.php b/SmashPig/Core/Http/Request.php
index bae378e..c54657b 100644
--- a/SmashPig/Core/Http/Request.php
+++ b/SmashPig/Core/Http/Request.php
@@ -5,7 +5,21 @@
 
     }
 
+    /**
+     * Get post data without interpretation
+     *
+     * @return string
+     */
     public function getRawPostData() {
         return file_get_contents( 'php://input' );
     }
+
+    /**
+     * Return all GET/POST/COOKIE data as an associative array
+     *
+     * @return array
+     */
+    public function getValues() {
+        return $_REQUEST;
+    }
 }
diff --git a/SmashPig/Core/Listeners/ListenerBase.php 
b/SmashPig/Core/Listeners/ListenerBase.php
index ab681c7..bab03b3 100644
--- a/SmashPig/Core/Listeners/ListenerBase.php
+++ b/SmashPig/Core/Listeners/ListenerBase.php
@@ -133,7 +133,7 @@
                                return false;
                        }
         } catch ( \Exception $ex ) {
-
+               Logger::error( 'Failed message security check: ' . 
$ex->getMessage() );
         }
 
         // We caught exceptions: therefore the message was not correctly 
processed.
diff --git a/SmashPig/Core/Listeners/RestListener.php 
b/SmashPig/Core/Listeners/RestListener.php
index 1520c52..a13e5bf 100644
--- a/SmashPig/Core/Listeners/RestListener.php
+++ b/SmashPig/Core/Listeners/RestListener.php
@@ -16,9 +16,12 @@
 
             if ( is_array( $msgs ) ) {
                 foreach ( $msgs as $msg ) {
-                    $this->pendingStore->add_message( $msg );
+                    //FIXME: this looks like an elaborate try-catch.  If 
there's
+                    //a fatal exception, the remaining messages are toast 
anyway,
+                    //so we should... do something different here.
+                    $this->pendingStore->addObject( $msg );
                     if ( $this->processMessage( $msg ) ) {
-                        $this->pendingStore->remove_message( $msg );
+                        $this->pendingStore->removeObjects( $msg );
                     }
                 }
             }
@@ -44,17 +47,17 @@
     }
 
     /**
-     * Parse the raw data from the web request and turn it into an array of 
message objects. This
-     * function should not return an exception unless the configuration data 
is malformed. If an
-     * individual message element in the envelope is malformed this function 
should log it and
-     * continue as normal.
+     * Parse the web request and turn it into an array of message objects.
      *
-     * @param string $data Raw web-request data
+     * This function should not throw an exception strictly caused by message
+     * contents. If an individual message in the envelope is malformed, this
+     * function should log it and continue as normal.
+     *
+     * @param Request $request Raw web-request
      *
      * @throws ListenerConfigException
-     * @throws ListenerDataException
      *
-     * @return mixed Array of @see Message
+     * @return array of @see Message
      */
     abstract protected function parseEnvelope( Request $request );
 
diff --git a/SmashPig/Core/Messages/ListenerMessage.php 
b/SmashPig/Core/Messages/ListenerMessage.php
index 2dd381b..d6674ea 100644
--- a/SmashPig/Core/Messages/ListenerMessage.php
+++ b/SmashPig/Core/Messages/ListenerMessage.php
@@ -1,5 +1,6 @@
 <?php namespace SmashPig\Core\Messages;
 
+use SmashPig\Core\Actions\IListenerMessageAction;
 use SmashPig\Core\Configuration;
 use SmashPig\Core\DataStores\KeyedOpaqueStorableObject;
 use SmashPig\Core\Logging\Logger;
@@ -34,7 +35,7 @@
 
                foreach( $actions as $actionClassName ) {
                        $action = new $actionClassName;
-                       if ( $action instanceof 
\SmashPig\Core\Actions\IListenerMessageAction ) {
+                       if ( $action instanceof IListenerMessageAction ) {
                                Logger::debug( "Running action 
{$actionClassName}." );
                                if ( !$action->execute( $this ) ) {
                                        Logger::info( "Action 
{$actionClassName} did not execute properly, will re-queue." );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4f1e8ad97b9c1775b4cff76a1147f626e6e625aa
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/PaymentsListeners
Gerrit-Branch: master
Gerrit-Owner: Adamw <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to