$this->setMwGlobals( array(
'wgDebugLogFile' => $debugLogFile,
- # @todo FIXME: $wgDebugTimestamps should be tested
+ # @todo FIXME: $wgDebugTimestamps should be tested
'wgDebugTimestamps' => false
) );
'gzip;q=1.0' => true,
'foozip' => false,
'foo*zip' => false,
- 'gzip;q=abcde' => true, //is this REALLY valid?
+ 'gzip;q=abcde' => true, // is this REALLY valid?
'gzip;q=12345678.9' => true,
' gzip' => true,
);
public static function provideMakeUrlIndexes() {
return array(
+ // Testcase for T30627
array(
- // just a regular :)
- 'https://bugzilla.wikimedia.org/show_bug.cgi?id=28627',
- array( 'https://org.wikimedia.bugzilla./show_bug.cgi?id=28627' )
+ 'https://example.org/test.cgi?id=12345',
+ array( 'https://org.example./test.cgi?id=12345' )
),
array(
// mailtos are handled special
array( 'mailto:org.wikimedia@wiki.' )
),
- // file URL cases per bug 28627...
+ // file URL cases per T30627...
array(
// three slashes: local filesystem path Unix-style
'file:///whatever/you/like.txt',
// Those will survive the algorithm but with results that
// are less consistent.
- // protocol-relative URL cases per bug 29854...
+ // protocol-relative URL cases per T31854...
array(
- '//bugzilla.wikimedia.org/show_bug.cgi?id=28627',
+ '//example.org/test.cgi?id=12345',
array(
- 'http://org.wikimedia.bugzilla./show_bug.cgi?id=28627',
- 'https://org.wikimedia.bugzilla./show_bug.cgi?id=28627'
+ 'http://org.example./test.cgi?id=12345',
+ 'https://org.example./test.cgi?id=12345'
)
),
);
$this->assertEquals( $expected, $actual, $description );
}
+ public function wfWikiID() {
+ $this->setMwGlobals( array(
+ 'wgDBname' => 'example',
+ 'wgDBprefix' => '',
+ ) );
+ $this->assertEquals(
+ wfWikiID(),
+ 'example'
+ );
+
+ $this->setMwGlobals( array(
+ 'wgDBname' => 'example',
+ 'wgDBprefix' => 'mw_',
+ ) );
+ $this->assertEquals(
+ wfWikiID(),
+ 'example-mw_'
+ );
+ }
+
+ public function testWfMemcKey() {
+ // Just assert the exact output so we can catch unintentional changes to key
+ // construction, which would effectively invalidate all existing cache.
+
+ $this->setMwGlobals( array(
+ 'wgCachePrefix' => false,
+ 'wgDBname' => 'example',
+ 'wgDBprefix' => '',
+ ) );
+ $this->assertEquals(
+ wfMemcKey( 'foo', '123', 'bar' ),
+ 'example:foo:123:bar'
+ );
+
+ $this->setMwGlobals( array(
+ 'wgCachePrefix' => false,
+ 'wgDBname' => 'example',
+ 'wgDBprefix' => 'mw_',
+ ) );
+ $this->assertEquals(
+ wfMemcKey( 'foo', '123', 'bar' ),
+ 'example-mw_:foo:123:bar'
+ );
+
+ $this->setMwGlobals( array(
+ 'wgCachePrefix' => 'custom',
+ 'wgDBname' => 'example',
+ 'wgDBprefix' => 'mw_',
+ ) );
+ $this->assertEquals(
+ wfMemcKey( 'foo', '123', 'bar' ),
+ 'custom:foo:123:bar'
+ );
+ }
+
+ public function testWfForeignMemcKey() {
+ $this->setMwGlobals( array(
+ 'wgCachePrefix' => false,
+ 'wgDBname' => 'example',
+ 'wgDBprefix' => '',
+ ) );
+ $local = wfMemcKey( 'foo', 'bar' );
+
+ $this->setMwGlobals( array(
+ 'wgDBname' => 'other',
+ 'wgDBprefix' => 'mw_',
+ ) );
+ $this->assertEquals(
+ wfForeignMemcKey( 'example', '', 'foo', 'bar' ),
+ $local,
+ 'Match output of wfMemcKey from local wiki'
+ );
+ }
+
+ public function testWfGlobalCacheKey() {
+ $this->setMwGlobals( array(
+ 'wgCachePrefix' => 'ignored',
+ 'wgDBname' => 'example',
+ 'wgDBprefix' => ''
+ ) );
+ $one = wfGlobalCacheKey( 'some', 'thing' );
+ $this->assertEquals(
+ $one,
+ 'global:some:thing'
+ );
+
+ $this->setMwGlobals( array(
+ 'wgDBname' => 'other',
+ 'wgDBprefix' => 'mw_'
+ ) );
+ $two = wfGlobalCacheKey( 'some', 'thing' );
+
+ $this->assertEquals(
+ $one,
+ $two,
+ 'Not fragmented by wiki id'
+ );
+ }
+
public static function provideWfShellWikiCmdList() {
global $wgPhpCli;