Commit graph

921 commits

Author SHA1 Message Date
DannyS712
82657a347a Hard deprecate using Revision objects for Linker methods
Bug: T249561
Change-Id: I0a9ece35900e0b844e66ba119b04a848dc1ecc82
2020-04-18 02:01:42 +00:00
DannyS712
af7f397ccc Pass RevisionRecord to Linker methods
Hard deprecation of passing Revision objects will follow soon,
but until that is ready core calls can be updated

There is some code cleanup that could be done around the calls, but
to simplify review no other changes are made.

Bug: T249561
Change-Id: Ifcfb3811650decffeaa87dc033c41fd1710b47a6
2020-04-18 01:24:54 +00:00
DannyS712
ae690a533b Accept RevisionRecord in Linker methods
In addition to Revision, for now

Bug: T249561
Change-Id: Ia05db749ebceb419fb27a4120fdd10d7bda9f66b
2020-04-07 00:54:31 +00:00
jenkins-bot
b2be858d92 Merge "Remove direct access to Action::page and Article::page properties" 2020-03-27 04:36:51 +00:00
ArtBaltai
726a2650d3 Remove direct access to Action::page and Article::page properties
Bug: T239975
Change-Id: Id0d4d1e099edbdd67cabbed423dfff68cc48d323
2020-03-27 04:10:51 +00:00
DannyS712
1d4df4f221 Hard deprecate Revision::getQueryInfo and ::getArchiveQueryInfo
Bug: T246284
Change-Id: I708f265aac3016e34d02936cf5dff98a3036ef0f
2020-03-26 23:53:19 +00:00
jenkins-bot
0de13c6125 Merge "Fix mismatching type hints in PHPDoc tags" 2020-03-26 13:35:31 +00:00
Thiemo Kreuz
1006aa41e6 Fix mismatching type hints in PHPDoc tags
This is a collection of random bits from my local stashes. This patch
intentionally only touches comments, no code.

Notably:
* Use more specific string[] instead of array, if possible.
* Some comments mention "or null", but miss to list the type.

Change-Id: I712b28964f125c8e3dcb4e3fb993757a09f96644
2020-03-24 09:59:02 +01:00
DannyS712
a8d93e2169 Linker: Pass a user to revision methods using FOR_THIS_USER
Bug: T248291
Change-Id: I336f6a4ddd696f7471d09eaec252096a9c575abc
2020-03-23 05:40:42 +00:00
DannyS712
78bc3ae255 Hard deprecate Revision::userCan
Replace remaining uses outside of tests, hide deprecated in tests

Bug: T247259
Change-Id: I91dfb46ed6864ee89d968aea8ec93b5ea2f8389e
2020-03-11 02:10:52 +00:00
DannyS712
9e701c9698 Remove use of global $wgUser in Linker::userToolLinks
Bug: T244602
Change-Id: Id49043ca5ef9cf655f3aace520b344463991b39b
2020-02-19 23:39:28 +00:00
Matt Fitzpatrick
8a1f19d726 Add ARIA navigation role and label to table of contents div
Adds accessibility context to the automatically generated table
of contents div for a page. The div's role is navigation, and
its label is the heading "Contents".

JAWS, for example, can navigate to the table of contents by
region, and announces it as "Contents navigation region".

Bug: T139221
Change-Id: Ie9b291301f683d2be2cb2134f9d6ae3f7a6d831b
2020-02-05 16:24:46 -08:00
Kunal Mehta
99007e96c7 Use namespaced IPUtils class
Change-Id: I047e099a93203a59093946d336a143d899d0271f
2020-01-01 02:36:49 -08:00
Umherirrender
46f6a9e13f Document null for $html on Linker::link
The default value of null should be part of the @param

Change-Id: Ib612a29e355c7dda8f3f66270a2fbd33cb1938be
2019-12-12 19:57:11 +01:00
Umherirrender
925e3eb30b Set method visibility in some classes
Change-Id: I3c3d59d4b3edf2459efeac890721a43475e27198
2019-12-05 17:42:55 +00:00
daniel
e98094956a Don't fail hard on bad titles in the database.
This updates some code that has been constructing TitleValue directly
to use TitleValue::tryNew or TitleParser::makeTitleValueSafe.

Bug: T200055
Change-Id: If781fe62213413c8fb847fd9e90f079e2f9ffc9d
2019-11-25 22:15:38 +01:00
Umherirrender
337ecb0514 Add missing @param and @return to documentation
Change-Id: Ibc5849cc8ea7e7c4eb30ded9c1cfa5f52187c377
2019-11-10 22:12:58 +00:00
Daimona Eaytoy
cae0110e5a Fix new phan errors, part 1
First part, mostly doc-only.

Bug: T231636
Change-Id: Id59f585740fa5bfb53c257287121f51a30de38fe
2019-10-11 15:04:04 +00:00
Max Semenik
8835ac44ad Linker: Kill HHVM and PHP5 special case
Add another test case to be extra sure™ it won't regress.

Change-Id: Ib35a469e70ee475ea88a1f99a733ffb4ac751a45
2019-10-06 12:19:32 -07:00
Daimona Eaytoy
e5444ea55a docs: Avoid some scalar juggling
Phan can treat scalar types as non-interchangeable with
`scalar_implicit_cast` set to false. This patch fixes some of those
issues (which are in total >1000), namely the ones with alphabetic order
< includes/actions.

Change-Id: Ib1c6573ab899088bc319b9da9ceaffc850da3dbe
2019-09-19 17:21:24 +00:00
Umherirrender
f74400487f phan: Disable enable_class_alias_support
It is enabled for b/c in extensions, but not needed in core

Change-Id: I51dca12be9c77049f77563d9bf0edd07928c2300
2019-09-15 08:26:52 +00:00
Umherirrender
6b8a2a75ee Avoid multiply calls to MediaWikiServices::getInstance() in one function
RepoGroup::singleton() results in
MediaWikiServices::getInstance()->getRepoGroup()

Also avoid getting the service in loops, doing it once before the loop
is cheaper

Change-Id: I29e0c7487e3e498559ff16a567e2fad0c0f8bb69
2019-09-01 20:49:19 +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
jenkins-bot
786524a94a Merge "Let Html::element do the HTML encoding" 2019-08-28 06:57:34 +00:00
Fomafix
bb94f4964d Use local variabe $services instead of MediaWikiServices::getInstance()
Change-Id: Ieb6230231d9b916fd1366e7b473db00c87ac4428
2019-08-26 16:12:05 +02:00
Petr Pchelko
1d286560d2 Replace User::isAllowed with PermissionManager.
Covers root includes, actions, api, block, changes,
changetags, diff and PermissionManager itself.

Bug: T220191
Change-Id: Ic027d32f5dd8f4c74865df0c8a9fcf91123c889c
2019-08-20 14:43:51 -07:00
Fomafix
7da70855fe Let Html::element do the HTML encoding
Also inline variables used once and move the htmlspecialchars to the
self::link call.

Change-Id: I6d9063af3f4ff0a6d70f3ebbce8362122d5bb06a
2019-08-07 23:51:41 +02:00
Derick Alangi
434d740d90 Avoid usage of deprecated Revision::* constants
Change-Id: I2d06bbacef88573f286da25994a3ad434ed90e9c
2019-07-21 18:02:58 +01:00
Derick Alangi
339211a1ea Avoid usage of deprecated Revision::* constants, use RevisionRecord
Change-Id: I872fc89e5c02dd6a3ae9cd7e76640b95dc33f514
2019-07-21 15:03:03 +01:00
Fomafix
f095d0d771 Linker: Force type Language for $lang in tocList and generateTOC
The call of wfGetLangObj( $lang ) is not necessary anymore.

$lang still defaults to user interface language on unset parameter.

This change is a follow-up to I15b65fec987641885374dfef9e1229ea405f7c30.

Change-Id: I6f12097a0e6cf7d6035d1164092c8b87c58e2bee
2019-07-16 07:03:59 +02:00
Brad Jorsch
1ef6deed00 Linker: Fix incorrect test added in Ib9816d8b
The test was intended to check for whether we have a user ID *or* a user
name. Instead, it's checking if we have a user ID *and* a user name. And
it also failed to consider User:0.

Bug: T227656
Change-Id: Ia1b5c4a6ae028513b73a65cd2c885459327d29c3
2019-07-10 13:30:03 -04:00
jenkins-bot
8fc57e9555 Merge "Check for valid user info before calling Linker::userLink() in Linker::revUserTools()" 2019-07-01 13:04:04 +00:00
Gergő Tisza
b71610c069
Fix LocalFile::move
Fixes a wfFindFile/wfLocalFile mixup in I9437494d.

Also restore the original behavior in Linker::makeBrokenImageLinkObj
for paranoia - findFile has a local cache so calling it and then
discarding the results is not completely a noop.

Bug: T226448
Change-Id: Ibb9d6f6383eb96ba27e0edd60423552e5cea4688
2019-06-25 18:38:13 +02:00
James D. Forrester
6b2c6fdf6a Linker:🔗 Drop support for string query param, deprecated in 1.20
Change-Id: I910cead2c32a3525772ee0640c8ed3b90ad40a84
2019-06-24 11:11:17 -07:00
Derick Alangi
21e2d71560 Replace some uses of deprecated wfFindFile() and wfLocalFile()
These global functions were deprecated in 1.34 and services made
available to replace them. See services below;

* wfFindFile() - MediaWikiServices::getInstance()->getRepoGroup()->findFile()
* wfLocalFind() - MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo()->newFile()

NOTES:

* wfFindFile() and wfLocalFind() usages in tests have been ignored
  in this change per @Timo's comments about state of objects.

* includes/upload/UploadBase.php also maintained for now as it causes
  some failures I don't fully understand, will investigate and handle
  it in a follow up patch.

* Also, includes/MovePage.php

Change-Id: I9437494de003f40fbe591321da7b42d16bb732d6
2019-06-11 13:26:37 +00:00
Bill Pirkle
5830ca7a2f Check for valid user info before calling Linker::userLink() in Linker::revUserTools()
If an actor table row has neither an actor_user nor an actor_name
value (which should not have happened, but did), we would call
Linker::revUserTools() with no valid user info. This generated
log noise and displayed bad output. Instead, check for valid user
info, and fall back to a default message if necessary. T225469
exists for correcting the underlying bad data, but adding this
check is still prudent.

Bug: T224368
Change-Id: Ib9816d8b87b995f4fe465004acd608225728e391
2019-06-10 18:22:17 -05:00
daniel
e9e50ad014 Make userLink() not fail too hard on false and null.
This works around an issue in Flow, which sometimes passes false
for a user name.

Bug: T224095
Change-Id: I14dc52f7199012dc35605f3170b06eb1719165a7
2019-06-05 14:51:57 +02:00
daniel
0c4410a623 Fix empty auto-summaries triggering a fatal error.
Aka:  Streamline Linker::formatAutocomments() and add tests

This uses the "streamlining" for the code proposed by Thiemo
in I38edc1ad7720. I have squashed the two commits, so it now
has his code in Linker, but still has my tests as well as his.

Thiemo wrote on his patch:
This also changes the output in case there is no fragment to link to.
Before an empty `/* */` in a summary this would have created a link to
the page. I would like to argue this is not what a user expects.

Bug: T222628
Change-Id: I05408ede0e20dfd976f4057fc5baab461d2ef769
2019-05-30 16:34:34 +02:00
Bill Pirkle
1449fa7769 Switch empty username logging from warning to debug.
Change ddd1d4b920 added logging when an empty username is
passed to various Linker.php functions. The logging revealed
this occuring on live, but it is occuring frequently and
causing distracting log noise. Switch the logging type from
warning to debug while the root cause is investigated.

Bug: T224050
Change-Id: I93826e486951e992afdf778f446792d3c209996a
2019-05-24 21:14:42 -05:00
Timo Tijhof
63cf83e089 Linker: Fix fatal error for "/* */" in an edit summary
Follows-up b6e1e99bec, which switched the method from Title::makeTitleSafe
to TitleValue. The latter throws fatal on non-string $fragment.

Title::makeTitleSafe, on the other hand, uses makeName(), which casts
$fragment to a string, and ignores if it ends up as empty string
(boolean false becomes empty string and thus did "the right thing").

Bug: T222857
Change-Id: Iecc2140fabd31ef0f193740c7fab0fc698c38e51
2019-05-19 11:20:34 +00:00
Aryeh Gregor
2e1ac38485 Mass conversion to NamespaceInfo
Change-Id: I2fef157ceec772f304c0923a1cd8c0eef2e82a0f
2019-05-07 22:44:56 +02:00
Aryeh Gregor
ddd1d4b920 Log warning and show error on empty username
Historically it seems that if Linker::userLink or friends were passed an
empty username (probably due to an incorrect database entry), they would
produce bogus output, e.g., an <a> with no contents or a link to the
invalid page "User_talk:" or similar.

In b6e1e99bec we replaced an occurrence of Title::makeTitle() (no
safety checks!) with creating a TitleValue, which asserts in its
constructor that the title text is not empty. This made such pages fail
an assertion and stop displaying at all.

Now there's a proper check for the error. Such cases will log a
production error and return "(no username available)".

Bug: T222529
Change-Id: Id65bdf9666b0d16e5553b8f38c7cf8fce2e37a25
2019-05-06 14:44:23 -05:00
Roan Kattouw
5ce1e2b743 Linker: Use parentheses by default in userToolLinksRedContribs()
This function had been changed to unconditionally disable parentheses,
but none of its callers load the CSS needed to make that work.

Bug: T220767
Change-Id: I566d65e155258d3bd1a1a06bca9aa2b3a2d417ee
Follows-Up: I6eeeaa3b58d37adb7fefb4cc6915022229b3b324
2019-04-19 15:09:36 -07:00
Aryeh Gregor
b6e1e99bec Use LinkTarget in Linker instead of Title
Bug: T214318
Change-Id: I60b6208fa5b45a568e81f908a19cd0f244ef79be
2019-04-15 17:15:05 +03:00
jdlrobson
5040b3f680 RecentChanges updated to use pseudo elements for presentation
Bug: T219348
Change-Id: I6eeeaa3b58d37adb7fefb4cc6915022229b3b324
2019-04-02 14:52:50 -07:00
jenkins-bot
a3ab671e61 Merge "Remove temporary rollback confirmation toggle" 2019-03-28 09:28:12 +00:00
jdlrobson
064dd53b28 Consistently use classes for deleted items in lists of diffs
Even if a revision has been deleted and the history-deleted class is
being used, the original class for its corresponding element when
not deleted should be applied. This is important as it allows skins
to skin consistently. "history-deleted" is a modifier class - it provides
further information on the original meaning.

This blocks styling the history page from core in Minerva skin

Bug: T216420
Change-Id: Ia659606838d7e38bc09054e36cd980b00f5e6da9
2019-03-26 23:04:51 +00:00
Tim Eulitz
8736acada9 Remove temporary rollback confirmation toggle
This patch removes the temporary rollback confirmation toggle that was
implemented to allow certain wikis to disable the rollback confirmation
feature while still showing the option in the user preferences.

For reference:

https://gerrit.wikimedia.org/r/c/mediawiki/core/+/494249

Bug: T217437
Change-Id: I001d7927f6f44a4cc517a80b71f5b83aca33824c
2019-03-26 10:13:45 +01:00
jdlrobson
063cce733e History page is now using pseudo elements for presentation
|, ( and ) separators are now added via CSS rather than being
made part of the HTML.

Bug: T205581
Change-Id: I272770418ee544b22f8f94312daf07010b7a2273
2019-03-26 00:15:21 +00:00
Thiemo Kreuz
9314453c93 Make use of the list() feature where it makes sense
This code is functionally identical, but less error prone (not so easy
to forget or mix these numerical indexes).

This patch happens to touch the Parser, which might be a bit scary. We
can remove this file from this patch if you prefer.

Change-Id: I8cbe3a9a6725d1c42b86e67678c1af15fbc5961a
2019-03-24 20:12:23 +00:00