Lucas_Werkmeister_WMDE added a comment.
I tried deferring the `createMultiClient()` call a bit in EventBus –
diff --git a/ServiceWiring.php b/ServiceWiring.php
index 67912b5..9883d78 100644
--- a/ServiceWiring.php
+++ b/ServiceWiring.php
@@ -24,7 +24,7 @@
),
$streamConfigs,
$services->get( 'EventBus.EventFactory' ),
- $services->getHttpRequestFactory()->createMultiClient(),
+ $services->getHttpRequestFactory(),
LoggerFactory::getInstance( 'EventBus' )
);
},
diff --git a/includes/EventBusFactory.php b/includes/EventBusFactory.php
index 85cf582..6ef715e 100644
--- a/includes/EventBusFactory.php
+++ b/includes/EventBusFactory.php
@@ -25,7 +25,7 @@
use InvalidArgumentException;
use MediaWiki\Config\ServiceOptions;
use Mediawiki\Extension\EventStreamConfig\StreamConfigs;
-use MultiHttpClient;
+use MediaWiki\Http\HttpRequestFactory;
use Psr\Log\LoggerInterface;
/**
@@ -70,8 +70,8 @@ class EventBusFactory {
/** @var EventFactory */
private $eventFactory;
- /** @var MultiHttpClient */
- private $http;
+ /** @var HttpRequestFactory */
+ private $httpRequestFactory;
/** @var LoggerInterface */
private $logger;
@@ -83,14 +83,14 @@ class EventBusFactory {
* @param ServiceOptions $options
* @param StreamConfigs|null $streamConfigs
* @param EventFactory $eventFactory
- * @param MultiHttpClient $http
+ * @param HttpRequestFactory $httpRequestFactory
* @param LoggerInterface $logger
*/
public function __construct(
ServiceOptions $options,
?StreamConfigs $streamConfigs,
EventFactory $eventFactory,
- MultiHttpClient $http,
+ HttpRequestFactory $httpRequestFactory,
LoggerInterface $logger
) {
$options->assertRequiredOptions( self::CONSTRUCTOR_OPTIONS );
@@ -101,7 +101,7 @@ public function __construct(
$this->maxBatchByteSize = $options->get(
'EventBusMaxBatchByteSize' );
$this->streamConfigs = $streamConfigs;
$this->eventFactory = $eventFactory;
- $this->http = $http;
+ $this->httpRequestFactory = $httpRequestFactory;
$this->logger = $logger;
}
@@ -138,7 +138,7 @@ public function getInstance( string $eventServiceName )
: EventBus {
if ( !array_key_exists( $eventServiceName,
$this->eventBusInstances ) ) {
$this->eventBusInstances[$eventServiceName] = new
EventBus(
- $this->http,
+ $this->httpRequestFactory->createMultiClient(),
$this->enableEventBus,
$this->eventFactory,
$url,
diff --git a/tests/phpunit/unit/EventBusFactoryTest.php
b/tests/phpunit/unit/EventBusFactoryTest.php
index d2b5f3f..9dc8514 100644
--- a/tests/phpunit/unit/EventBusFactoryTest.php
+++ b/tests/phpunit/unit/EventBusFactoryTest.php
@@ -1,8 +1,10 @@
<?php
+
use MediaWiki\Config\ServiceOptions;
use MediaWiki\Extension\EventBus\EventBusFactory;
use MediaWiki\Extension\EventBus\EventFactory;
use MediaWiki\Extension\EventStreamConfig\StreamConfigs;
+use MediaWiki\Http\HttpRequestFactory;
use Psr\Log\NullLogger;
use Wikimedia\TestingAccessWrapper;
@@ -48,7 +50,7 @@ private function getEventBusFactory( array $mwConfig ) :
EventBusFactory {
),
$streamConfigs,
$this->createNoOpMock( EventFactory::class ),
- $this->createNoOpMock( MultiHttpClient::class ),
+ $this->createNoOpMock( HttpRequestFactory::class ),
new NullLogger()
);
}
– but it doesn’t work. The hook handler that’s being called accesses not just
the `EventBusFactory`, but a specific `EventBus` instance, so as long as the
`EventBus` gets a `MultiHttpClient` injected the test will still fail.
Maybe `MockHttpTrait` should allow calls to `createMultiClient()` (and
possibly `createGuzzleClient()`, which looks similar), and only fail the test
when an actual request is launched (`run()`, `runMulti()`)?
TASK DETAIL
https://phabricator.wikimedia.org/T272998
EMAIL PREFERENCES
https://phabricator.wikimedia.org/settings/panel/emailpreferences/
To: Lucas_Werkmeister_WMDE
Cc: Ottomata, Mholloway, Addshore, Silvan_WMDE, WMDE-leszek,
Lucas_Werkmeister_WMDE, Aklapper, Alter-paule, Beast1978, Un1tY, Akuckartz,
Hook696, Iflorez, Kent7301, alaa_wmde, joker88john, DannyS712, CucyNoiD,
Nandana, Gaboe420, Giuliamocci, Cpaulf30, Lahi, Gq86, Af420, Bsandipan,
Pablo-WMDE, GoranSMilovanovic, QZanden, LawExplorer, Lewizho99, Maathavan,
_jensen, rosalieper, Scott_WUaS, Jonas, Wikidata-bugs, aude, Lydia_Pintscher,
Jdforrester-WMF, Mbch331
_______________________________________________
Wikidata-bugs mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikidata-bugs