Skip to content

Commit c7c08d7

Browse files
authored
Merge pull request #98 from SemanticMediaWiki/fix-lingo-cache-type-typo
Fix the wgexLingoCacheType setting being ignored due to a typo
2 parents 5134bd4 + ef6f853 commit c7c08d7

4 files changed

Lines changed: 28 additions & 4 deletions

File tree

RELEASE-NOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ This file contains the RELEASE-NOTES of the Semantic Glossary (a.k.a. SG) extens
77
* Fixed glossary cache invalidation on page edits, which stopped working after Semantic MediaWiki renamed the data-update hook
88
* Fixed the `rebuildGlossaryCache.php` maintenance script against Semantic MediaWiki 7.0
99
* Moved hook registration into `extension.json` and removed the procedural extension entry point; the Lingo backend registration no longer overwrites a custom `$wgexLingoBackend` set in `LocalSettings.php`
10+
* Fixed `$wgexLingoCacheType` being ignored due to a `$GLOBAL`/`$GLOBALS` typo; a custom cache type configured for the glossary cache is now honored
1011

1112
### 6.0.0
1213

src/Cache/GlossaryCache.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ public function getKeyForLingo() {
7272
* @return string
7373
*/
7474
public function getCacheType() {
75-
if ( isset( $GLOBAL['wgexLingoCacheType'] ) && $GLOBAL['wgexLingoCacheType'] !== null ) {
76-
return $GLOBAL['wgexLingoCacheType'];
75+
if ( isset( $GLOBALS['wgexLingoCacheType'] ) && $GLOBALS['wgexLingoCacheType'] !== null ) {
76+
return $GLOBALS['wgexLingoCacheType'];
7777
}
7878

7979
return $GLOBALS['wgMainCacheType'];

tests/phpunit/Unit/Cache/GlossaryCacheTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,29 @@ public function testGetCacheType() {
3939
);
4040
}
4141

42+
public function testGetCacheTypeRespectsLingoCacheType() {
43+
$instance = new GlossaryCache();
44+
45+
$previousLingo = $GLOBALS['wgexLingoCacheType'] ?? null;
46+
$previousMain = $GLOBALS['wgMainCacheType'];
47+
48+
// Pick a Lingo cache type distinct from the main cache type so the
49+
// assertion fails if the (formerly mistyped) override is ignored and
50+
// the main cache type is returned instead.
51+
$GLOBALS['wgexLingoCacheType'] = CACHE_DB;
52+
$GLOBALS['wgMainCacheType'] = CACHE_NONE;
53+
54+
try {
55+
$this->assertSame(
56+
CACHE_DB,
57+
$instance->getCacheType()
58+
);
59+
} finally {
60+
$GLOBALS['wgexLingoCacheType'] = $previousLingo;
61+
$GLOBALS['wgMainCacheType'] = $previousMain;
62+
}
63+
}
64+
4265
public function testGetKeys() {
4366
$instance = new GlossaryCache();
4467

tests/phpunit/Unit/ConfigurationIntegrityTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ class ConfigurationIntegrityTest extends \PHPUnit\Framework\TestCase {
2020
public function testValidityOfCacheTypeSetting() {
2121
$instance = new GlossaryCache();
2222

23-
if ( isset( $GLOBAL['wgexLingoCacheType'] ) ) {
24-
$this->assertCacheType( $GLOBAL['wgexLingoCacheType'] );
23+
if ( isset( $GLOBALS['wgexLingoCacheType'] ) ) {
24+
$this->assertCacheType( $GLOBALS['wgexLingoCacheType'] );
2525
}
2626

2727
$this->assertCacheType( $instance->getCacheType() );

0 commit comments

Comments
 (0)