Commit graph

53 commits

Author SHA1 Message Date
Volker E
ade83aff14 Replace 'TablePager' CSS class exclusively by mw-datatable
`mw-datatable` has already been in use and should be the main class
for styling TablePager tables.
`mw-datatable` also includes the equivalent padding of former
`.TablePager th` & `td`, therefore removing it.

Bug: T214218
Change-Id: I2025b2ede87035e15f0280a6fe5efddec174bcca
2019-03-13 07:29:31 +00:00
jenkins-bot
06825cbeae Merge "Replace sorting classes with better naming convention" 2019-03-13 00:27:11 +00:00
Volker E
5c8ba9ebf4 Replace sorting classes with better naming convention
Improving CSS structure by removing code duplications.

Bug: T214218
Change-Id: I0501e1ab934aef3af289fee618b99578a1f0285c
2019-03-12 00:12:20 -07:00
jenkins-bot
9c5d5606fc Merge "Make IndexPager query direction code more readable" 2019-03-08 00:05:31 +00:00
Umherirrender
b00852c91a Add @var to Pager classes
Some are needed to make better results with phan in extensions

For example:
File CentralNoticeCampaignLogPager.php line 12:
Assigning array{0:20,1:50,2:100} to property but
\CentralNoticeCampaignLogPager->mLimitsShown is
array{0:20,1:50,2:100,3:250,4:500}
[PhanTypeMismatchProperty]

With "@var int[]" the type is correct

Change-Id: Ic68910bf17344852ad11fcc000a47891e4bf0179
2019-03-07 20:25:11 +01:00
Aaron Schulz
46db79baed Make IndexPager query direction code more readable
Rename $descending variable in doQuery() to $order, along with the
$descending argument to reallyDoQuery() and buildQueryInfo(). Use
new IndexPager::QUERY_* constants for checking and inverting such
values. Fix the comments so that they do not imply the opposite of
what is true anymore.

For compatibility, the constants are boolean values such that any
subclass defining reallyDoQuery()/buildQueryInfo() can use that
argument the same way as before.

Change-Id: I912d3678c755c25463a2fadbec6888f3a87d4215
2019-03-06 14:29:22 -08:00
Aaron Schulz
3162b076ef Various small code and comment cleanups to IndexPager
Change-Id: I351c12d51468bd428207017929fec1e796097206
2019-03-05 01:42:54 -08:00
Volker E
36263dd18c TablePager: Reduce pagination button in visual strength
Reducing buttons to `frameless` buttons and reposition icons of
next and last page button to be symmetrically harmonious.

Bug: T214128
Change-Id: I1c0a621d7699b5fadc2559abdf6003a0db0aabae
2019-01-17 16:56:21 -08:00
jenkins-bot
2b5cd32428 Merge "Mark protected IndexPager properties also as protected in subclasses" 2018-12-21 23:39:16 +00:00
Thiemo Kreuz
5b1cda7ae1 Mark protected IndexPager properties also as protected in subclasses
I'm intentionally only touching these protected properties and nothing
else, because I believe these are uncontroversial. They should be protected
according to modern SOLID standards, and actually are declared as
protected in the base class. What this patch effectively does is documenting
this fact, but it does not change anything.

Change-Id: I625307b58bd419c4a72e9842b2b46c08ed9b4f8e
2018-12-20 18:25:19 +01:00
Thiemo Kreuz
a88be858ee Fix order on Special:Contributions when timestamps are identical
Please see T200259#4827781 for a longer explanation why this is needed.

Bug: T200259
Change-Id: I1678f7ec994328a96eed208483421be2f82be0ce
2018-12-20 18:12:07 +01:00
Brian Wolff
528042054f Fix some phan-taint-check false positives
Change-Id: Ic5ccbb3f97722476bee7188b83b80cdc652d2a64
2018-09-21 17:27:44 -07:00
Umherirrender
7f68979bec Replace some wfMessage by ContextSource::msg
Change-Id: Ie056af7a002dbbf4e8defc8032bfcc0bdefc6566
2018-08-22 15:42:31 +02:00
Bartosz Dziewoński
eea5d3ee67 Remove incorrect timezone conversion from date parameters
This affects at least Special:Log and Special:Contributions.

The setTimezone() call does not actually change the offset used for
database lookup, because getTimestamp() returns a Unix timestamp,
which by definition does not include timezone information.

We don't actually want to do anything with timezones here. Whether
we like it or not, these date selectors have always used UTC dates.

Follow-up to I8c2cd398d7c7ac68a8f46ee94cb9e7c6beed5694.

Change-Id: Ia034017af5b37da3aa4889d5b7680c8be423126e
2018-07-26 20:13:38 +00:00
Bartosz Dziewoński
249e0c06e4 ReverseChronologicalPager: Fix timezone confusion
(This change is best tested with Special:Log before changes from
38756eae4, since it seems the $mDay/$mMonth/$mYear values are not
directly used anywhere in core after that.)

The setTimezone() call did not actually change the offset used for
database lookup, because getTimestamp() returns a Unix timestamp,
which by definition does not include timezone information.

It did change the offset used for year/month/day fields in the
interface, but it changed it in the wrong direction: instead of
assuming the date is in local timezone and converting to UTC, it
assumed the date is in UTC and converted it to local timezone.

We don't actually want to do anything with timezones here. For better
or worse, the date selectors for pagers have always used UTC dates.
The timezone code was only introduced relatively recently in 53fa809a.

What we really want for the interface is to display the previous
date, relative to the database offset. The interface asks the user
to select the month/date up to which to display things (such as
"May 2018 (and earlier)"), but the database queries use strict
comparison (such as `log_timestamp < '20180601000000'`), so the
database offset is calculated to the next date after selected one.

The incorrect timezone calculation accidentally did so, but only if
the wiki timezone had a negative offset relative to the UTC. If the
wiki was using UTC or a timezone with positive offset, the correction
was not applied, causing the selected date in the interface to move
one day forward from the date that was set.

Bug: T171110
Change-Id: I8c2cd398d7c7ac68a8f46ee94cb9e7c6beed5694
2018-07-26 22:11:52 +02:00
addshore
6ecf8d044d Remove unused $links in TablePager::getNavigationBar
Change-Id: I43ba3390c47e4955704cfd82b16627008f9e6bc8
2018-07-18 19:37:16 +00:00
Umherirrender
130ec2523d Fix PhanTypeMismatchDeclaredParam
Auto fix MediaWiki.Commenting.FunctionComment.DefaultNullTypeParam sniff

Change-Id: I865323fd0295aabd06f3e3c75e0e5043fb31069e
2018-07-07 00:34:30 +00:00
Fomafix
125cbd8c01 Use \u{00A0} instead of &#160; or &nbsp;
Directly use the UTF-8 encoding of the 'NO-BREAK SPACE' (U+00A0) instead of
the HTML/XML entities &#160; or &#xa0; or &nbsp;.

With the UTF-8 character the generated HTML is shorter and better to read.

Also change the special value for the label in HTMLForm from &#160; to
U+00A0 but also support &#160; for backward compability.

Bug: T154300
Change-Id: I882599ac1120789bb4e524c4394870680caca4f4
2018-06-24 01:20:13 +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
Brad Jorsch
2c34fd6e0e Replace uses of each()
It's deprecated in PHP 7.2, may as well replace it now.

I note that, contrary to claims at
https://wiki.php.net/rfc/deprecations_php_7_2#each, none of our uses
were trivially replaceable with foreach.

* wfArrayDiff2_cmp() is processing two arrays by value in parallel.
* MagicWordArray::parseMatch() is doing something funky with the data
  structure returned by preg_match().
* HashRing was using it like "nextKey()", replaced with calls to key()
  and next().
* FormatMetadata and IndexPager were both using it as a shorter way to
  get both key() and current() for the first element in the array. I
  suppose a foreach(){ break; } would do the same, but that's confusing.

Bug: T174354
Change-Id: I36169a04c764fdf1bfd6603395111c6fe0aae5eb
2017-09-20 09:51:28 -04:00
Kunal Mehta
d1cf48a397 build: Update mediawiki/mediawiki-codesniffer to 0.10.1
And auto-fix all errors.

The `<exclude-pattern>` stanzas are now included in the default ruleset
and don't need to be repeated.

Change-Id: I928af549dc88ac2c6cb82058f64c7c7f3111598a
2017-07-22 18:24:09 -07:00
Roan Kattouw
b4ef22f17f RangeChronologicalPager: Don't clear $offset when $this->rangeConds is set
It has the effect of breaking pagination entirely when a date range
is set. Special:Contributions doesn't break this way because it has
its own code clearing start/end when offset is set, but Special:Newfiles
does break.

Change-Id: Ie9b26a4b54ebc608035c942b5bdc6ee26b82bc1e
2017-06-16 16:12:31 -07:00
Geoffrey Mon
53fa809a62 Pager class for filtering by date range
New abstract class RangeChronologicalPager to provide shared date range
filtering capability (with unit tests)

I18n msgs to use as common labels for date range inputs

Expose some ReverseChronologicalParser::getDateCond logic so we can
convert year/month date filters to datestamp date filters

Bug: T120733
Change-Id: I65fdc00368f406f5fa2492600e95e07ce442c165
2017-05-12 14:55:54 +02:00
Ed Sanders
91e49be2a7 OOUI-ificiation of TablePager nav
Depends on next OOUI release for new icons.

Bug: T163715
Change-Id: Ia750131aae52c35181209277c5b951a447db1b5a
2017-05-03 14:34:20 +01:00
Aaron Schulz
488a647831 Move IDatabase/IMaintainableDatabase to Rdbms namespace
Change-Id: If7e8a8ff574661fd827de8bcec11d2c39a687300
2017-03-28 15:32:38 -07:00
Timo Tijhof
3a2a707546 Clean up remaining get_class() uses
* get_class()        -> __CLASS__ (same as self::class)
* get_called_class() -> static::class
* get_class($this)   -> static::class

Change-Id: I1888a1897ecf4548a2e5a67a942e5c080dd7e3d3
2017-03-07 22:03:47 +00:00
Aaron Schulz
e01fd44388 Move ResultWrapper subclasses to Rdbms
Change-Id: I6f3f0e85e268b24c57c537aa6ad8016e0b4cdddb
2017-03-03 00:44:41 +00:00
Kunal Mehta
a57b64436c Use wikimedia/timestamp
Bug: T100924
Depends-On: I0a067367cda6885fa45631ed7c18799d653dc9bf
Change-Id: I69ba64e364df8af089c1c918cdf32f99454e693a
2017-02-28 21:15:38 -08:00
Max Semenik
f23a964170 Fix type annotations
Change-Id: Ib72c98358b2f0b3b73b6f105adea47346373d46d
2016-12-15 14:11:12 -08:00
jenkins-bot
69ae945e8d Merge "Update weblinks in comments from HTTP to HTTPS" 2016-11-08 21:32:00 +00:00
Fomafix
202f695f67 Update weblinks in comments from HTTP to HTTPS
Use HTTPS instead of HTTP where the HTTP link is a redirect to the HTTPS link.

Also update some defect links.

Change-Id: Ic3a5eac910d098ed5c2a21e9f47c9b6ee06b2643
2016-11-07 15:24:46 +01:00
Kunal Mehta
153d117b60 Don't fatal on invalid timestamps
Database::timestamp() intentionally lets errors bubble up, so catch
invalid user-provided timestamps in
ReverseChronologicalPage::getDateCond(), and avoid using an offset in
that case.

Bug: T149257
Change-Id: Ida85eb44b66e8a0166e7f68a101ff094e04b1c8e
2016-11-03 19:09:13 +00:00
Kaldari
c68c3061b6 Partially reverting I8e684f06 to restore some legacy behavior
Apparently some calls to getDateCond() expect it to not set an offset.
Also, removing some of the new tests that no longer work since they
don't pass all the required parameters. (Before I8e684f06, the year
and month were both required parameters.)

Bug: T145597
Change-Id: I3a90b3da48e49ec9723b7100a7d92146154f74e3
2016-09-13 18:32:47 -07:00
Geoffrey Mon
ae2f10b786 Add day to date filter for ReverseChronologicalPager
* ReverseChronologicalPager::getDateCond now accepts a day parameter
* Make year parameter of getDateCond optional (current year used)
* Make month parameter of getDateCond optional (end of year used)
* Tests for ReverseChronologicalPager::getDateCond

Depends-On: I587f1f4402ba2964ff23c0d4b06e41accbe05c10
Bug: T120733
Change-Id: I8e684f067d792b07137341d63cd2e54a18c51a7d
2016-09-12 07:16:40 +00: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
Aaron Schulz
16266edff3 Change "slave" => "replica DB" in /includes
Change-Id: Icb716219c9335ff8fa447b1733d04b71d9712bf9
2016-09-05 21:01:01 +00:00
Amir Sarabadani
efa0d7af44 Clean up array() syntax in docs, part III
Also fixing some typos here and there

Change-Id: I29c29acf87f84ba9993ba75ebf2ad8091d981574
2016-08-13 05:40:40 +04:30
Ricordisamoa
5c20a532b8 Make some TablePager methods actually protected
* getTableClass
* getNavClass
* getSortHeaderClass

Change-Id: I459ca456149635e3300c7ca7cfed4c1edc1c12b1
2016-04-09 06:37:33 +02:00
Reedy
1834ee3d8e Fix numerous class/function casing
Change-Id: I23982bfa0548c9ea3bdb432be7982f1563930715
2016-03-18 23:14:49 +00: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
Aaron Schulz
7c07943eab Update more docs and type hints to use IDatabase
Change-Id: I8c8d85b32a8aba21e14d2a2dde4c25eb509186c1
2015-10-06 18:49:52 -07:00
addshore
72bd5c9e56 Add protected getCurrentRow to TablePager
This makes unit testing TablePagers easier

Change-Id: I899ec6b056fb1f007a6caf0be320324cffe08326
2015-08-29 12:13:47 +00:00
umherirrender
393adfb169 Timestamp from Year/Month selector on forms should be wiki time
When searching for a year/month with the year/month selector on
Special:Contributions or action=history the given time should be treated
as wiki time and therefore needs adjust to UTC before search in the
Database.
This has no effect on wikis with UTC like enwiki, but for example on
dewiki with an offset from 1hour/2hour.

Change-Id: Iccd41d19a360827b9c80b66582ca0daa7ed7576c
2015-05-15 15:57:28 +02:00
Aaron Schulz
69998a7e0d Converted some profiling to scopedProfileIn
Change-Id: I63eb315155ef03d20a2d228c2be07a24baa0c278
2015-01-07 21:03:02 -08:00
umherirrender
df24b7209d Fixed spacing
- Added newline at end of file
- Removed double spaces/newlines
- Added space after if/function and parentheses/brackets
- Removed space before comma/cast
- Fixed indent of some lines

Change-Id: I29867ffdffdfb7d2b56997e9393497c7dc12f7d3
2014-09-29 20:46:19 +02:00
Kunal Mehta
25fa587753 TablePager: Use wfScript() instead of $wgScript
Change-Id: Ib12bd3dfa102dc673789c27506becc2fd8138f56
2014-09-13 07:04:34 +00:00
Bartosz Dziewoński
6a637fb0bc IndexPager: Introduce constants for values of $mDefaultDirection
I've spent several hours looking at related code and I still can't
remember which direction is 'true' and which is 'false'.

Change-Id: I58694f7a0892c986e7215f59b56b014cece8d40d
2014-09-03 19:54:34 +02:00
Bartosz Dziewoński
987a860df4 TablePager: Redo arrow icons from scratch as CSS backgrounds
Redrawn the images with SVG versions.

Intentionally did not preserve the value of the 'alt' attribute of the old
images, it doesn't seem very useful to me. Instead, added 'title'
attributes on the sort links that describe their action. This should be
more useful than the old version for both visual and aural mediums.

Bug: 69277
Change-Id: Ibaec75e81d3eb8338d911ac84d91570047f475f5
2014-08-31 00:48:45 +02:00
Bartosz Dziewoński
69a039aeeb IndexPager: Don't generate rel=first and rel=last
These values for the "rel" attribute (aliases for 'begin' and 'end',
respectively) have only appeared as proposals for the HTML4
specification, but were then explicitly dropped.

The story of them and more links are available on
<http://microformats.org/wiki/existing-rel-values> (search for
'first', 'last', 'begin', 'end'). The gist is that they were
intentionally dropped and therefore should not be used.

Change-Id: I33afd1364bf9ccf79c11a2a050ad0c4ff52c447a
2014-08-31 00:48:44 +02:00