Commit graph

34 commits

Author SHA1 Message Date
Umherirrender
58e26c3ef6 Make $fname mandatory on private functions
For a private function the $fname does not need to be optional,
it should be easy to pass it always.

Change-Id: Ifcddcd2479ae6f8bbf68210441c61ee7a45e1489
2024-09-19 20:09:20 +02:00
Umherirrender
c8ec25a961 maintenance: Add missing documentation to class properties
Add doc-typehints to class properties found by the PropertyDocumentation
sniff to improve the documentation.

Once the sniff is enabled it avoids that new code is missing type
declarations. This is focused on documentation and does not change code.

Change-Id: I7dec01892a987a87b1b79374a1c28f97d055e8fa
2024-09-13 19:29:24 +02:00
Dreamy Jazz
e7393b3cc7 Exclude boilerplate maintenance code from code coverage reports
Why:
* Maintenance scripts in core have bolierplate code that is
  added before and after the class to allow directly running
  the maintenance script.
* Running the maintenance script directly has been deprecated
  since 1.40, so this boilerplate code is only to support a now
  deprecated method of running maintenance scripts.
* This code cannot also be marked as covered, due to PHPUnit
  not recognising code coverage for files.
* Therefore, it is best to ignore this boilerplate code in code
  coverage reports as it cannot be marked as covered and also
  is for deprecated code.

What:
* Wrap the boilerplate code (requiring Maintenance.php and then
  later defining the maintenance script class and running if the
  maintenance script was called directly) with @codeCoverageIgnore
  comments.
* Some files use a different boilerplate code, however, these
  should also be marked as ignored for coverage for the same
  reason that coverage is not properly reported for files.

Bug: T371167
Change-Id: I32f5c6362dfb354149a48ce9c28da9a7fc494f7c
2024-08-27 13:22:29 +01:00
Reedy
e2f9bea62b Fix casing of Mediawiki to MediaWiki
Change-Id: I0f266a034a99255b27fd96d82335d6e710a61f20
2024-01-29 17:15:04 +00:00
Amir Sarabadani
69cabb628c maintenance: Migrate to expression builders
This was somehow left out

Bug: T210206
Change-Id: I70851b5b99fa865dbfd629caf2c1866c85418350
2024-01-17 20:27:08 +01:00
Daimona Eaytoy
6ddbd53eda Remove redundant empty() constructs (3)
empty() only makes sense when the expression it checks is possibly
undefined, otherwise it's equivalent to a truthiness check with the
additional downside of suppressing errors when it's not wanted.

Replace it with simple truthiness checks, using strict comparison when
that seems to help with polymorphic variables.

These were caught by a bespoke phan plugin.

Change-Id: Ide262162553d2da7e5388d05e8731529c44591c1
2023-09-08 23:37:23 +02:00
Amir Sarabadani
15a278189f Reorg: Move MWTimestamp to MediaWiki\Utils
Bug: T321882
Change-Id: I48c10343295c4eb3d9ef8037343b0070e928f040
2023-08-19 05:53:40 +02:00
Amir Sarabadani
310333906a maintenance: Switch simple calls of Database::select to SQB
Done semi-automatically via a php parser written on top of ANTLR4.

Bug: T311866
Change-Id: I33f5b6703c0aa9c80c907a21c2a770e30642edd3
2023-07-19 17:42:23 +02:00
thiemowmde
f3e714c782 Use more narrow IReadableDatabase in BatchRowIterator
It's an iterator. It reads. This causes a nice chain-reaction where a
lot more code (a lot in extensions) can be updated the same way.

Note this doesn't affect the stability of this code because all old
callers will continue to work with the more narrow type.

Change-Id: Ib7e0287a480af641ce2c19e856c1fb90498f3eb8
2023-05-19 15:02:50 +02:00
thiemowmde
d923d7aa8d Use more narrow database interfaces in maintenance scripts
This makes this code easier to read and to maintain because it's more
obvious why a DB connection is passed. For now this patrch focusses
exclusively on private methods.

Change-Id: Id60dc90b124f4cae1dfbede990f45e3c69491a25
2023-02-27 15:58:37 +00:00
jenkins-bot
9f2e36641c Merge "Reorg: Move category-related classes from includes/ to Category/" 2023-02-09 23:20:40 +00:00
Amir Sarabadani
c8116223b4 Reorg: Move category-related classes from includes/ to Category/
Bug: T321882
Change-Id: I0b86acfdeaa3a2a0a14b7763fd088122820bafdc
2023-02-09 20:18:54 +01:00
Umherirrender
ed169d991e Remove unused arguments to private functions
Found by phan dead detection

Change-Id: I93379b7b9a733206d0e53add04fcdb9478c58755
2023-02-08 19:00:47 +00:00
Aryeh Gregor
79fc95d39c Use MainConfigNames instead of string literals, #5
This should be the last of the usages in core, although I'm sure a few
are hiding somehow.

Change-Id: I7bf0b24bf23d3efb4c56a891830bbfe67945e899
2022-04-27 18:46:29 +03:00
Umherirrender
d30b3d8926 Fix various documentation related to scalar types
Found by phan strict checks

Change-Id: If41d16b473baddd92cc4261cdc2bfbe65fedcb19
2022-03-09 20:49:51 +00:00
Umherirrender
95852cb22b Explicit cast TS_UNIX to int for arithmetic operations and int args
When the called function has a doc of int, it should be cast to be
explicit here.
Also cast for arithmetic operations to be explicit about the number

Change-Id: I905b78dfb66e66443e0e3203488bab5b548db543
2022-01-11 20:13:13 +01:00
Ammarpad
f7f5e72ba9 Use rc_new_name_timestamp index name unconditionally
Bug: T276292
Change-Id: I93f8ce51dd1c2406d88015fcf6be9b044f424880
2021-05-05 22:40:51 +01:00
Amir Sarabadani
1053405664 Rename new_name_timestamp on recentchanges to rc_new_name_timestamp
To make it have a uniform prefix for index and column names

Bug: T270033
Change-Id: I8eb600416913092bd5aeb70389bba6e8a54d1d57
2021-03-01 19:00:52 +00:00
jenkins-bot
51c80cffae Merge "don't pass null page id to page related queries for category change rdf dumps" 2020-09-09 19:28:44 +00:00
Ariel T. Glenn
b4c32cf38d don't pass null page id to page related queries for category change rdf dumps
Bug: T260232
Change-Id: Ia9b254cf1d561b10de7e9aae9765cb21ea83325f
2020-09-07 16:48:15 +03:00
Reedy
6c1f642959 maintenance: Make use of BatchRowIterator::setCaller
Bug: T261014
Change-Id: I20858c486e79753a1aa62fa8cbf22afc4f59dba3
2020-09-05 12:55:11 +00:00
David Causse
01eada74ef Write category parent hierarchy when handling categorization
Since we do brute force update (DELETE ALL+INSERT ALL) of the parent
categories we need to always write the parent category hierarchy.

Bug: T246568
Change-Id: Id9c3282a97bf3fc3d5355cc08a0c9d833c72c9b2
2020-07-31 12:14:13 +02:00
Reedy
f648dd236e Fix PSR12.Properties.ConstantVisibility.NotFound in maintenance/
Change-Id: Ib0f081f7b278fdd3f4083fc5020bcac97f6015b4
2020-05-09 23:54:58 +00:00
Brad Jorsch
b26248235b Add string casts when using array_keys() with SQL query conditions
Until I70473280, integer literals were always quoted as strings, because
the databases we support all have no problem with casting
string-literals for comparisons and such.

But it turned out that gave MySQL/MariaDB's planner problems in some
queries, so we changed it to not quote actual PHP integers.

But then we run into the fact that PHP associative arrays don't preserve
the types of keys, it converts integer-like strings into actual
integers. And when those are passed to the DB unquoted for comparison
with a string-typed column, MySQL/MariaDB screws up the comparison while
PostgreSQL simply throws an error. Sigh.

This patch adds string casting to direct uses of array_keys() to supply
values for such query conditions. It doesn't change uses where the field
being compared is a numeric field.

If anyone knows of a good way to find indirect uses of array_keys() for
passing as $conds to IDatabase methods, please do so!

Change-Id: Ie72ee33437d492904e1495b3f4ebb1fcf0118f49
2019-12-16 16:05:18 -05:00
Umherirrender
337ecb0514 Add missing @param and @return to documentation
Change-Id: Ibc5849cc8ea7e7c4eb30ded9c1cfa5f52187c377
2019-11-10 22:12:58 +00:00
Umherirrender
8f666cabcd Use Maintenance::getConfig in some maintenance scripts
This avoid global state

Change-Id: Id67d07597159a0bd2721a381775230c3cd1d5509
2019-09-01 20:55:08 +02:00
Daimona Eaytoy
e2e543f7c2 Unsuppress more phan issues (part 5)
Bug: T231636
Depends-On: I6e5fba7bd273219b1206559420b5bdb78734aa84
Change-Id: I50377746f01749b058c39fd8229f9d566224cc43
2019-09-01 09:48:31 +00:00
Stanislav Malyshev
af8e2632ad Fix categories detele SPARQL clause
Bug: T228348
Change-Id: I87b3b5831e31dc619b5eefb7854d3223acd605fc
2019-08-27 16:19:31 -07:00
Thiemo Kreuz
cc329a5b06 Update PHPDoc types in several maintenance scripts and related
There is like a billion of these in our core codebase. I would love to
update them all. But I don't have the time, at least not to do them all
at once.

TL;DR: It's an improvement. :-)

Change-Id: I0a9c51bdcf0f261f971586bb8703f418324b0f98
2019-03-07 17:54:26 +00:00
Aaron Schulz
cb15755e92 Normalize use of "INNER JOIN" to "JOIN" in database queries
The ANSI SQL default join type is INNER and this might save
some line breaks here and there.

Change-Id: Ibd39976f46ca3f9b71190d3b60b76ca085787a00
2019-03-06 09:17:30 -08:00
Stanislav Malyshev
ba5bce123b Fix handling categorization changes
Previously, we handled categorization changes using wrong assumptions
- that rc_cur_id refers to the parent category. Instead, it refers to
the child page.

Change-Id: I40e886c3548ccca57db7ab83f14ec4dcd804cf2f
Bug: T201216
2018-08-14 00:40:08 +00:00
Stanislav Malyshev
6aec8dd6fb Use separate insert/delete statements to work around Blazegraph bug
Bug https://github.com/blazegraph/database/issues/100 happens on DELETE/INSERT
but not on separate delete and insert, try to work around it

Change-Id: Iba6a98dde6f4bea9051cd6dee91fb19db5eca10e
Bug: T201217
2018-08-13 23:24:52 +00:00
daniel
ed5ab7c856 Use array_merge to merge indexed arrays in categoryChangesAsRdf.php.
Bug: T198356
Change-Id: Ic29568ecfc26da7e6d8c9a875232bfa4e0f9f380
2018-07-02 17:43:41 +02:00
Stanislav Malyshev
bc9e1a086e Create update SPARQL for category changes
This script creates SPARQL UPDATE statements for changes in a given time
period. These statements can be applied to an existing database to
update it.

See tests for examples of how the statements look like.

Bug: T173774
Change-Id: I9867ad566c0619b55a48a011bd3c55321b1bfcff
2018-04-20 16:40:35 -07:00