]> git.mxchange.org Git - hub.git/commitdiff
Added assert() calls to make sure the package is valid
authorRoland Häder <roland@mxchange.org>
Sun, 23 Jun 2013 19:18:09 +0000 (19:18 +0000)
committerRoland Häder <roland@mxchange.org>
Sun, 23 Jun 2013 19:18:09 +0000 (19:18 +0000)
application/hub/main/discovery/package/class_PackageRecipientDiscovery.php
application/hub/main/package/class_NetworkPackage.php

index ce5d075a76a04a4a8ca3e470b6705f42806c115c..ae48aa47bd6b34618cf5ed3e4d9b642f1b8d5d4b 100644 (file)
@@ -60,6 +60,7 @@ class PackageRecipientDiscovery extends BaseHubDiscovery implements Discoverable
         */
        public function discoverRecipients (array $packageData) {
                // This must be available
+               //* DEBUG: */ print $this->__toString() . ': packageData=' . print_r($packageData, TRUE);
                assert(isset($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]));
 
                // First try out the direct recipient (session id)
index 8202882765292c418c6ab15400a602488d66d413..c050b3e1cf91358a81d707beaebb2c5fe0fc7d44 100644 (file)
@@ -408,6 +408,9 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R
         * @return      void
         */
        private function declareRawPackageData (array $packageData) {
+               // Make sure the required field is there
+               assert(isset($packageData[self::PACKAGE_DATA_RECIPIENT]));
+
                /*
                 * We need to disover every recipient, just in case we have a
                 * multi-recipient entry like 'upper' is. 'all' may be a not so good
@@ -697,13 +700,10 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R
                 * Now there are for sure packages to deliver, so start with the first
                 * one.
                 */
-               $packageData = $this->getStackerInstance()->getNamed(self::STACKER_NAME_UNDECLARED);
+               $packageData = $this->getStackerInstance()->popNamed(self::STACKER_NAME_UNDECLARED);
 
                // Declare the raw package data for delivery
                $this->declareRawPackageData($packageData);
-
-               // And remove it finally
-               $this->getStackerInstance()->popNamed(self::STACKER_NAME_UNDECLARED);
        }
 
        /**
@@ -724,6 +724,10 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R
                // Get the package
                $packageData = $this->getStackerInstance()->getNamed(self::STACKER_NAME_DECLARED);
 
+               // Assert on it
+               assert($packageData[self::PACKAGE_DATA_RECIPIENT]);
+
+               // Try to deliver the package
                try {
                        // And try to send it
                        $this->deliverRawPackageData($packageData);