diff --git a/inc/Core/Steps/Fetch/Handlers/FetchHandler.php b/inc/Core/Steps/Fetch/Handlers/FetchHandler.php index cb3cf1a43..997c5f1e7 100644 --- a/inc/Core/Steps/Fetch/Handlers/FetchHandler.php +++ b/inc/Core/Steps/Fetch/Handlers/FetchHandler.php @@ -83,9 +83,9 @@ final public function get_fetch_data( int|string $pipeline_id, array $handler_co $items = $this->filterProcessed( $items, $context ); // Apply max_items cap. - // Default to 1 to prevent unbounded fan-out when flows lack an - // explicit max_items value. Set to 0 for unlimited. - $max_items = (int) ( $config['max_items'] ?? 1 ); + // Default comes from getDefaultMaxItems() which subclasses can override. + // Set to 0 for unlimited. + $max_items = (int) ( $config['max_items'] ?? $this->getDefaultMaxItems() ); if ( $max_items > 0 && count( $items ) > $max_items ) { $items = array_slice( $items, 0, $max_items ); } @@ -182,6 +182,20 @@ protected function onItemProcessed( ExecutionContext $context, array $item ): vo // No-op in base class. Subclasses override as needed. } + /** + * Get the default max_items value when not explicitly configured. + * + * Base handlers default to 1 to prevent unbounded fan-out for + * AI-heavy pipelines (RSS, Reddit, etc.). Subclasses like + * EventImportHandler override to 0 (unlimited) since structured + * event scrapers produce clean data that is cheap to process. + * + * @return int Default max items. 0 = unlimited. + */ + protected function getDefaultMaxItems(): int { + return 1; + } + /** * Convert raw item arrays into DataPackets. *