From: Roland Häder Date: Thu, 26 Aug 2021 02:13:03 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=1fae422be6059a8ddf481d6e18b87dcbc9f95775;p=hub.git Continued: - Use readCsvFileLine()'s 2nd parameter to check if read CSV lines are properly formatted (3 elements are present) - updated 'core' framework Signed-off-by: Roland Häder --- diff --git a/application/hub/classes/source/urls/class_CrawlerUploadedListUrlSource.php b/application/hub/classes/source/urls/class_CrawlerUploadedListUrlSource.php index f012e66fc..d9cfeb9be 100644 --- a/application/hub/classes/source/urls/class_CrawlerUploadedListUrlSource.php +++ b/application/hub/classes/source/urls/class_CrawlerUploadedListUrlSource.php @@ -14,6 +14,7 @@ use Org\Mxchange\CoreFramework\Generic\NullPointerException; use Org\Mxchange\CoreFramework\Registry\Registerable; // Import SPL stuff +use \OutOfBoundsException; use \SplFileInfo; /** @@ -196,7 +197,7 @@ class CrawlerUploadedListUrlSource extends BaseUrlSource implements UrlSource, R private function saveCsvDataInCrawlerQueue (array $csvData) { // The array must have a fixed amount of elements, later enhancements may accept more /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CRAWLER-UPLOADED-LIST-URL-SOURCE: csvData()=' . count($csvData) . ' - CALLED!'); - assert(count($csvData) == self::CRAWL_ENTRY_SIZE); + assert(count($csvData) == self::CRAWL_ENTRY_SIZE, sprintf('csvData has unexpected size %d/%d', count($csvData), self::CRAWL_ENTRY_SIZE)); /* * First converted the indexed array into an assoziative array. Don't @@ -302,7 +303,7 @@ class CrawlerUploadedListUrlSource extends BaseUrlSource implements UrlSource, R $csvFileInstance = $this->getStackSourceInstance()->popNamed(self::STACK_NAME_CSV_FILE); // Read full "CSV line" - $csvData = $csvFileInstance->readCsvFileLine($this->columnSeparator); + $csvData = $csvFileInstance->readCsvFileLine($this->columnSeparator, self::CRAWL_ENTRY_SIZE); // Is the array empty? /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CRAWLER-UPLOADED-LIST-URL-SOURCE: csvData[%s]=%s', gettype($csvData), print_r($csvData, TRUE))); @@ -317,7 +318,7 @@ class CrawlerUploadedListUrlSource extends BaseUrlSource implements UrlSource, R } // ... with a fixed amount of elements, later enhancements may accept more - assert(count($csvData) == self::CRAWL_ENTRY_SIZE); + assert(count($csvData) == self::CRAWL_ENTRY_SIZE, sprintf('csvData has unexpected size %d/%d', count($csvData), self::CRAWL_ENTRY_SIZE)); /* * Push the file back on stack as it may contain more entries. This way @@ -344,7 +345,7 @@ class CrawlerUploadedListUrlSource extends BaseUrlSource implements UrlSource, R // It must have a fixed amount of elements (see method parseCsvFile() for details) /* PRINTR-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CRAWLER-UPLOADED-LIST-URL-SOURCE: csvData[' . gettype($csvData) . ']=' . print_r($csvData, TRUE)); - assert(count($csvData) == self::CRAWL_ENTRY_SIZE); + assert(count($csvData) == self::CRAWL_ENTRY_SIZE, sprintf('csvData has unexpected size %d/%d', count($csvData), self::CRAWL_ENTRY_SIZE)); // Save it in crawler queue (which will enrich it with way more informations $this->saveCsvDataInCrawlerQueue($csvData); diff --git a/core b/core index 7798dfbfa..7c7b31032 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 7798dfbfa76e420d9c696c2cb5be60cfd66b23d2 +Subproject commit 7c7b31032ea193ccc98c64038bff678023bc4619