Commit graph

57 commits

Author SHA1 Message Date
Aaron Schulz e9d466f398 Convert $wgMemc use to WANObjectCache
Bug: T160813
Change-Id: If298927d6b90e1b94e83485e723f13aa2bad0932
2020-03-13 21:07:36 +00:00
Thiemo Kreuz 955e0bb5bb Fix PHP 7.4 compatibility
The way this test is set up means the $this->params property is not
initialized. It is only initialized when execute() is, well, executed.
Since there is not really a guarantee this will always happen before
the failing method is called, I figured it's better to add this cheap
safety check in the production code.

Taggign with T233012 because I believe this extension is a gated one
for many other codebases.

Bug: T233012
Change-Id: Ie0060125cf4646d80f8c88eedd01551f66e3fb89
2020-03-13 20:59:58 +00:00
libraryupgrader 7025be47c1 build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 28.0.0 → 29.0.0
  The following sniffs are failing and were disabled:
  * MediaWiki.Commenting.FunctionComment.MissingDocumentationPrivate

npm:
* eslint-config-wikimedia: 0.12.0 → 0.15.0
* grunt-eslint: 21.0.0 → 22.0.0

Additional changes:
* Also sorted "composer fix" command to run phpcbf last.
* Removing manual reportUnusedDisableDirectives for eslint.

Change-Id: I351f0a333fd5f06e47f0748aa25cb3fff63cc67f
2020-01-15 09:17:22 +00:00
libraryupgrader 5986441375 build: Updating mediawiki/mediawiki-phan-config to 0.9.0
Don't pass booleans to BagOStuff::makeKey()

Change-Id: I87e42cee60d0adefd94f4bdc7fbbfabc65b7c93e
2019-12-21 23:44:50 -08:00
DannyS712 4c94bec18f Use Special:MyLanguage in API help links
Bug: T231269
Change-Id: I242981f4f7ecbd31fe4052daee8652089f4c6694
2019-08-27 06:44:46 +00:00
Thiemo Kreuz 81fd92685a Move Tidy functionality to TextTruncator
I argue that the code fixing unclosed HTML tags is – even if optional –
an integral part of the code that potentially breaks these HTML tags in
the first place. Notice how much code disappears in the ApiQueryExtracts
class.

Additionally, the new approach uses an interface instead of a static
function call that is impossible to mock and hard to test.

Change-Id: Ic1a65995f4dba11d060a8738d642905cbfc79271
2019-05-03 08:46:27 +02:00
jenkins-bot 8567e067f2 Merge "Extract unrelated static code from ExtractFormatter" 2019-05-02 21:03:58 +00:00
Thiemo Kreuz 8d3ff14a93 Consistently mention the @license in all files
Note how only two files mentioned the license before. For consistency
it should be either all or none. Both solutions would be possible. Even
*not* mentioning the license anywhere in these files would be fine from
a legal perspective, as long as the relevant file COPYING is still
there in the root folder of this extension.

The overly long "deed" text does not serve much of a purpose. It's not a
complete, legally relevant license text. It's hard to read as the fact
this is "GPL2+" is surprisingly hard to find. The @license tag solves
these problems, and is recognized by documentation generators.

Change-Id: I7844be0c5f4f3d7562156cd9f34fe466552a9c9d
2019-04-24 18:26:53 +02:00
Thiemo Kreuz a0d37fcb51 Extract unrelated static code from ExtractFormatter
This is a straightforward baseline patch that does nothing but moving
existing code around, without touching it. I'm not even trying to
remove the "static" keyword. The actual refactoring will be done in
the next patch. I hope with this the changes I do in the refactoring
become more visible and much easier to review.

Change-Id: Idba859ec0c24f3622ea8fb8d7a9b11843d1e3827
2019-03-21 12:38:13 +00:00
Thiemo Kreuz 6a082f1764 Inline nested callback functions
This gets rid of code that is reported as being unused, even if it is
used.

This also simplifies the regular expression a little bit. The .
automatically ends at the end of the line when the mode /s is *not* set,
which it isn't. The /m mode is not needed then because there is no ^ or
$ any more in the regular expression.

Note this code is sufficentily covered by a test (one I wrote just a
few days ago).

Change-Id: I8eb57e308bb2b281e0e72499b4d46f93a4dfa5f4
2019-03-19 18:50:03 +01:00
Max Semenik b9a21cc865 Better way to detect if Tidy is on
Change-Id: Ie9723ef50d9a472605da92faabced3d852ec9387
2019-03-17 18:19:34 -07:00
Max Semenik 1bdb8410ac Get rid of useless ApiQueryExtracts->parserOptions
Change-Id: I084116998ba758c90f14a370c24d098cbd6cdc28
2019-03-17 18:02:11 -07:00
Max Semenik 0215eae3aa Make ExtractFormatter not depend on configuration
Change-Id: I4e9a0947bf50d062ea28004bde30d2e8b18788a4
2019-03-17 18:02:09 -07:00
Max Semenik 1017e3ab72 Remove compat with old MW
Change-Id: Ic5c44414b49e434a8c46ba3dca01eebe9e0f1d3c
2019-03-17 13:47:38 -07:00
Umherirrender 832d0ff745 Remove use of deprecated UsageException
Deprecated since 1.29, extension required 1.29

Change-Id: I2f550f0b94571afc289af616645b822d63fea4d3
2018-08-21 22:23:49 +02:00
Umherirrender add3e27461 User constructor does not take an argument
User object without argument is the anon default

Change-Id: I2c47c4865386d59f14eb6390b3e12fb9c5198ccd
2018-08-06 23:12:26 +02:00
Thiemo Kreuz 60cd40b975 Remove not needed count() and "return true" from hook handlers
This patch fixes two styls issues I could not separate:

* Hook handler functions do not need to return true. This is the default
anyway, and meaningless.

* Counting is possibly expensive and not needed when all we need to know
is if an array is empty or not.

Change-Id: I460776c981638806a606d9bf88fc8579d6da8c0e
2018-06-28 20:45:20 +02:00
Umherirrender 618aef40a0 Remove @return from __construct
Change-Id: I2000dc076c869620533368431f6c55241fbc92e8
2018-04-05 12:18:59 +02:00
jdlrobson d69b35f4bc Adjust expectations for API consumers when using the TextExtracts API
Bug: T170617
Change-Id: I53e08db40e5319019c842869f992bac32b1dac97
2018-03-20 09:42:10 -07:00
Gergő Tisza be8a5d6ea3
Bump cache version due to 'unwrap' ParserOutput option
Bug: T186927
Change-Id: I078f71d99f3179af5f4f85892472932eb5635fe1
2018-02-09 14:15:30 -08:00
Brad Jorsch 63a1d82b4e Use 'unwrap' post-cache transform instead of setWrapOutputClass( false ), when available
To reduce parser cache fragmentation, core is deprecating
$parserOptions->setWrapOutputClass( false ) in favor of
$parserOutput->getText( [ 'unwrap' => true ] );

Change-Id: Ibc013a41f4a463f4014fbbce7ce27f8690161728
2017-12-22 13:43:44 -05:00
Pppery f6fd9273c5 Re-enable MediaWiki.Commenting.FunctionComment.MissingDocumentationPublic sniff
Bug: T170580
Change-Id: I0a0055f1de57f15a45c21e2f51ed275a2b249440
2017-11-30 15:31:55 -05:00
Pppery 009765a04c Re-enable MediaWiki.Commenting.FunctionComment.MissingParamComment sniff
Also renames $action to $name in APIQueryExtracts.php, because trying to
document the parameter revealed that "action" doesn't match the use of
the parameter.

Bug: T170580
Change-Id: I1b7f3f0e17b118ea9bcfd28c69321aa692aad4e3
2017-11-29 21:56:29 -05:00
Pppery 624da67ec6 Re-enable MediaWiki.NamingConventions.LowerCamelFunctionsName.FunctionName sniff
Change-Id: I420fd3640772f4127ca15603af00fd30aecc28c0
2017-11-29 20:27:15 -05:00
Umherirrender 01376c8e05 Improve some parameter docs
Change-Id: Ie4326ecb517e5c7381b946b45bc108f8889fd4b2
2017-10-07 11:24:02 +02:00
jenkins-bot 237ac977f7 Merge "Hygiene: Remove deprecation and unused import" 2017-08-03 21:36:11 +00:00
Piotr Miazga 91bbe7b10a Hygiene: Remove deprecation and unused import
Changes:
 - ApiBase::setWarning() is deprecated, use addWarning() instead
 - ParserCache::singleton() is deprecated, use MediaWikiServices instead
 - Exception import is not used, drop it
 - added MediaWiki 1.29 as a requirement

Bug: T166714
Change-Id: Ib81e5acbb28e1f803c7a792b9f990f2aa6d57521
2017-08-02 16:32:13 +02:00
Piotr Miazga fcda3b365b When APIParse fails log the warning and return null
API Parse request fails from time to time which causes PHP notice
error. In order to understand whats going on lets introduce error
logging as temporary solution. This will give us possibility to
find the error instead of silently returning null. For now we will
keep old behaviour and return null in that case explictly. This will
avoid future php notice errors.

Changes:
 - when API parse request fails log the error and return null

Bug: T169017
Change-Id: Ib908821b76a1e8b59235643854752c4f5910a274
2017-08-02 15:12:20 +02:00
Max Semenik 753fc03c10 Don't call ParserOuptut::setTOCEnabled()
It's not really needed. Add tests verifying that.

Bug: T168040
Change-Id: I49cf58d92620ad53dd833bc8ce0d2443a00b48e4
2017-07-24 17:55:06 -07:00
jenkins-bot d72b09724e Merge "Remove deprecated $wgUseTidy in favour of $wgTidyConfig" 2017-07-07 22:49:21 +00:00
Baha 97a25e2183 Return empty extract for articles in File namespace
Bug: T114418
Change-Id: I2dfccbcf27284ecfdd0669b004151824ece79b73
2017-07-07 15:32:27 -07:00
Piotr Miazga c13dae2788 Remove deprecated $wgUseTidy in favour of $wgTidyConfig
Bug: T168671
Change-Id: I27f5bee2448797c3a5a8cb886cee0e518b199ebe
2017-07-07 21:39:30 +00:00
jenkins-bot 698a8a8066 Merge "Send sectionpreview parameter on TextExtract parse" 2017-06-29 00:25:10 +00:00
jdlrobson 27baa2d0d9 Send sectionpreview parameter on TextExtract parse
This will invoke special handling for unbalanced templates

Bug: T168743
Change-Id: I3fe1bd5b56a049f57fad478f1358dd8496503b41
2017-06-28 08:55:00 -07:00
Kunal Mehta 43f3539a7c Set an expiry for memcache entries
Use the same expiry as the parser cache since this is a derivative of
the parser cache.

And avoid wfMemcKey while we're at it.

Change-Id: Ieba084aff4b8beb180da01d9cc4b8a2857569171
2017-06-11 20:12:55 +00:00
Baha 182304dc6d API: Limit maximum number of characters when exchars is passed.
Set the limit to 1200 characters.

Bug: T156467
Change-Id: I4e53b26a3f57f5f5cf7acbd3702c8bc4541a5eb5
2017-05-24 18:04:20 -04:00
jenkins-bot a803755b3e Merge "Add phpcs and make pass" 2017-05-24 13:17:49 +00:00
Umherirrender 93be5e75f6 Add phpcs and make pass
Change-Id: I2f95b3dfa260d955a5a420d0bf3c914382c09746
2017-05-19 18:39:27 +02:00
Baha 6bfe60508a Increase default API limit from 1 to 20
Bug: T153707
Change-Id: I6ba3adb7c680e1a60461cd3903cbf8640721ea02
2017-05-19 09:39:13 -04:00
jenkins-bot 7c81c6ec9f Merge "Suppress parser output wrapper div" 2017-05-16 14:49:40 +00:00
Brad Jorsch 42e87ac3b6 Suppress parser output wrapper div
It confuses the code that munges the HTML to produce an extract.

By itself this won't fix the bug, but together with a core change to
avoid polluting the parser cache such as I5be25c6d it should work.

Bug: T165161
Change-Id: Ia1b654bf659958c04d7e370d4686cf17f615b591
2017-05-16 14:47:49 +00:00
Kunal Mehta aef292b82b API: Change memcache key to clear cache
And add a CACHE_VERSION constant to make this easy in the future.

Bug: T165161
Change-Id: I362f44cf3d680d073e7e6dc6eec95ec5eec15684
2017-05-12 11:19:51 -07:00
Brad Jorsch 739e02f2d2 Update for API error i18n
See Iae0e2ce3.

Change-Id: Ibe7cb02d551ac2f85ee01edbf2b40a966ed42b74
2016-12-08 10:08:25 -05:00
Max Semenik ec44826b7a Remove use of a removed function
Change-Id: Iac8bec0a0a2625e40c5c70a715ffb4784224f164
2016-09-22 18:58:55 -07:00
Max Semenik 264f65215b Minor fixes
* Annotations
* Deprecated functions
* Namespace tests

Change-Id: I521f6af6074a454cec5322ab4cd46db08350c2c3
2016-09-22 18:51:12 -07:00
Max Semenik 754c9e4f19 CodeSniffer fixes
Change-Id: I8bdcd2250bd3163fe40ce4685eb04bffe53afdca
2016-09-22 18:38:27 -07:00
Brad Jorsch 90a025b839 Remove pre-1.25 API compatibility code
Since this extension uses extension.json, it already requires 1.25+ so
no need to keep the old code around.

Change-Id: Id9e8fb026b26bb4db34fb22bd631205ce6f7072b
2016-09-20 15:23:35 -04:00
Fomafix 579fae4c38 API: Remove unused parameter exvariant
All API calls supports the generic parameter variant.
With I8a31dfd3cf2a3e8f768907084d26a77f198ccbe3 in core this parameter
is documented and generates no warning anymore.

Bug: T117529
Change-Id: Ic7e6f1df99c67ad4132c22503d99345611af271a
2016-09-19 18:00:19 +00:00
Kunal Mehta 0664ddbf94 Add missing use statement
Removed another unused one, and cleaned up the doc block.

Bug: T121283
Change-Id: I1a8b9920152e6d52ffb59de385fcc29c92f33c92
2015-12-11 15:11:43 -08:00
mhutti1 80703452ed Converted TextExtracts to new extension registration system
Moved most of TextExtracts.php to the new extension.json
and added method for backward compatable implementation
of the extension if still called though the php file. Moved
unit test hook to Hooks.php and deleted old il8n.php.

Bug: T87979
Change-Id: I3d26bd931ad2941268b94474f3e6327282da24ec
2015-12-10 22:59:49 +01:00