Commit graph

195 commits

Author SHA1 Message Date
C. Scott Ananian fde916fff5 [DI] Use dependency injection for RecordLintJob
Change-Id: I3b8cd95e075af92c77a7dec4f12a0a81eab3ae4b
2024-04-04 21:42:10 -04:00
C. Scott Ananian c983a822e3 [DI] Use dependency injection for Hooks
Change-Id: I23f56b0a3df1ef206ec160453294349d2482435f
2024-04-04 18:43:13 -04:00
C. Scott Ananian d71a297781 [DI] Use dependency injection for ApiQueryLinterStats
Change-Id: I5f5d3a226a9f7b733a6f07200216a1192115b102
2024-04-04 18:43:13 -04:00
C. Scott Ananian d8970278d1 [DI] Use dependency injection for SpecialLintErrors
Change-Id: I211d70d5fb4a321cf302cc10f6e160480468a347
2024-04-04 18:43:10 -04:00
Arlo Breault 6304fc5e08 Stop exposing hidden categories in siteinfo
Suppresses them from ?action=query&meta=siteinfo

Bug: T334527
Change-Id: I325e78e438a8385948071d2b4ba8a8c4407d5fc4
2024-04-04 16:04:39 -04:00
Arlo Breault 8d49b68ba5 Move Database::updateStats to TotalsLookup
Database::updateStats moved to Database from RecordLintJob in
I2610b9b16d4032b0e18b3537cc9ed51bfdaff299 for reuse in Hooks but seems
better placed on TotalsLookup.

Change-Id: I600853e5cfc9e8abae9c6b07cee4c2adc37ef464
2024-04-02 17:12:24 -04:00
Arlo Breault 397b36e8e3 Don't include hidden category counts in page info
Bug: T337275
Bug: T334527
Change-Id: I6439df894c06fc5592422e72dac04150591f4033
2024-04-02 15:12:19 -04:00
Arlo Breault d6514cfa3b Fix invisible categories in ApiQueryLintErrors
Invisible categories are permitted as categories, just not part of the
default set.  'invisible-categories' is removed, since it never worked.

Bug: T360064
Bug: T334527
Change-Id: Ie6b7a6d83349cbd2899e78bc18cc1629d710c6f0
2024-04-01 21:43:24 -04:00
Umherirrender 91848725e7 Replace isset() with null check in HtmlTags
Found usage of isset() on expression self::$allowedHtmlTags that appears
to be always set. isset() should only be used to suppress errors. Check
whether the expression is null instead.
See https://www.mediawiki.org/wiki/Manual:Coding_conventions/PHP#isset

Change-Id: I21483aab05292cfb802ff6a5e63013ecc02f5c13
2024-04-01 13:47:54 +02:00
Tim Starling 4dd75df2e8 Fix index usage when searching for page titles
When searching for a specific page title, it's necessary to specify
page_namespace, not just linter_namespace, so that the relevant index in
the page table can be used.

Submitting the form with an empty namespace box led to a search for
namespace zero, because getCheck() returns true for an empty string.
It's not easy to search for a title part in all namespaces. So drop
that hidden feature and interpret a title part with a missing namespace
as being a search for namespace 0.

It's possible to search for a category with an empty title and zero or
more namespaces. Implement the namespace filter in this case using the
linter_namespace field. But ignore the namespace filter if there is no
category, since there is no index on linter_namespace alone.

Bug: T360865
Change-Id: I00934eaaf1a99e4098f177166b43069d33d9f137
2024-03-27 11:44:59 +11:00
Arlo Breault c90267575c Update lint category help links
Bug: T360793
Change-Id: I4a7b0d0200d2af5c6768db91d0883c7fc483d8dc
2024-03-22 14:14:38 -04:00
Umherirrender 9555edce6c build: Upgrade mediawiki/mediawiki-codesniffer to v43.0.0
Change-Id: I0a022343428d4b41d2c3c00a6f48eeb237c76fac
2024-03-11 20:44:04 +01:00
jenkins-bot c1cf86af3b Merge "Use OutputPage::setPageTitleMsg() instead of ::setPageTitle()" 2024-02-17 02:36:03 +00:00
Bartosz Dziewoński 8fe89c1c35 Use OutputPage::setPageTitleMsg() instead of ::setPageTitle()
Bug: T343994
Change-Id: Icf148a1a9b10e568f48d0ef478f781d243a9345a
2024-02-17 02:58:49 +01:00
libraryupgrader fa24bc16e1 build: Updating dependencies
composer:
* mediawiki/mediawiki-phan-config: 0.12.1 → 0.14.0

npm:
* grunt-banana-checker: 0.11.0 → 0.11.1

Change-Id: I7dbb4861df50848b803babe3dab10811adc3faae
2024-02-10 22:20:52 +00:00
Umherirrender 6c10926920 Use namespaced classes
This requires 1.42 for some new names

Done automatically via script

Change-Id: Idaad9e8d165a6bd202b96bbb657deb710cca4c54
2024-01-06 17:03:30 +01:00
Reedy 2276363a99 Cleanup SchemaHooks and SQL files
* Move MySQL files into subfolder
* Simplify onLoadExtensionSchemaUpdates hook by using variable for dbType
* Document what MW version patches were added

Bug: T353922
Change-Id: I4b87481163121047619d173675747feef4d8ede1
2023-12-22 02:13:52 +00:00
Bartosz Dziewoński 46e44bc694 Ignore "exact match" title when the title is not given
Restore a check removed in 3b3729ad4d.

Bug: T353860
Change-Id: I4722596433247a751d736ae35d9e3af9ac9d94cb
2023-12-21 11:35:17 +01:00
Isabelle Hurbain-Palatin 24155905cd Migrate Database.php to use QueryBuilders everywhere
Bug: T350977
Change-Id: I864c1e4880876b329ba0e8102e6c0f335a149491
2023-12-15 16:04:37 +01:00
jenkins-bot 91ff1af06b Merge "Replace addQuotes in ApiQueryLintErrors by expression builder" 2023-12-14 19:52:11 +00:00
Isabelle Hurbain-Palatin e3555039a0 Replace addQuotes in ApiQueryLintErrors by expression builder
Bug: T350977
Change-Id: I2ab0b83ed727a10861c4cfcf7d65142fc559e4af
2023-12-14 17:40:53 +01:00
jenkins-bot 846b2066de Merge "Update LintErrorPager to expression builder" 2023-12-14 15:07:14 +00:00
Isabelle Hurbain-Palatin 3b3729ad4d Update LintErrorPager to expression builder
Bug: T350977
Change-Id: Iee1726c93028219f9d360c5a485eb39f8c0a49ed
2023-12-14 14:43:41 +01:00
Umherirrender c730c0a9c8 Use ! condition instead of compare with false
Change-Id: I0f032169697b0227ade9644f754086f8bb4b9596
2023-12-12 16:38:17 +01:00
Reedy 76634af5b0 SpecialLintErrors: Minor cleanup
* Collapse a nested conditional
* Minor copy editing

Change-Id: I2875ec0dd9c44c896cad916feb8ed1f2bd514479
2023-11-26 21:34:26 +00:00
sbailey a3d0632c86 Update the namespace parameter name in the link in action=info pages
* url parameter 'namespace' changed to 'wpNamespaceRestrictions'

Bug: T231161
Change-Id: I904733ecb89fd855f7a338a6ef6d2a35a87c86d4
2023-11-07 19:04:45 +00:00
sbailey dd0836d232 Implement multiple namespace selection for Linter filters
* Using namespacesmultiselect type in HTMLForm element to
   provide multiple namespace selection criteria in reports.

 * New namespace URL encoding implemented which matches namespace
   parameters against active namespaces to ensure parameter
   security and validation.

 * Test system updated to use new URL namespace encoding

Bug: T231161
Change-Id: Ic3190cffe259aecdea429c10e35122eabdbe10d4
2023-10-26 10:39:57 -07:00
Arlo Breault e978607d56 Remove ParserMigration association
Bug: T333179
Change-Id: Ifc6676c3f873aeb1655f3cb1b549a5dd55bc4d85
2023-10-13 12:33:26 -04:00
gerritbot e181c2ef66 Replace some moved Title class uses, now MediaWiki\Title\Title
Bug: T321681
Change-Id: Id325b25e154b8b2bbd1d0b1d7b1c7830b40873f6
2023-08-19 12:37:07 +00:00
gerritbot f6f734ef42 Migrate ILB::getConnectionRef() calls to ILB::getConnection()
Deprecated since 1.39 (I6e7544763bd)

Bug: T343277
Change-Id: I6921060a38a1956c198f7a1316bed45c0eafa307
2023-08-04 13:03:06 +00:00
Umherirrender 7009ca8390 Use a maintenance database connection to call fieldExists
IndexPager::$mDb is documented as IDatabase, that interface does not
implement fieldExists. To use the correct static types get a
IMaintainableDatabase instead from the load balancer and call
fieldExists

Bug: T343495
Change-Id: I6a07ff2115de781e26f272126a72a9fbdef30223
2023-08-04 11:56:02 +02:00
Moh'd Khier Abualruz d543552be9 Allow registration of hidden lint rules
Adding support for categories non, allowing access to category page without showing it in listing, in categories in teh special page

Bug: T334527
Change-Id: I8397a24e85ca9f5a9ce6413dec5efa8c401a9960
2023-05-04 10:41:05 -07:00
gerritbot e1542b880a Update moved class WikiMap
See T321882. Moved in I60cf4b9ef02b9d5

Bug: T321681
Change-Id: I2d9e34bf9849c3ae05761f83031c806987b5991f
2023-04-25 09:54:08 +00:00
sbailey bef1042e69 Replace use of select or selectRow with QueryBuilder
* All database methods using old access methods converted to use
   queryBuilder except row counters

Bug: T312434
Change-Id: I8796adf63179c4505fbb76ab6fd71cf3775c9b89
2023-03-25 15:13:59 +00:00
sbailey 6aa4cdeba9 Linter Tag and Template search feature, UI and report code
* Tag and Template search is enabled using config variable
   'LinterUserInterfaceTagAndTemplateStage' and also checks for
   the linter table column 'linter_tag' to exist to protect the
   report code from error if the column is absent. As the linter
   table alter maintenance added both the linter_tag and
   linter_template at the same time, there is no reason to check
   both. The user interface code does not check for the field
   presence only the config variable.

 * This code depends on the recordLintJob code writing the tag
   and template data which is enabled by the config variable
   'LinterWriteTagAndTemplateColumnsStage' and also assumes the
   data migration maintenance script migrateTagTemplate.php has
   been run to populate linter error records created prior to
   the table alter and the write code being enabled.

Bug: T175177
Change-Id: I2f951dfcd34e3dc6ca17e8754cfaeba8baa3e835
2023-02-27 06:55:06 -08:00
sbailey 499a1c3796 Use new linter_namespace column and index in the Linter table
* This performance improvement patch uses the namespace from the
   new field 'linter_namespace' in the linter table instead of
   the 'page_namespace' in the page table. It checks for and
   requires the presence of the linter_namespace field in the
   linter table, as well as the config variable
   'LinterUseNamaspaceColumnStage' being set true.

 * If the linter_namespace field is present and aforementioned
   config variable is true, the code assumes that the config
   variable 'LinterWriteNamespaceColumnStage' is set true and
   recording the linter_namespace for new lint errors is
   active and the migrateNamespace.php migrate code has been
   run to migrate the page_namespace data into existing linter
   records that were created before the linter_namespace column
   existed and were left NULL during the table alter maintenance
   operation.

 * A follow on patch should remove the configuration variables and
   conditional code producing the final, refactored code dependent
   on the new namespace column index.

Bug: T299612
Change-Id: I4a1497d9e4dcd6a9a7befdaccf3e34c61694365d
2023-02-24 06:54:08 -08:00
Kunal Mehta eaf2d26db8 Remove API action=record-lint
The action=record-lint was a hack that allowed Parsoid/JS to send data
to MediaWiki to be stored in the linter database. Thankfully we no
longer need it in the glorious Parsoid/PHP world because it can write
directly to the database.

The API module, i18n messages and $wgLinterSubmitterWhitelist are all
removed.

Bug: T329992
Change-Id: Iba70e05a2e28f4ecd02101cff51993ebe65f19d0
2023-02-20 20:44:00 -05:00
sbailey d12bf639f6 Change linter maintenance scripts to use existing config varaibles
* Having separate config variables to enable the maintenance
   migrateNamespace and migrateTagTemplate scripts is duplicitous
   and should be shared with the write enable config variables.

Bug: T329342
Change-Id: I4cb453fc0678b065cb42a2ca59863da1ab9cdbe4
2023-02-14 09:43:54 -08:00
jenkins-bot f82904c185 Merge "Link to detailed Special:LintErrors from action=info" 2023-02-10 02:10:20 +00:00
jenkins-bot 107b89a901 Merge "Move LoadExtensionSchemaUpdatesHook handler to separate class" 2023-02-10 02:10:19 +00:00
sbailey 2768a70218 Fix migrate data error when params has excessively long strings
* The linter migrate code for linter_tag field and linter_template
   field are constrained by the database schema to 32 characters
   for the tag field and 255 characters for the template field.
   In some anomalous circumstances parsoid can report tag and or
   template fields in the linter_params object that exceed those
   character limits. This code truncates these excessively long
   strings to protect the database migrate update code from a
   length exceeded error.

Bug: T329113
Change-Id: I8af7c44759f172eae77d3519a6eac47110e9b1e7
2023-02-09 18:20:46 +00:00
sbailey 07046457f0 Fix write error when linter_params has excessively long strings
* The linter write code for linter_tag field and linter_template
   field are constrained by the database schema to 32 characters
   for the tag field and 255 characters for the template field.
   In some anomalous circumstances parsoid can report tag and or
   template fields in the linter_params object that exceed those
   character limits. This code truncates these anomalous strings
   to protect the database update code from a length exceeded
   error.

Bug: T328979
Change-Id: I057ae2e32a9e1a7735b5300409e5693e8db5c764
2023-02-08 10:40:12 -08:00
Kunal Mehta cb84f3a872 Link to detailed Special:LintErrors from action=info
action=info has a summary table of number of lint errors by category,
but we have richer information available via Special:LintErrors. If
there is a "Lint errors" section, provide a link below the table to
Special:LintErrors for the errors on this page.

Update ApiRecordLint for the new Hooks constructor and leave a FIXME
to eliminate the coupling.

Bug: T301374
Change-Id: Ic1fcf42b50d1392ac53201ceb256691133cf62ff
2023-02-06 20:41:45 -05:00
Kunal Mehta b5a7aaf7e0 Move LoadExtensionSchemaUpdatesHook handler to separate class
This hook is not allowed to have a service, so before we can add
services to the main Hooks class, it needs to be split out.

Change-Id: Ia7b4b8bf7c91ebb851c5de9f0f54f56b0993bf83
2023-02-06 20:36:45 -05:00
sbailey abbcc17511 Fix linter table linter_params definition to not be nullable
* update all schema files to correct linter_params being set nullable by accident in
   2020 during abstract definition update

 * include hook to provide 3rd party support, use $updater->modifyExtensionField(

Bug: T327806
Change-Id: I7fea08280cf2fa7956e5b300dc3365dc3561ca52
2023-01-26 12:47:36 -08:00
Umherirrender eb31c6c4dc Replace deprecated HTMLForm::addHeaderText
Bug: T325474
Change-Id: If1a4b14b6cec480f600065c913cb1f27260fbc5f
2022-12-27 12:48:42 +01:00
sbailey 350d677c5b Phase 3 of T175177: Migrate linter_params into new fields
* The migrate code is designed to perform a one-time update of
   linter_params JSON encoded template and tag information into
   the new discrete template and tag text fields for use as
   additional search criteria. The function can be restarted if
   it is interrupted.
 * It now uses configurable batching and sleep times between
   batches to allow the database to do other work and replication
   to occur without stressing infrastructure.
 * The migrate code is only called by test code and needs to be
   called one-time from a maintenance script.

Bug: T175177
Change-Id: Idc4ca88d4762bc7a3bcbc4e66c0f275562083867
2022-12-09 12:01:06 -08:00
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