Commit graph

85 commits

Author SHA1 Message Date
Umherirrender
6ea3d6ac2c Add explicit casts between scalar types
php internal functions like floor/round/ceil documented to return
float, most cases the result is used as int, added casts

Found by phan strict checks

Change-Id: I92daeb0f7be8a0566fd9258f66ed3aced9a7b792
2022-03-08 16:59:01 +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
Umherirrender
a470224257 Improve nullable documentation in special page class about args
Change documentation to null or false where the type is allowed

Change-Id: Id8fd2b94a986e85af1c5aa6b4a8de2a9b3081b9e
2021-10-22 06:14:21 +00:00
Reedy
bc224d0498 QueryPage: s/Sometime/Sometimes/
Change-Id: Ibdc16044fabfe9fe3677985d10b2dbe1ac2e7c84
2021-09-27 23:43:14 +01:00
Umherirrender
44fd53fee3 Using @return never documentation on always-throw-function
This helps phan to detect unreachable code and also impossible types
after the functions.
It helps phan to avoid false positives for array keys
when the keys are checked before

Bug: T240141
Change-Id: I895f70e82b3053a46cd44135b15437e6f82a07b2
2021-09-07 17:29:03 +02:00
Umherirrender
4d42b5e86e docs: Change wording master to primary in comments and log text
Bug: T254646
Change-Id: I5379dc79be60c99f0a30f74e5d624f81fe6f921b
2021-09-01 23:04:40 +02:00
TChin
00f48f2151 Turn hashes into comments
Standardized double-slash comments

Bug: T285484
Change-Id: I5dd8a0ecd78063751ae6d009359cdc449e1b2fb8
2021-06-24 14:45:10 -04:00
James D. Forrester
df5eb22f83 Replace uses of DB_MASTER with DB_PRIMARY
Just an auto-replace from codesniffer for now.

Change-Id: I5240dc9ac5929d291b0ef1c743ea2bfd3f428266
2021-04-29 09:24:31 -07:00
jenkins-bot
3f131cb38e Merge "Delete cached data of non-cached querypages with updateSpecialPages.php" 2021-04-22 01:23:44 +00:00
Tim Starling
aa94551c2b Make SpecialFileDuplicateSearch not be a QueryPage
Since 2011, FileDuplicateSearch has been especially awkward as a
QueryPage subclass. The only thing of value in the parent was
construction of <ol></ol> tags, but that's not enough to justify it.
getQueryInfo() was unused  -- my motivation is to not have to maintain
it. A LoadBalancer was injected but was unused.

Change-Id: I2f0c18913260ee74ef266352bb93cfbdc1143d85
2021-04-08 14:39:01 +10:00
Ammarpad
798593cc73 QueryPage: Remove useless check
Change-Id: I676b26633103c10b1aa20646cbbe46e6450cc7cf
2021-03-29 17:57:01 +01:00
Umherirrender
c11b87822f Delete cached data of non-cached querypages with updateSpecialPages.php
If a special page is no longer expensive (by code or by config like
DisableQueryPages) the data should not longer stored in the database,
because always fresh data are shown and never the cached data

This does not delete on disabled query pages, because the data still
visible on the page.
This only affectes query pages and not very special pages like
ActiveUsers

Bug: T174513
Change-Id: Ia9015cb7bc0ab7b1a3d96d1b481c31b3e6c39657
2021-03-10 20:28:09 +01:00
Umherirrender
6ca2883ce8 Improve doc about object to be stdClass in QueryPage::formatResult
Change-Id: Ib1fadd74f2f3223ea8a9343d1524533f00b991df
2020-11-15 13:50:59 +01:00
Umherirrender
4829c65848 Inject LinkBatchFactory into QueryPage and use it
The LinkBatchFactory service is only used in one method call in the
QueryPage class, so make it optional and provide it
when needed with a setter

Bug: T259960
Change-Id: Iee446b1defc9a4f116dc264b012ab972f89d95fc
2020-11-02 14:51:56 +01:00
jenkins-bot
5d3728814b Merge "Inject DBLoadBalancer into abstract QueryPage" 2020-11-02 12:34:49 +00:00
Umherirrender
15442f328a Inject DBLoadBalancer into abstract QueryPage
Every QueryPage needs a database to work
Inject the new service on special pages with already using services.

Bug: T259960
Change-Id: I96d91993b70052484c1a6a918a1e2ccc91e39ae7
2020-11-02 00:41:32 +01:00
Umherirrender
a6ab0ac818 Inject ContentLanguage into SpecialPage and use it
The ContentLanguage is already present in the factory,
pass it to the created object and make every object aware of the
content language along with the user language for easier access

Bug: T259960
Change-Id: I32bbacbb45d0844ca99f0c5ee168be6a26e8974a
2020-11-02 00:09:41 +01:00
Umherirrender
42507e73cd Use LinkBatchFactory in pagers, special pages and actions
Change-Id: I299900316c8d3129844a047228cd1c15ae7dff63
2020-09-06 01:26:09 +02:00
jenkins-bot
39705eb311 Merge "Replace "@stable for subclassing" with "@stable to extend"" 2020-07-13 09:31:38 +00:00
daniel
3c50afa46b Replace "@stable for subclassing" with "@stable to extend"
For compliance with the new version of the table interface policy
(T255803).

This patch was created by an automated search & replace operation
on the includes/ directory.

Bug: T257789
Change-Id: Ie32c1b11b3d16ddfc0c83a757327d449ff80b2e4
2020-07-13 11:00:30 +02:00
daniel
f7116bb3a2 Replace "@stable for overriding" with "@stable to override"
For compliance with the new version of the table interface policy
(T255803).

This patch was created by an automated search & replace operation
on the includes/ directory.

Bug: T257789
Change-Id: I5ffbb91882ecce2019ab644839eab5e8fb8a1c5f
2020-07-13 10:57:12 +02:00
daniel
24d34d32e3 Mark special page base classes as stable for subclassing
Bug: T247862
Change-Id: I44d9dddd99c0106a30058cd80377a65f9b1694a9
2020-07-10 15:52:19 +02:00
Edward Chernenko
e479b9ecf1 Shorter code in QueryPage::execute()
This eliminates code duplication:
SpecialPage::checkPermissions() does exactly the same thing.

Change-Id: I9ae84582b92ae1231f96df7ad453ffbe1f00614f
2020-06-27 09:29:51 +00:00
Tim Starling
68c433bd23 Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.

General principles:
* Use DI if it is already used. We're not changing the way state is
  managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
  is a service, it's a more generic interface, it is the only
  thing that provides isRegistered() which is needed in some cases,
  and a HookRunner can be efficiently constructed from it
  (confirmed by benchmark). Because HookContainer is needed
  for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
  SpecialPage and ApiBase have getHookContainer() and getHookRunner()
  methods in the base class, and classes that extend that base class
  are not expected to know or care where the base class gets its
  HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
  getHookRunner() methods, getting them from the global service
  container. The point of this is to ease migration to DI by ensuring
  that call sites ask their local friendly base class rather than
  getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
  methods did not seem warranted, there is a private HookRunner property
  which is accessed directly. Very rarely (two cases), there is a
  protected property, for consistency with code that conventionally
  assumes protected=private, but in cases where the class might actually
  be overridden, a protected accessor is preferred over a protected
  property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
  global code. In a few cases it was used for objects with broken
  construction schemes, out of horror or laziness.

Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore

Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router

setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine

Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-05-30 14:23:28 +00:00
Reedy
51d3ade7d4 Fix more Squiz.Scope.MethodScope.Missing
Member variables in HistoryBlobStub have been marked protected

SpecialPage::setListed() and listed() have been deprecated

CategoryPage::getCategoryViewerClass() and setCategoryViewerClass()
have been deprecated

Change-Id: Id1f530c2c8ec1171615f726dc7446431ee7ca8fe
2020-05-18 20:35:38 +00:00
DannyS712
3d8e6c6448 Replace WebRequest::getLimitOffset with ::getLimitOffsetForUser
Bug: T243805
Change-Id: I8b084e447e12a330bdce2bff18fd7c756ac5f698
2020-02-19 00:50:21 +00:00
James D. Forrester
0958a0bce4 Coding style: Auto-fix MediaWiki.Usage.IsNull.IsNull
Change-Id: I90cfe8366c0245c9c67e598d17800684897a4e27
2020-01-10 14:17:13 -08:00
James D. Forrester
4f2d1efdda Coding style: Auto-fix MediaWiki.Classes.UnsortedUseStatements.UnsortedUse
Change-Id: I94a0ae83c65e8ee419bbd1ae1e86ab21ed4d8210
2020-01-10 09:32:25 -08:00
Umherirrender
9a8a33bd0f Add a run mode to $wgDisableQueryPageUpdate
The run mode is used to show a different message on the special page,
instead of the current one "Updates for this page are currently
disabled. Data here will not presently be refreshed." even the data gets
updated with a different cron job.

Bug: T78711
Change-Id: Ib63d16bfea477dec43323b39671cc068530e2f0b
2019-09-26 22:33:53 +00:00
Reedy
dd71a77512 Make most special pages class names match filename
Change-Id: I3a9f932acb7d9cf44a984b5d97f9fbc6b8670f7d
2019-09-10 02:47:08 +01:00
jenkins-bot
6162ec0f35 Merge "Add QueryPage::delete method" 2019-07-31 14:15:14 +00:00
Gergő Tisza
767fdb56cf
Add QueryPage::delete method
Add a method for delete the cached result for a page. This is
useful for backlog-type query pages which provide some interface
for fixing the problem in-place.

Change-Id: I36b750d71b6551bb5c662e82c24f029db01acd3b
2019-07-26 23:22:30 +02:00
Gergő Tisza
2ba42f2374
QueryPage: allow arbitrary sorting
When the value field is not provided in QueryPage::getQueryInfo,
it is set to zero, essentially randomizing the result. Use a
sequential index instead.

Change-Id: I8b67268e3c59a51ed00bd832f80df184dd771c3b
2019-07-26 20:18:47 +02:00
Aaron Schulz
1fb1494c93 Use IResultWrapper in code comments instead of ResultWrapper
Change-Id: Idb813c20bef0d41d0f9f01440daab4fee6cdb38d
2019-06-22 17:58:39 +00:00
zoranzoki21
94df8929f7 Remove tryLastResult function from includes/specials/QueryPage.php
It is deprecated in 1.27

Change-Id: Ia10696a3d8e700cdf889c15e9b16b9d8e3e7f94f
2019-05-20 21:42:21 +00:00
Umherirrender
6896da4e14 Typehint against IDatabase in special pages
Change-Id: I1ec906cc7b284a3de02bb67fb41b5cf9e67ff3d2
2019-05-18 18:24:08 +02:00
eranroz
7d129953f6 Sunsetting viewPrevNext
Removing viewPrevNext from Language and moving it to SpecialPage.
Used soley in special pages, and we aim to remove/reduce the dependency
of messages and language

Bug:T207977
Change-Id: I49b41a89ba59cfc24982b321f02c5cca9939decd
2019-04-01 21:36:49 +02:00
Thiemo Kreuz
16847b4031 specials: Fix incomplete documentation of execute() param
The parameter passed to the execute() method of each special page can
be null, and usually is. In some of these files this fact was already
mentioned in the comment, but not listed as a type.

In this patch I also remove comments that do not explain much. Saying
that the execute() method of a special page "executes a special page" or
is the "main entry point to a special page" is not super helpful. That's
usually what the documentation in the parent class shoudl explain.
We can add @inheritDoc tags in all these cases if you prefer. Please
tell me.

Change-Id: I1d811ab0c6d5c956e36f6a74120a425abc4332e6
2019-03-28 16:26:42 +00:00
jenkins-bot
ba4644911d Merge "specialpage: Remove unused QueryPage::doFeed()" 2019-03-26 02:34:11 +00:00
Thiemo Kreuz
7a9bdff60d specialpage: Remove unused QueryPage::doFeed()
This code was written in 2004, and pretty much untouched since then.

The last non-trivial update to this code was done in 2014 via I1de6301.
But as far as I can tell this was just maintenance, not motivated by
somebody actually using this code.

I suspect this is unused for a long time already, long before 2014.
Possibly even unused in 2004. Really: I tried to dig into the revision
history of the core codebase to find when and where this was used, and
when it became unused. I could not find anything. I also used
https://codesearch.wmflabs.org to make sure there are no known callers
or subclasses hidden anywhere. I could not find anything either.

In conclusion I suggest to skip any deprecation phase.

Change-Id: I5f52c44760b903bcb348bebf8c6a0f6faf8180b7
2019-03-25 09:42:48 +01:00
Thiemo Kreuz
de398a4395 Update some minor type hints
Change-Id: If5a6372e79038d3750d30a931badd0c110da2fe5
2019-03-25 09:03:23 +01:00
Kunal Mehta
cc5d9a92a2 build: Updating mediawiki/mediawiki-codesniffer to 24.0.0
Change-Id: I66b1775b7c1d36076d9ca78cbeb42787a743f2aa
2019-02-07 18:39:42 +00:00
Aryeh Gregor
90d4f56fe4 Mass conversion of $wgContLang to service
Brought to you by vim macros.

Bug: T200246
Change-Id: I79e919f4553e3bd3eb714073fed7a43051b4fb2a
2018-08-11 22:44:29 -06:00
Fomafix
6866cfec37 Simplify PHP by using ?? and ?:
Also remove not necessary surrounding parentheses.

Change-Id: I0eb5c9c1bdfb09a800258379cdcefb5fd4d3d21c
2018-07-10 20:03:17 +00:00
Bartosz Dziewoński
485f66f174 Use PHP 7 '??' operator instead of '?:' with 'isset()' where convenient
Find: /isset\(\s*([^()]+?)\s*\)\s*\?\s*\1\s*:\s*/
Replace with: '\1 ?? '

(Everywhere except includes/PHPVersionCheck.php)
(Then, manually fix some line length and indentation issues)

Then manually reviewed the replacements for cases where confusing
operator precedence would result in incorrect results
(fixing those in I478db046a1cc162c6767003ce45c9b56270f3372).

Change-Id: I33b421c8cb11cdd4ce896488c9ff5313f03a38cf
2018-05-30 18:06:13 -07:00
Umherirrender
a3da44c7df Change ResultWrapper to IResultWrapper in pagers and special pages
There is no need for a specific type, the interface implementation is
enough

Change-Id: I22ec4d3a9a19fc86efc9a2deb06f810695d38c85
2018-04-04 14:52:10 +02:00
Umherirrender
3124a990a2 Use ::class to resolve class names in includes files
This helps to find renamed or misspelled classes earlier.
Phan will check the class names

Change-Id: I07a925c2a9404b0865e8a8703864ded9d14aa769
2018-01-27 20:34:29 +01:00
Umherirrender
255d76f2a1 build: Updating mediawiki/mediawiki-codesniffer to 15.0.0
Clean up use of @codingStandardsIgnore
- @codingStandardsIgnoreFile -> phpcs:ignoreFile
- @codingStandardsIgnoreLine -> phpcs:ignore
- @codingStandardsIgnoreStart -> phpcs:disable
- @codingStandardsIgnoreEnd -> phpcs:enable

For phpcs:disable always the necessary sniffs are provided.
Some start/end pairs are changed to line ignore

Change-Id: I92ef235849bcc349c69e53504e664a155dd162c8
2018-01-01 14:10:16 +01:00
Umherirrender
b5cddfb27b Remove empty lines at begin of function, if, foreach, switch
Organize phpcs.xml a bit

Change-Id: Ifb767729b481b4b686e6d6444cf48b1f580cc478
2017-07-01 11:34:16 +00:00
Aaron Schulz
dd359741cc Move DB errors to Rdbms namespace
Change-Id: I463bd86123501abc68fdb78b4cda6110f7af2549
2017-04-15 10:47:41 -07:00