Commit graph

38 commits

Author SHA1 Message Date
daniel
7b45d112e6 Fix inconsistent spec of InterwikiLookup::getAllPrefixes.
The documented return type was not what existing callers expected,
and not what the default implementation actually returned.

This patch fixes the interface documentation and the behavior of
an alternative implementation.

Change-Id: Ib09bffeba3ddc5b43da1c7c299f1fa946be4e2e2
2017-05-04 08:40:35 +00:00
daniel
025f15a208 Factor InterwikiLookup out of Interwiki class.
This keeps the existing app logic for looking up interwiki information
intact in ClassicInterwikiLookup. The idea is to seamlessly switch to a new
implementation when it becomes available, while also allowing us to
switch back in case of problems.

Change-Id: I7d7424345d0ce3ce90ba284006ee9615e3d99baa
2016-05-18 11:57:32 +02:00
Aaron Schulz
109feaba80 Remove wfDebug() from getInterwikiCacheEntry()
This is uses a fair amount of time according to flamegraphs.

Change-Id: I178a590ab5de2f6fb9366ad59434d8b27dad710d
2016-05-09 22:40:31 -07:00
daniel
ff764440da Introduce InterwikiTest
This test class verifies that Interwiki currectly handles information
from the database, CDB files, and plain arrays. This is intended to
allow confident refactoring when implementing T113034.

Bug: T113034
Change-Id: I2b68d11e3e946d81fa5f5f65a28fc399e7936c0f
2016-04-23 21:44:59 +02:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00
Ori Livneh
7f7863a8a9 interwiki: Fix-up for I5a979f047031e
Make Interwiki::getAllPrefixesCached() work when $wgInterwikiCache is set to a
static array (rather than path to a CDB file).  Follows I5a979f047031e.

Bug: T122362
Change-Id: I003e055471747afdcc82440490456e03cc67cc1a
2016-02-09 20:23:15 +00:00
Ori Livneh
eb7cc60aa7 Allow $wgInterwikiCache to be an associative array
For the same reasons wikiversions.cdb was converted to a PHP file -- viz., that
static arrays in PHP files get cached in HHVM's bytecode cache and are
therefore faster to use with HHVM than CDB files.

Bug: T122362
Change-Id: I5a979f047031ef211622f399df9b3b388797f53a
2015-12-23 22:23:52 +00:00
Aaron Schulz
91c7084b63 Update getWithSetCallback() callers to the newer signature
Change-Id: I1cda46178c16b7ffad97d09f8480fd57f766be57
2015-10-07 19:27:08 -07:00
Aaron Schulz
54758dd160 Change getCacheSetOptions() callers to use "Database"
* This is less verbose that DatabaseBase
* Also add a few WAN cache doc comments

Change-Id: I5b6de6d0ffa06753ea96c50b63db7dae796475dc
2015-10-05 22:06:46 -07:00
Aaron Schulz
db0b9ef264 Make WANObjectCache sets account for slave lag
* This gets lag information that is useful when
  the calling code is about to run queries that
  will have their results cached.
* This is now used in place of trxTimestamp() for
  WANObjectCache set() and getWithSetCallback().
* The WAN cache will use a low TTL if the lag is
  too high to avoid caching stale data for weeks.
* Bumped MAX_COMMIT_DELAY as nothing enforces it.

Bug: T113204
Change-Id: I2a95b4088cff42d6e980351555f81a4b13519e24
2015-10-05 16:45:13 -07:00
Aaron Schulz
7cb83f0bb3 Converted Interwiki::load to using getWithSetCallback()
Change-Id: I4299715ce4c996fed8add773aa03441324eb0dfc
2015-09-29 23:52:41 -07:00
Aaron Schulz
4a74dbf198 Converted Interwiki using WAN cache
* Added an invalidateCache() method for the Interwiki extension

Bug: T93141
Change-Id: Id4f8b6fb9bfe26f6b5e5ce32e4e55d51eb37964d
2015-04-30 01:33:22 +00:00
Aaron Schulz
e369f66d00 Replace wfRunHooks calls with direct Hooks::run calls
* This avoids the overhead of an extra function call

Change-Id: I8ee996f237fd111873ab51965bded3d91e61e4dd
2014-12-10 12:26:59 -08:00
Kunal Mehta
987d2e4c77 Use cdb library and provide a back-compat layer
The new cdb library is pulled in via composer. Since the
library uses namespaces, a backwards-compatability layer
is provided for the old class names:
* CdbReader
* CdbWriter
* CdbException

The PHP/DBA-specific classes should never have been used directly.

Depends on I98302bdf1 in mediawiki/vendor

Change-Id: I39549ac8540b262cf91f7d1830d36327afb3033d
2014-11-19 18:39:27 +00:00
umherirrender
b883e8c7c0 Cleanup some docs (includes/[e-l])
- Swap "$variable type" to "type $variable"
- Added missing types
- Fixed spacing inside docs
- Makes beginning of @param/@return/@var/@throws in capital
- Changed some types to match the more common spelling

Change-Id: I41a84e8e1dec39170aa655250325ffc485eaeaef
2014-07-24 19:43:03 +02:00
Siebrand Mazeland
3cb6887bca Updates for Interwiki.php
* Change default type for $iwData to be the same as possible updated values
* Remove superfluous else{}
* Break long lines
* Update documentation
* Update formatting

Change-Id: Ie1a655def0e9a4f71495ce5936964ef81a146297
2013-12-02 12:00:01 +01:00
Chad Horohoe
e7404af422 Improved CdbException handling in Interwiki
Change-Id: I6461b64dc77b3ecc641db39da1e9be306100fda3
2013-11-26 15:28:39 -08:00
umherirrender
9d6575af15 The static declaration must come after the visibility declaration
From phpcs

Change-Id: Ieab0207f965630eda113abdc0259aa2eddcf5ca7
2013-01-26 21:03:52 +01:00
Siebrand Mazeland
02aa6edd3d Update doc comments and code formatting.
Change-Id: Ib182878e08d19261d9803fd4d7e215570a2ffed4
2013-01-21 21:45:13 +00:00
Reedy
e38706a0e1 Interwiki::fetch can return null, false or an interwiki object
Change-Id: If8c3bf0ceb2d1162cc64c0dc367ebfa4729e8f2e
2012-06-11 23:04:02 +01:00
umherirrender
38a2cd320a add Interwiki::selectFields
to avoid * inside select

Change-Id: I9d0ac631d9389744f68d744fa1d3fa3e3866a956
2012-05-11 22:16:19 +02:00
Alexandre Emsenhuber
63176b99b7 Added missing GPLv2 headers in some places.
Also made file/class documentation more consistent.

Change-Id: I1deb70318d01a257b51948ba806d80cd1a239f4f
2012-05-04 08:47:07 +02:00
Sam Reed
08e4a19369 Documentation updates
Normalise method returns
2012-03-05 15:23:04 +00:00
Sam Reed
6454687806 Improve documentation
Simplify if

Fix whitespace
2012-02-02 20:19:20 +00:00
Sam Reed
937fc3bcfd Back out r95396 and friends 2011-09-29 22:08:00 +00:00
Aaron Schulz
50305c2864 FU r98109: !EMPTY -> !NONEXISTENT (more consistent with elsewhere) 2011-09-26 22:46:40 +00:00
Aaron Schulz
8ecde9b038 Cache negative results for interwiki prefix checks. Also helps filecache fail-over mode if DB is down. 2011-09-26 03:37:20 +00:00
Sam Reed
44020e254c Merge the iwtransclusion branch back into trunk
Hexmode fixed broken unit tests in revisions after last time
2011-08-24 13:03:03 +00:00
Daniel Friesen
ecd274f432 Followup r94353; Use !== null since that's what we use in core. 2011-08-14 14:20:59 +00:00
Daniel Friesen
b7474f0743 Followup r94349; Interwiki::getURL used $title != null to test if the $title arg was passed and should be substituted. However "" == null, so as a result switching to using the argument broke [[mw:]] style interwiki links without an article title.
Update the Interwiki::getURL code to use isset(), and update the comment to tell pre-1.19 supporting extensions to do the entire urlencoding and $1 substitution on their own since Interwiki::getURL was essentially buggy and broken before now.
2011-08-12 14:55:25 +00:00
Daniel Friesen
d5dfd2b066 Update Interwiki::getURL's first argument so that it's properly urlencoded when replacements are made.
Scanning all of core and all the extensions we have in svn, it doesn't look like anyone makes any calls to Interwiki::getURL using the argument so this should be safe enough to clean up the api.
Also update Title::getFullURL to make use of the first arg now.
2011-08-12 14:10:37 +00:00
Sam Reed
183d2dab37 Back out r93533, r93531, r93530
Breaks unit tests as below, not going to be able to fix them before I disappear for the evening, so might aswell leave trunk clean

ArticleTablesTest testbug14404

Error:
ArticleTablesTest::testbug14404
Undefined offset: 0

/home/ci/cruisecontrol-bin-2.8.3/projects/mw/source/tests/phpunit/includes/ArticleTablesTest.php:31
/home/ci/cruisecontrol-bin-2.8.3/projects/mw/source/tests/phpunit/MediaWikiTestCase.php:60
/home/ci/cruisecontrol-bin-2.8.3/projects/mw/source/tests/phpunit/MediaWikiPHPUnitCommand.php:20
/home/ci/cruisecontrol-bin-2.8.3/projects/mw/source/tests/phpunit/phpunit.php:60

ParserTests testParserTest #552 - testParserTest with data set #551

Failure:
ParserTests::testParserTest with data set #551 ('RAW magic word', '{{RAW:QUERTY}}', '<p><a href="/index.php?title=Template:QUERTY&amp;action=edit&amp;redlink=1" class="new" title="Template:QUERTY (page does not exist)">Template:QUERTY</a>
</p>', '', '')
RAW magic word
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-<p><a href="/index.php?title=Template:QUERTY&amp;action=edit&amp;redlink=1" class="new" title="Template:QUERTY (page does not exist)">Template:QUERTY</a>
+<p><a href="/index.php?title=Template:RAW:QUERTY&amp;action=edit&amp;redlink=1" class="new" title="Template:RAW:QUERTY (page does not exist)">Template:RAW:QUERTY</a>
 </p>

/home/ci/cruisecontrol-bin-2.8.3/projects/mw/source/tests/phpunit/includes/parser/NewParserTest.php:545
/home/ci/cruisecontrol-bin-2.8.3/projects/mw/source/tests/phpunit/MediaWikiTestCase.php:60
/home/ci/cruisecontrol-bin-2.8.3/projects/mw/source/tests/phpunit/MediaWikiPHPUnitCommand.php:20
/home/ci/cruisecontrol-bin-2.8.3/projects/mw/source/tests/phpunit/phpunit.php:60
2011-07-30 15:56:54 +00:00
Sam Reed
dc9d39887e Merge iwtransclusion branch into trunk 2011-07-30 15:30:01 +00:00
Robin Pepermans
d898a5fa86 Fixes for r92538 & r92528:
* use default null for $local
* use foreach for database result
2011-07-21 22:19:23 +00:00
Robin Pepermans
472801ecfa Follow-up r92528:
* remove @static
* return database result directly (no need for while())
* getAllPrefixesDb() -> getAllPrefixesDB()
2011-07-19 15:52:38 +00:00
Robin Pepermans
844e7c83e4 (bug 19838) API does not use interwiki cache.
Patch by Beau; modified to work with current code.
2011-07-19 12:30:18 +00:00
Daniel Friesen
1afb94ee5c Allow rows missing iw_trans or iw_local to be considered valid. 2011-04-23 03:10:57 +00:00
Daniel Friesen
99c94d0c7c Move the Interwiki class to includes/interwiki/ to make way for a more flexible Interwiki system. Do this first since svn doesn't support editing and moving a file in the same commit. 2011-04-23 02:35:21 +00:00
Renamed from includes/Interwiki.php (Browse further)