Commit graph

148 commits

Author SHA1 Message Date
sbailey 702ce215d0 Phase 3 migrate code for namespace column add to Linter table
* Migrates namespace info from the page tables page_namespace field
   to the new linter table field linter_namespace. This duplication
   of the namespace value was requested to greatly reduce the amount
   of database activity required by the linter search and reporting
   code.

 * This patch has been prepared as a dark launch patch enabled with
   config value LinterMigrateNamespaceStage and assumes that the
   Linter table has had the linter_namespace column added to it,
   and recording of the namespace field is already enabled and is
   populating the namespace column.

 * The migrate code now runnable from Linter/maintenance directory,
   using migrateNamespace.php, which will be deployed in a separate
   patch. The maintenance code creates an appropriate environment
   to call migrateNamespace( in Database.php.

Bug: T299612
Change-Id: I73cb80729d6a5a8716fe93164ad1e42e6958d672
2022-11-28 08:07:54 -08:00
James D. Forrester 1f119cd5b1 ApiQueryLinterStats: Change the 'ls' prefix to 'lntrst' to avoid conflict
In practice this isn't a breaking change as no-one has any params to
re-name in callers.

Bug: T319202
Change-Id: Ic925e258ad3c2e194fd9f04f8afd255a9aa99e45
2022-10-03 12:06:55 -04:00
Reedy 1c526b7443 Convert to HookHandler
Change-Id: Ib8ad9a58e781f7dad4b047d170a8f689802c4bad
2022-09-07 02:58:04 +01:00
Reedy 89d3f6152b Minor cleanup
Change-Id: I0b8abdbeaece73fe8759ee220b9a3aefce240e68
2022-09-07 02:48:18 +01:00
sbailey b358b20dca Second phase of T175177: Adds template and tag to RecordLintJob
Bug: T175177
Change-Id: I59be7cabb80ace98da3c7f6f36a0d3d4f6b17d23
2022-08-22 12:47:01 -07:00
Arlo Breault 0f46ed3dbc Get config from services, not globals
If908c4dc99c966cde2981f9a03be38a577406a4e introduced the
wgLinterWriteNamespaceColumnStage global but didn't add it to the
extension.json

Change-Id: I8ee5849f67ddfd894a25425582b59404eb52aef2
2022-08-03 13:01:42 -04:00
Arlo Breault f6607e8818 Stop using wfGetDB
This is pulled out of I59be7cabb80ace98da3c7f6f36a0d3d4f6b17d23

Change-Id: Iab6a47320995e9adb1666cd0bb728f516a2fde69
2022-08-02 14:40:30 -04:00
Kunal Mehta faf474e139 Only call getRequest()/getOutput() once in same function
Change-Id: I17b90a7d9f65dda563daa9cb09b40b965f3c49d3
2022-07-02 15:00:46 -07:00
Kunal Mehta be6c6a4eb0 Treat empty titlecategorysearch parameter same as not being present
The form will automatically add an empty &titlecategorysearch= parameter,
so treat the parameter being absent the same as empty string.

Bug: T311202
Change-Id: I377c55a59ce60f81532ae7effba60fbe29da609b
2022-07-02 14:57:43 -07:00
sbailey e306f5f681 Add namespace column and new index to Linter table - part 2
* Writes namespaceID to new "linter_namespace" field if global
   "wgLinterWriteNamespaceColumnStage" is present

Bug: T299612
Change-Id: If908c4dc99c966cde2981f9a03be38a577406a4e
2022-07-01 06:51:29 -07:00
DannyS712 c97d9e329d Start catch blocks on the same line as the preceding }
Change-Id: Idafe486275588e20846f7b3fd03adc97744d83b8
2022-06-23 00:27:00 +00:00
sbailey 79e825a466 Provide search by title prefix for any category of lint error
Bug: T185685
Change-Id: Ib667fcf5b2b1e752fde297b32b8bbe37dceabc5a
2022-06-16 13:27:14 -07:00
gerritbot 044ba77182 Fix usage of ApiBase::PARAM_* deprecated constants
The ones that are replaced with ParamValidator

Bug: T275455
Change-Id: I773e3ec3072bb25c455c080b8cd5870b3b27d23e
2022-04-04 00:37:17 +00:00
gerritbot e7dccae886 Replace deprecated ApiBase::PARAM_ with IntegerDef ones
The rest of ApiBase::PARAM_  will be done in separate patches

Bug: T275455
Change-Id: I491d4306611f53ed19aa92e119de7b386ef6bda4
2022-04-03 22:15:33 +02:00
sbailey ffcbb3af84 Add title interactive lookup to category based linter error search
* Just one of two or more patches enhancing linter error searching

Bug: T185685
Change-Id: Ic103d1ece079f5689f24425b8b7e78e0fb00449e
2022-03-28 10:07:27 -07:00
jenkins-bot d772f211dd Merge "Use HTMLTitleTextField on SpecialLintErrors" 2022-03-16 20:52:40 +00:00
sbailey 7309cc139c Linter allows specification of a page prefix to refine selection
* UI and functionality working, SQL injection risk is handled using
   the database wrapper function buildLike()

Bug: T185685
Change-Id: I1f630a83f01a1c93f29643e4fc8baf55391b758d
2022-03-10 08:48:19 -08:00
Subramanya Sastry b08fd17186 Hooks.php: Check for non-array $tags
Bug: T302918
Change-Id: I96fdbbc443025d9461dc168e58164004a0f8d7ed
2022-03-02 15:40:05 -06:00
sbailey 6925519cb5 Delete lint errors when blank page saved while changing content type
* Add "mw-blank" as another tag value that erases all lint errors
   for a page as a blank page cannot have any lint errors.

Bug: T280193
Change-Id: Iaad8ce75950588b2676de5dfb5f5221d64231f0e
2022-02-28 15:03:16 -08:00
Arlo Breault 285838961b Account for all lintable contentmodels after contentmodel change
Change-Id: I54495ec01d4fc3b29f1c924f86be3bcd2ed94977
2022-02-25 17:46:56 -05:00
sbailey 0e56c22277 Delete lint error records when content model changes from wikitext
* Determines if new content type is not wikitext and if so
   deletes all existing lint error records for that pageID.

Bug: T298343
Change-Id: I20fac9a0c901f3e7a5cc898566a4487fbe70798f
2022-02-25 13:22:10 -08:00
Umherirrender ba6b0db292 Use HTMLTitleTextField on SpecialLintErrors
This gives autocomplete on the special page

Change-Id: Ic29cf4c16886609c6689c66aff6ebc28a20879ea
2022-02-16 18:19:12 +00:00
Ammarpad daa6275a20 SpecialLintErrors: Make code more resilient to bad input
Use WebRequest::getText, which discards array values since
the `pagename` param requires string value.

Bug: T301360
Change-Id: Ifc23a7020e410603ac86b71d7aee2d28f06b9ab2
2022-02-15 18:49:40 -05:00
Alexander Vorwerk 8c7fa34662 Fix typo in patch file
Bug: T175177
Follow-Up: Iac22d99109bb1253f450a64254f50677e3cdefeb
Change-Id: I0c1ad29b67a732faa06add8faff4f70988b8613b
2022-02-07 20:47:53 +00:00
sbailey 56567da56f First phase of T175177 database alter table adds two fields
* Adds template and tag name fields to enable better search
   capability to the Linter extension

Bug: T175177
Change-Id: Iac22d99109bb1253f450a64254f50677e3cdefeb
2022-02-03 14:57:17 -08:00
sbailey 4544a9c7cc Add namespace column and new index to Linter table - part 1
* This patch contains the code needed to update the database with
   the addition Linter table column linter_namespace <int/null>
   and add an index with category and namespace for faster
   selection of linter records.

Bug: T299612
Change-Id: I05da381b9a74294b44d4aef968614277d601a176
2022-01-28 20:19:38 +00:00
jenkins-bot bd45eeda91 Merge "Replace deprecated JobQueueGroup::singleton()" 2022-01-23 21:39:36 +00:00
Umherirrender 354012f419 Replace deprecated JobQueueGroup::singleton()
Change-Id: Ib19314b8a8a4265daf67e31d50f1c61aec2edb8e
2022-01-21 17:22:20 +00:00
Subramanya Sastry 70ffca650e Drop 'inline-media-caption' lint requests
Bug: T297443
Bug: T299302
Change-Id: Id158f1fef8be06ddac733c71b7c1e26a58270955
2022-01-17 12:55:51 -06:00
Matěj Suchánek 1335b79a0b Pass HTML element attributes as an array
Html::openElement checks for this and logs a warning.
Html::closeElement does not, and this makes it return
</span class="error">.

Change-Id: I31c2809d2fd5421606fa877021d1636ac0eb4d26
2022-01-15 14:18:56 +01:00
Arlo Breault 8a797fd625 s/linter-pager-title/linter-pager-title-header/
Change-Id: I51e4ffa89954b0b6bf798562668dc4a95c00d9da
2022-01-11 23:24:52 +00:00
Arlo Breault ace2d5c17d s/linter-pager-template/linter-pager-template-header/
Change-Id: I658b258fe46bdeefbfc0b1d348e4ac4d9c423205
2022-01-11 12:41:56 -05:00
Arlo Breault 850ec4fa70 Add i18n for pager category
Follow up to I70fde2676ded6a112f7f2b07f94f6f4b616f0e39

Change-Id: I38647833938fb27793827649bc5c785dc3fd63ea
2022-01-11 12:21:19 -05:00
Arlo Breault fc8c39baa5 Fix lint error updating
The article id of the title is set to 0 when the page is deleted so,
although the lint job from the hook runs, it doesn't remove anything.

Reverts most of I06b821b65f65609ddac8ed4e7c662336082d8266

Bug: T298782
Bug: T170313
Change-Id: I2610b9b16d4032b0e18b3537cc9ed51bfdaff299
2022-01-10 16:24:00 -05:00
Arlo Breault 2218e87c05 Move outputting headers back to the top
Change-Id: I175d69c990de032686033ef909eec0b1865e795f
2022-01-10 15:21:20 -05:00
Arlo Breault f821fa7f47 Add a title for single page view
Follow up to I70fde2676ded6a112f7f2b07f94f6f4b616f0e39

Bug: T151362
Change-Id: I21b8b9085f13480075e0b572f38ec9a05a398f01
2022-01-10 15:16:04 -05:00
sbailey 31bc33b578 All lint errors for a single page was missing error detail label
Bug: T151362
Change-Id: I4eabb53cd133ee46e986a0d81a7002a286dfc0c4
2022-01-10 13:07:31 -06:00
sbailey 88aab3cd1e Linter: Display lint errors for a single page
* Added error message when namespace and/or pagename is not
  found or malformed which now displays a bold red message.

Bug: T151362
Change-Id: I70fde2676ded6a112f7f2b07f94f6f4b616f0e39
2022-01-07 12:45:55 -08:00
Alexander Vorwerk af53fbc23a Replace usages of deprecated wfWikiID()
The global function wfWikiID() is deprecated since 1.35 and it's usages
should be replaced with WikiMap::getCurrentWikiId().

Bug: T298059
Change-Id: I695c20bff266f869f740baf7f3e335b357546fb4
2021-12-21 01:54:47 +00:00
Arlo Breault 2fa7a30f14 Remove hardcoded list of categories with no parameters
Change-Id: Ic8b9ced613c873cada0a9909ed0d3799160504a1
2021-12-15 17:27:36 -05:00
Kunal Mehta 4f4b700fbd Fix off-by-one error around MAX_ACCURATE_COUNT
Currently we select 20 rows, and return the accurate count if it's less
than that, so up to 19 rows. Since we want to return an accurate count
if it's 20 rows or less, select one more row, 21, so we can differentiate
between only having 20 result rows or hitting the limit. This is the same
technique used in MediaWiki's Pager system.

Change-Id: I50fa96238eb4c7178414ee92c53799fd69520926
2021-08-06 13:05:29 -07:00
libraryupgrader 577a074b69 build: Updating composer dependencies
* mediawiki/mediawiki-codesniffer: 35.0.0 → 36.0.0
* php-parallel-lint/php-parallel-lint: 1.2.0 → 1.3.0

Change-Id: Ib1e2319da19d8c5589d1d41d3c0fe8f882792721
2021-05-05 06:09:03 +00:00
jenkins-bot 46aa330369 Merge "Make Linter category counts more accurate when counts are low" 2021-04-27 18:00:36 +00:00
sbailey 201b47e01d Make Linter category counts more accurate when counts are low
* The code now produces an accurate count if the number of
   errors for a category is below the threshold set by a
   public constant MAX_ACCURATE_COUNT (currently 20).
   The database record count limit was originally set to 1,
   to determine accurately, if there were actually 0 errors
   in a category as the estimate code would never report 0.
   If not 0, it would use the estimated count which does not
   produce an accurate count for any other number of errors.
   For low error counts this is annoying to editors and
   unnecessary. The additional CPU/disk activity to accurately
   check for low error counts is not significantly more than
   checking for 0 or 1, as checking for 0 likely requires
   a complete table scan which is probably expensive compared
   to a low count that early outs when it hits to record limit.

 * An improvement to consider is recording the accurate count in
   a separate tiny table, and maintaining an accurate count there
   which is used in preference to doing the select with row limit
   based on say a 30 second TTL, to prevent a stampede of requests
   from doing extraneous database operations.

 * Added unit test coverage for accurately counting low error
   conditions that are lower than the threshold and also verify
   that the estimate is inaccurate beyond the error count
   threshold.

Bug: T194872
Change-Id: I4f74cfe3bf9601baa0dc8fa6464a68030ac2bc4b
2021-04-27 10:38:24 -07:00
jenkins-bot 0e78237815 Merge "Fix bunch of PHPCS errors" 2021-04-17 12:19:30 +00:00
zoranzoki21 63e3150ab6 Fix bunch of PHPCS errors
Change-Id: I58b4f8b951d3bb7ce73ce2f14faf6a0f76963345
2021-04-17 13:42:01 +02:00
Kunal Mehta cb9329672a Update Legoktm's email address
Change-Id: Iceef061f4882b83661e5be6a931d85628b566f4c
2021-04-11 19:08:44 -07:00
Reedy c647f7c80e Fix PSR12.Properties.ConstantVisibility.NotFound
Bug: T253169
Change-Id: I9bd5f82ed62bb01b80b13507832935ac7a673804
2020-09-19 17:07:37 +00:00
Reedy 3387c848d0 Convert Linter to abstract schema
Bug: T259374
Change-Id: Ida866d45bc3daca6ed763df2b8c38d2b27c809aa
2020-08-22 23:33:46 +01:00
Bartosz Dziewoński fb58818a42 ApiQueryLintErrors: Allow querying by page title
Adding a new parameter 'lnttitle'.

The SQL queries should work the same as the ones when using the
existing parameter 'lntnamespace'.

Bug: T254930
Change-Id: Ic34617e2f56d1055388ea6e8a93ff641f0342240
2020-06-09 20:38:21 +02:00