Commit graph

29 commits

Author SHA1 Message Date
DannyS712
ba2e216399 GenderCache: remove checking for valid usernames
Violates proper DI by retrieving UserNameUtils from
MediaWikiServices instead of injecting, but can't inject
because that creates a circular dependency (UsernameUtils
indirectly relies on GenderCache via MediaWikiTitleCodec).

If callers can validate that they are only searching for the
genders of valid user names, that would be great but its
not required, at worst we just search for a few
extra database rows that don't exist.

Bug: T267054
Change-Id: I00813228e177a7a7d13969fae85cf725def8f879
2021-05-12 06:37:38 +00:00
ZabeMath
15881aefe9 Avoid using User::isValidUserName()
User::isValidUserName is deprecated since 1.35 and should be replaced with the UserNameUtils service

Bug: T277398
Change-Id: Iaef995b992e2f38f651453092b23c928479e7d18
2021-03-14 18:04:12 +01:00
DannyS712
324a46f9a7 Remove hard deprecated GenderCache::singleton
Bug: T249019
Change-Id: Id0d368dc8fda78465806215a46b06022bc658b85
2020-12-18 02:21:33 +00:00
DannyS712
196e305d4a GenderCache::getGenderOf - remove use of global $wgUser
Use RequestContext::getMain(), since we only need the context user's
name

Bug: T254702
Change-Id: I48a77904a173a06c5ec3d1e9e33193a0bf4ef5d6
2020-09-27 01:35:32 +00:00
jenkins-bot
25d4b6cd38 Merge "Use DefaultOptionsLookup for default option in GenderCache" 2020-06-29 08:28:45 +00:00
Umherirrender
63eaa9ae89 Use DefaultOptionsLookup for default option in GenderCache
Change-Id: I778d2c4cd8de2aee138566fe82d658d046edf3f4
2020-06-28 16:53:24 +02:00
Tim Starling
47a1619027 Remove terminating line breaks from debug messages
A terminating line break has not been required in wfDebug() since 2014,
however no migration was done. Some of these line breaks found their way
into LoggerInterface::debug() calls, where they mess up the formatting
of the debug log.

So, remove terminating line breaks from wfDebug() and
LoggerInterface::debug() calls.

Also:
* Fix the stripping of leading line breaks from the log header emitted
  by Setup.php. This feature, accidentally broken in 2014, allows
  requests to be distinguished in the log file.
* Avoid using the global variable $self.
* Move the logging of the client IP back to Setup.php. It was moved to
  WebRequest in the hopes that it would not always be needed, however
  $wgRequest->getIP() is now called unconditionally a few lines up in
  Setup.php. This means that it is put in its proper place after the
  "start request" message.
* Wrap the log header code in a closure so that variables like $name do
  not leak into global scope.
* In Linker.php, remove a few instances of an unnecessary second
  parameter to wfDebug().

Change-Id: I96651d3044a95b9d210b51cb8368edc76bebbb9e
2020-06-03 12:01:16 +10:00
Umherirrender
d991df93c8 Only take titles on GenderCache::doTitlesArray
Title parsing needs a TitleParser, but the TitleParser also needs the
GenderCache, makes things very hard to inject.
Move the work to the caller side parsing the titles.
There are currently only usage with titles
https://codesearch.wmflabs.org/search/?q=doTitlesArray&i=fosho&files=&repos=

Change-Id: Ie774a62439e885d46bdc6f2d34296e6de41bbf88
2020-05-10 22:42:32 +00:00
DannyS712
a0e3c77946 Hard deprecate GenderCache::singleton
Bug: T249019
Change-Id: I0748f081ee98c19de2951f94692c46b9064031ed
2020-04-08 18:23:36 +00: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
77cc34e734 Allow GenderCache to accept UserIdentity and LinkTarget
Change-Id: I0bb6c13ed2fbc3b247058c3b6e528e2b7015b757
2020-01-08 08:44:23 +00:00
Umherirrender
69c689380f Inject LoadBalancer into GenderCache
This avoids global function wfGetDB
Let the GenderCache work without a database connection as it is used
by the installer

Change-Id: I8a203c50de5841bc33693dadb8439a23a8c60910
2019-08-07 15:15:14 +02:00
Aryeh Gregor
571567cddc Update GenderCache to use NamespaceInfo
Change-Id: I0c2997bf8764249c26251d0f63f3ea0a0b272a7e
2019-05-06 12:08:45 +03:00
Fomafix
e1630b6a53 PHP: Use short ternary operator (?:) where possible
Change-Id: Idcc7e4fcdd4d8302ceda44bf6d294fa8c2219381
2018-06-11 11:26:35 +02: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
Thiemo Mättig
ef470ebf7f Remove @param comments that literally repeat what the code says
These comments do not add anything. I argue they are worse than having
no comments, because I have to read them first to understand they
actually don't explain anything. Removing them makes room for actual
improvements in the future (if needed).

Change-Id: Iee70aad681b3385e9af282d5581c10addbb91ac4
2018-01-10 14:14:26 +01:00
Aaron Schulz
950cf6016c Rename DB_SLAVE constant to DB_REPLICA
This is more consistent with LoadBalancer, modern, and inclusive
of master/master mysql, NDB cluster, and MariaDB galera cluster.

The old constant is an alias now.

Change-Id: I0b37299ecb439cc446ffbe8c341365d1eef45849
2016-09-05 22:55:53 -07:00
addshore
b85d9f3363 Make GenderCache use MediaWikiServices
Change-Id: Id20310f78d938bdfa4d29ae483bb1a33bacd2b51
2016-05-07 13:26:26 +01:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00
umherirrender
fd66273c94 Fixed some @params documentation (includes/[cache|objectcache])
Swapped some "$var type" to "type $var" or added missing types
before the $var. Changed some other types to match the more common
spelling. Makes beginning of some text in captial.
Also added some missing @param.

Change-Id: I86fd10e3f2d4bb80e7432533038d124693acfb3c
2014-04-19 01:19:46 +02:00
Siebrand Mazeland
8251479984 Update formatting
Change-Id: I9aa56cbe0989d6f302ee0f47c4a6154101f73e90
2013-11-17 21:46:55 +01:00
MatmaRex
df8ec1e216 No spaces after (casts)
Also removed some unnecessary ones. I think I've caught them all.

The spaceless version already appears in core ~300 times (after
accounting for false positives when grepping). Some consistency would
be nice.

Change-Id: I607655b5f4366e66dc78730d5fd2f57ed8776cae
2013-09-04 20:05:43 +02:00
umherirrender
1bfc8feb25 Fixed spacing in actions/cache/filebackend/filerepo/job folder
Added spaces before if, foreach
Added some braces for one line statements

Change-Id: Idb93d34e314e5f314223b79208968d6bcd30c40e
2013-04-20 19:18:13 +02:00
Tyler Anthony Romeo
4dcc7961df Fixed @param tags to conform with Doxygen format.
Doxygen expects parameter types to come before the
parameter name in @param tags. Used a quick regex
to switch everything around where possible. This
only fixes cases where a primitve variable (or a
primitive followed by other types) is the variable
type. Other cases will need to be fixed manually.

Change-Id: Ic59fd20856eb0489d70f3469a56ebce0efb3db13
2013-03-11 13:15:01 -04:00
umherirrender
0ea2c38727 Fill GenderCache inside ApiPageSet
the queries for title and pageids are own queries created by the api,
which does not use the GenderCache, that can produce a query per row

Change-Id: I932f8d9d1cfa751dbb6f5237e2de325527d3ff53
2012-05-16 16:46:22 +02:00
Alexandre Emsenhuber
4471b93253 Added missing GPLv2 headers in some places.
Also made file/class documentation more consistent.

Change-Id: I604ed8ddc572e89001e49df6740ab42307bc0330
2012-05-08 14:51:21 +02:00
umherirrender
4989ddd423 strip off subpages direct in GenderCache
LinkBatch can also give subpages to the GenderCache and therefor it is
easier to do it always in GenderCache, than in LinkBatch and Title

Add unit tests for GenderCache

Change-Id: Ia936ff8bb639a197b0b3a8e07c97a66edd57dd10
2012-04-21 10:34:22 +02:00
umherirrender
dfe61f64af GENDER should use the GenderCache
This reused the gender state of a user on a page. This is helpful for
special pages which shows the group name, because the each group name
used gender, which result in often use.

Change-Id: I8e816f54aaa100c3333e84e19299fd194323341d
2012-04-07 22:45:31 +02:00
Niklas Laxström
055a1c485c Moved GenderCache to cache/ 2012-01-10 07:39:51 +00:00
Renamed from includes/GenderCache.php (Browse further)