Commit graph

106 commits

Author SHA1 Message Date
Reedy
21b679223c IndexPager: Add @since notation to getDatabase()
Because I looked it up, I might aswell commit it.

Moved in 84ce626df6

Change-Id: I646aa8a4272a5d93c628c2282b0b4d5a13b68ed9
2021-09-29 15:13:12 +01:00
Tim Starling
f7f84dddb3 Introduce CommentFormatter
CommentParser:

* Move comment formatting backend from Linker to a CommentParser service.
  Allow link existence and file existence to be batched.
* Rename $local to $samePage since I think that is clearer.
* Rename $title to $selfLinkTarget since it was unclear what the title
  was used for.
* Rename the "autocomment" concept to "section link" in public
  interfaces, although the old term remains in CSS classes.
* Keep unsafe HTML pass-through in separate "unsafe" methods, for easier
  static analysis and code review.

CommentFormatter:

* Add CommentFormatter and RowCommentFormatter services as a usable
  frontend for comment batches, and to replace the Linker static methods.
* Provide fluent and parametric interfaces.

Linker:

* Remove Linker::makeCommentLink() without deprecation -- nothing calls
  it and it is obviously an internal helper.
* Soft-deprecate Linker methods formatComment(), formatLinksInComment(),
  commentBlock() and revComment().

Caller migration:

* CommentFormatter single: Linker, RollbackAction, ApiComparePages,
  ApiParse
* CommentFormatter parametric batch: ImageHistoryPseudoPager
* CommentFormatter fluent batch: ApiQueryFilearchive
* RowCommentFormatter sequential: History feed, BlocklistPager,
  ProtectedPagesPager, ApiQueryProtectedTitles
* RowCommentFormatter with index: ChangesFeed, ChangesList,
  ApiQueryDeletedrevs, ApiQueryLogEvents, ApiQueryRecentChanges
* RevisionCommentBatch: HistoryPager, ContribsPager

Bug: T285917
Change-Id: Ia3fd50a4a13138ba5003d884962da24746d562d0
2021-09-28 11:13:03 -07:00
DannyS712
7cca5dea0b TablePager: fix param documentation for formatValue()
Can receive null value if the field isn't in the database result.

Change-Id: Id995a384dc58f5d8216a7309490b98558004d071
2021-09-09 08:44:27 +02:00
Umherirrender
2e4ee47c3d Cleanup mixed space/tab line indent
Change-Id: I833052a656b1ce419c0929f6f0514f2a33c2c4cc
2021-09-04 00:52:31 +02:00
Thiemo Kreuz
4764a3dc06 Remove redundant class="" related condition from TablePager
The Html class does this already, since 2009 even:
https://phabricator.wikimedia.org/rMWf03c53b8a7a9dac33d3ef9947bf2fe5b6c354c9f

Change-Id: Ic002790417b2430fe6fce5cd37634c518eda80a2
2021-08-26 10:43:03 +02:00
DannyS712
00927d4c36 TablePager: don't call getRowClass twice when the result was saved
We have $class already

Change-Id: Ia78d313eb12597757bd9045ba9d1e71587e28d93
2021-08-26 07:04:52 +00:00
jenkins-bot
c039f2db81 Merge "Simplify loops over array_keys" 2021-08-24 13:19:38 +00:00
jenkins-bot
a3245767f1 Merge "pager: Simplify loop in AlphabeticPager" 2021-08-24 13:19:32 +00:00
Matěj Suchánek
5267cc09ea Simplify loops over array_keys
Use native PHP feature of iterating over key-value pairs
instead of looking up the value if it's used.

Change-Id: Id55f774b3a9d97463b97581c5b2ffe081489863a
2021-08-12 07:08:36 +00:00
Alexander Vorwerk
0d48f7d25b Hard deprecate User::getIntOption()
deprecated since 1.35 and unused

Bug: T274211
Change-Id: If739492953ee53a39c81894c48f16be81c845542
2021-08-11 14:16:40 +02:00
Thiemo Kreuz
cde4080b22 pager: Simplify loop in AlphabeticPager
Change-Id: I774feef71ecff5dae258a7e045372f9791d905a6
2021-08-09 09:28:33 +02:00
Reedy
fb771021ea Use some more neutral language
Bug: T277987
Change-Id: Ieceb01f7a61693a0f03cc331213cb8f93163b8e9
2021-04-18 16:49:36 +01:00
Reedy
cce3fb49d0 Use more neutral or alternative language
Bug: T277987
Change-Id: Iafc4b3e3137936046487119b7e17635f4e560277
2021-03-20 19:47:18 +00:00
Reedy
bbe130b242 Rename some variables to use more neutral language
Bug: T254646
Change-Id: I997625b8201dce2c257d20f96d00089e995c2b0d
2021-03-19 16:18:49 +00:00
Umherirrender
8de3b7d324 Use static closures where safe to use
This is micro-optimization of closure code to avoid binding the closure
to $this where it is not needed.

Created by I25a17fb22b6b669e817317a0f45051ae9c608208

Change-Id: I0ffc6200f6c6693d78a3151cb8cea7dce7c21653
2021-02-11 00:13:52 +00:00
DannyS712
2c6e42c434 IndexPager - document getLinkRenderer
Had to look through git blame to find when it was added (1.34)
for a recent review, would be helpful for others if it was easily
available in a doc block; since I'm adding a doc block, also
add @return

Change-Id: I07c4cdda176f309204fa3c2cfe6c165d1df850af
2020-12-14 08:22:30 +00:00
Umherirrender
9fb6d107ba Improve docs about @param/@return object $row to stdClass
Change-Id: I743d992db703f2b46b6e3abf80c14d026c6599f4
2020-11-13 00:08:21 +01:00
Thiemo Kreuz
89e454c7fe pager: Fix PHPDoc tags in TablePager
Change-Id: Iec69eb7f27c616dad5138b54158cbf955e9d5990
2020-11-11 22:20:47 +00:00
jenkins-bot
39705eb311 Merge "Replace "@stable for subclassing" with "@stable to extend"" 2020-07-13 09:31:38 +00:00
jenkins-bot
0270990f0b Merge "Replace "@stable for calling" by "@stable to call"" 2020-07-13 09:27:04 +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
272db6afde Replace "@stable for calling" by "@stable to call"
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: If560596f5e1e0a3da91afc36e656e7c27f040968
2020-07-13 08:55:28 +00:00
daniel
0bb1180743 Mark pager base classes as stable for subclassing.
This makrs Pager baseclasses as stable for subclassing per the Stable
Interface Policy. This also indicates which of the methods defined by
the base classes can safely be overwritten by extensions.

Bug: T247862
Change-Id: If1e0a35427b55d72c86f8f2530bd47aa4130fa92
2020-07-08 14:15:19 +00:00
daniel
442fb30ce1 Stability annotations for interfaces.
Per the Stable Interface Policy, PHP interfaces should not be
directly implemented by extensions, unless they are marked to be safe
for that purpose.

Bug: T247862
Change-Id: Idd5783b70fc00c03d57f5b1a887f0e47c4d7b146
2020-07-07 22:01:29 +00:00
DannyS712
94169ee873 Whitespace cleanup: Use tabs for indentation, avoid double spaces
Change-Id: I346073b59d283029bd6666356c62c81e687ea5e6
2020-06-27 07:53:07 +00:00
daniel
db4ac19f7e Replace @protected tag
This patch replaces all usages of @protected in core.
The @protected tag was removed in cases where it was redundant or
contradictory. It has been replaced by @internal where usage outside of
core is not desired, and with @note for cases where use by extensions
is desired, but should be limited.

Bug: T247862
Change-Id: I5da208e5cb4504dde4113afb3a44922fd01325a3
2020-06-26 14:31:16 +02: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
Reedy
60fdd5d8cd Fix some more Squiz.Scope.MethodScope.Missing
Change-Id: I5560d3d65a31f0922c9518b647be690fdb06e6be
2020-05-17 01:30:25 +00:00
Reedy
4cd8d9cff5 Fix numerous PSR12.Properties.ConstantVisibility.NotFound
Change-Id: I2ec09c02c2e4ed399d993cb1871e67df02167ca8
2020-05-11 01:36:36 +01:00
James D. Forrester
d109281079 IndexPager: Limit offset params to the max of the indices available
Change-Id: I13ec4b1cb0b83e6a2352319cce476f1a9dee96d7
2020-02-20 13:42:16 -08:00
DannyS712
3d8e6c6448 Replace WebRequest::getLimitOffset with ::getLimitOffsetForUser
Bug: T243805
Change-Id: I8b084e447e12a330bdce2bff18fd7c756ac5f698
2020-02-19 00:50:21 +00:00
Thalia
b60afbb89a TablePager: Improve documentation for getDefaultSort
Change-Id: I80ef8794c6c2d66a5a1c7d826d97f95ac25b918e
2020-02-14 18:29:03 +00:00
Dayllan Maza
9dbd67f0b3 Improve documentation of abstract methods
Re-wording documentation to remove the obvious. Also makes @inheritDoc
more readable and less confusing.

Change-Id: I7178efc7259ef68e3e3b889174140db8c0201640
2020-02-14 08:05:43 -05:00
Thalia
e6686ffec2 TablePager: Fix documentation for getIndexField method
Documentation is now inherited from the parent, which allows several
return types.

This allows classes that extend TablePager to paginate on multiple
columns, introduced in 6786aa5d8e.

Change-Id: Ic2572bfad9cefe52ffb56cd7acab21251b87ecf9
2020-02-13 13:53:36 +00:00
Thalia
1f3a5dd527 IndexPager: Cast properties passed to implode to arrays
$mLastShown, $mFirstShown and $mPastTheEndIndex should be arrays
since 6786aa5d8e, but classes that
override doQuery do not all honour this.

Cast these to arrays as they are passed to implode.

Bug: T244941
Change-Id: I1e6d9bee852e304e6b10733f53f942942cc0ff52
2020-02-12 00:29:30 +00:00
Roan Kattouw
bf9ae0768d ImageHistoryPseudoPager: Update doQuery() for IndexPager changes
This class duplicates a bunch of code from IndexPager, and that code was
changed in 6786aa5d8e in a way that broke
this code. Update it to account for the fact that mFirstShown,
mLastShown and mPastTheEndIndex are now arrays. Also update the
documentation in IndexPager to reflect that.

Bug: T244937
Change-Id: I51a50b6d3be1467f4ee399446d1d12cfed71a06c
2020-02-11 15:36:28 -08:00
jenkins-bot
c837c1d097 Merge "Support pagination on multiple columns in the IndexPager" 2020-02-08 06:13:46 +00:00
Thalia
6786aa5d8e Support pagination on multiple columns in the IndexPager
Allow subclasses to return an array of column names via
getIndexField. The offset is built using values from those fields,
and the order of precedence for sorting corresponds to the order
of the fields.

The offset is imploded and exploded using '|'.

Bug: T244492
Change-Id: I45c66df4dfe07c947f0ffcd4d6def4e1fcfbb36c
2020-02-06 16:21:46 -08:00
Thalia
36ed224b8f Fix IndexPager documentation to use correct terms in query
The $mIndexField and $mExtraSortFields properties are set in the
constructor according to the value of 'order', rather than 'count'.

Change-Id: I31298ca86bbc0b95391e60194a1d99a76c662764
2020-02-03 13:41:22 -08:00
jenkins-bot
fae044d9f9 Merge "IndexPager::$offset can be int|string" 2020-01-15 19:09:11 +00:00
Tony Thomas
11ca56324d IndexPager::$offset can be int|string
Breaks: I810640a07268d93b4f80745528281776b4a54682
Apparently, it is defined on the class prop correctly as an int|string

Bug: T242783
Change-Id: I44b598e885947cadaa3bae2b7446f150395f1cea
2020-01-15 18:49:50 +01:00
Thiemo Kreuz
b39a56d74e Make use of existing array value variables in foreach loops
In all these cases, the foreach() loop specifies a variable for the
current value. We don't need two ways to access the same value. This
makes the code harder to read.

Change-Id: I6ed7a518439963b7091057194de993a7e977be32
2019-12-29 12:04:29 +00:00
Thalia
5b4a1b2d4a Remove old, unused profiling from IndexPager
Change-Id: Idc4e9734be0e50f6d74adbda54afaba1596fb6ff
2019-12-19 19:54:25 +00:00
Daimona Eaytoy
ba1822f245 pager: Improve the extra sort field to work well when indexField is a string
The getExtraSortFields() function was well documented for the case when
getIndexField returns an array. But what if it returns a string?
Currently, using getExtraSortFields with a string as indexField means
that whatever you'll sort the table by, the extra sort will be used.
Instead, with this patch the extra sort will have two different
behaviours, depending on whether the extraSort array is associative or
not. If it is, then only the extra sort for the current field will be used.
Otherwise, like it already does, the extra sort will always be applied.

This is intended to be used by AbuseFilter in I979849e66 for T191694.

Change-Id: I0e695f96f18c7a9229753b1225dd473feb936a31
2019-11-22 16:23:38 +00:00
Umherirrender
70c63d120f Pass Title to IndexPager::buildPrevNextNavigation
LinkTarget was changed to Title in
Ie6233561de78457cae5e4e44e220feec2d1272d8
Change-Id: Iba1fe984ecfc08737131a3827198a5b7018d7ec0
2019-09-04 20:25:59 +02:00
Matěj Suchánek
b587c7d4e5 Restore some previous constructor calls
Follow-up to If07f10075a51fbbe9de24464cb6844faaad94780
and I082152b64141f1a9a4085bba23fe81a99ec8d886.

It will make getRequest use the provided context again.

Change-Id: I60b2598edcb0daed076876482e1e9d6cbf815eb2
2019-08-27 09:56:38 +02:00
Elliott Eggleston
28a221825f TablePager: put parent construct call back at end
Restores position of parent constructor call, changed in commit
I082152b64141f1a.

The parent constructor calls getIndexField(), which depends on the
mSort value already being set.

Bug: T231261
Change-Id: If07f10075a51fbbe9de24464cb6844faaad94780
2019-08-26 23:43:01 -05:00
Matěj Suchánek
2ec627ea02 Clean up LinkRenderer usage in IndexPager and extensions
The property needs to be private because pagers in extensions
may declare the same property with stronger visibility which
would crash.

Bug: T149346
Change-Id: I082152b64141f1a9a4085bba23fe81a99ec8d886
2019-08-25 20:11:53 +02:00