Hello Aaron Schulz, Krinkle, jenkins-bot,
I'd like you to do a code review. Please visit
https://gerrit.wikimedia.org/r/349181
to review the following change.
Change subject: Revert "rpc: raise exception instead of die"
......................................................................
Revert "rpc: raise exception instead of die"
Causes exception spam when running scap pull on a jobrunner.
Will revisit later on.
This reverts commit 5944c13b05d41713ba7f056f0eae187b643f1c41.
Change-Id: Ic168ab4026b84a71f49da9803c250026938485f5
---
M rpc/RunJobs.php
D tests/rpc/RunJobsTest.php
2 files changed, 2 insertions(+), 47 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/operations/mediawiki-config
refs/changes/81/349181/1
diff --git a/rpc/RunJobs.php b/rpc/RunJobs.php
index b479b07..2db74e7 100755
--- a/rpc/RunJobs.php
+++ b/rpc/RunJobs.php
@@ -19,9 +19,9 @@
* @author Aaron Schulz
*/
if ( !in_array( $_SERVER['REMOTE_ADDR'], array( '127.0.0.1',
'0:0:0:0:0:0:0:1', '::1' ), true ) ) {
- throw new Exception( "Only loopback requests are allowed.\n", 1 );
+ die( "Only loopback requests are allowed.\n" );
} elseif ( $_SERVER['REQUEST_METHOD'] !== 'POST' ) {
- throw new Exception( "Request must use POST.\n", 2 );
+ die( "Request must use POST.\n" );
}
define( 'MEDIAWIKI_JOB_RUNNER', 1 );
diff --git a/tests/rpc/RunJobsTest.php b/tests/rpc/RunJobsTest.php
deleted file mode 100644
index becd086..0000000
--- a/tests/rpc/RunJobsTest.php
+++ /dev/null
@@ -1,45 +0,0 @@
-<?php
-class RunJobsTest extends \PHPUnit_Framework_TestCase {
- protected $oldServer;
-
- protected function setUp() {
- parent::setUp();
-
- $this->oldServer = $_SERVER;
- }
-
- protected function tearDown() {
- $_SERVER = $this->oldServer;
-
- parent::tearDown();
- }
-
- /**
- * @expectedException Exception
- * @expectedExceptionCode 1
- * @expectedExceptionMessage Only loopback requests are allowed
- */
- function testRaiseAnExceptionFromNonLocalhost() {
- $_SERVER['REMOTE_ADDR'] = '192.0.2.42';
- require __DIR__ . '/../../rpc/RunJobs.php';
- }
-
- /**
- * @dataProvider provideLocalhostIps
- *
- * @expectedException PHPUnit_Framework_Error_Notice
- * @expectedExceptionMessage Undefined index: REQUEST_METHOD
- */
- function testAcceptLocalhostRequest( $address ) {
- $_SERVER['REMOTE_ADDR'] = $address;
- require __DIR__ . '/../../rpc/RunJobs.php';
- }
-
- public function provideLocalhostIps() {
- return [
- 'IPv4 loopback' => [ '127.0.0.1' ],
- 'IPv6 loopback' => [ '0:0:0:0:0:0:0:1' ],
- 'IPv6 loopback (short)' => [ '::1' ],
- ];
- }
-}
--
To view, visit https://gerrit.wikimedia.org/r/349181
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic168ab4026b84a71f49da9803c250026938485f5
Gerrit-PatchSet: 1
Gerrit-Project: operations/mediawiki-config
Gerrit-Branch: master
Gerrit-Owner: Hashar <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits