Commit graph

112 commits

Author SHA1 Message Date
Sam Smith 8f5000f346 Remove Popups instrumentation
Bug: T267211
Change-Id: I640ab367cd235ab8da7dd70dbef7ae9076712e84
2021-07-29 17:01:01 +00:00
Alexander Vorwerk 35462639c3 Avoid using User::getBoolOption()
User::getBoolOption() is deprecated and should be replaced with
UserOptionsLookup::getBoolOption()

Bug: T277600
Change-Id: I9a2118a6342bd5f145174428dcfb518cba4e439b
2021-06-06 16:44:20 +02:00
jenkins-bot 26ae1842c1 Merge "Avoid using User::setOption()" 2021-06-03 20:04:41 +00:00
anjali041 81bb920e2b Avoid using User::setOption()
User::setOption() is deprecated and should be replaced with UserOptionsManager::setOption()

Bug: T277818
Change-Id: I5698b4422755a921c9c9c01ce29084ebfe5f5385
2021-06-02 12:21:10 +00:00
jenkins-bot b84f12e76a Merge "Rearrange PopupContext code for readability" 2021-05-22 07:10:52 +00:00
Umherirrender 0f087ce5e9 build: Updating composer dependencies
* php-parallel-lint/php-parallel-lint: 1.0.0 → 1.3.0
* mediawiki/mediawiki-codesniffer: 35.0.0 → 36.0.0
* mediawiki/minus-x: 1.1.0 → 1.1.1

Libup is broken on the build steps due to different node versions

Change-Id: I28aefe77365b9812f9cc0f9e5177f45e9f5c2cc2
2021-05-19 19:38:42 +02:00
Thiemo Kreuz 7c3f369019 Rearrange PopupContext code for readability
For example:
* Anonymous users are a critical exception. They must always
  load the module.
* Otherwise check if one preview type is active.
* Prefer isRegistered() over isAnon(), because isRegistered()
  is part of the UserIdentity interface.

Change-Id: Iea7e3bb7ef01bd72ccbd1fc5e574437f6dc42aa2
2021-05-06 16:44:41 +02:00
jenkins-bot e9fac7bcc5 Merge "Enable ReferencePreviews for old users by default" 2021-05-05 15:54:15 +00:00
Andrew Kostka 1fce62ca7b Enable reference previews for anonymous users when not in beta
Change-Id: I605bc79626999c2e65cdceaa47dd6c4479a3d249
2021-05-05 16:43:25 +02:00
Thiemo Kreuz 5b6ed0e580 Enable ReferencePreviews for old users by default
The behavior for PagePreviews – implemented years ago – was
different. For old users it was disabled by default. This
behavior is wrong for ReferencePreviews.

Bug: T271206
Change-Id: I28c43ab3348ffdc27b068fc1ac1d6a6a06ee90a6
2021-05-05 14:32:15 +02:00
Thiemo Kreuz 3a00223a36 Separate reference preview settings in beta & non-beta
This is the smallest possible patch for a backport.

While it seems there is zero technical reason to limit user
option keys to lowercase with dashes, it's best-practice.
Same as message keys.

Bug: T281235
Change-Id: Ia4a45cf4459543c81b23b757ae9c2cfaf9676894
2021-04-27 16:15:17 +02:00
Thiemo Kreuz c281bb9302 Clean up code enabling individual popup types
We still have 2 different mechanisms in place, maybe even 3:
* We simplify the CSS selector when we know a popup type is
  disabled, and it's impossible an anonymous user can enable it
  at run-time.
* We create that "initiallyEnabled" map that allows anonymous
  users to toggle the individual popup types at run-time.
* This map is also used to check if the footer link should be
  shown.
* There is also a wgPopupsReferencePreviews global that acts as
  a "kill switch". However, this is not a pure feature flag,
  but incorporates the user setting for registered users. This
  is currently partly redundant (checking
  `mw.user.options.get( 'popupsreferencepreviews' )` does the
  same) and can be removed later when the feature flag is not
  needed any more.

The footer link currently acts odd because anonymous users are
unable to enable ReferencePreviews, but get the footer link.

This patch introduces a 3-state model:
* `true` acts as before.
* `false` means a popup type is disabled, but anonymous users
  can enable it (i.e. this is the opt-out behavior for anonymous
  users).
* `null` means a popup type is not available at run-time, for
  nobody. Anonymous users can't do anything about this.
  Registered users must leave the page and change a setting.

Bug: T277640
Change-Id: Id8d1396c09cf0f706034a66f9cd3c880a8b33df8
2021-04-21 19:38:25 +02:00
Thiemo Kreuz e19b557227 Merge duplicate ReferencePreviews Beta feature flag
Change-Id: Ia7f1c9128460bc5a139e37eb16fff649e80cd20f
2021-04-21 10:46:05 +02:00
Andrew Kostka e4e07e509a Separate page and reference preview preferences
Bug: T277638
Change-Id: I8144625e0d3a2626511f35d4e92d082b6fa44bb4
2021-03-29 14:09:27 +02:00
WMDE-Fisch 97538eb9e1 Add tests for bitmask code
Bug: T276716
Change-Id: I7c21e909f121217e43bf5072061bda422f390693
2021-03-11 14:05:21 +01:00
WMDE-Fisch 58f820009e Use flags to represent settings
To reduce size of code added to the <head> and increase performance.
The increased bundlesize is still less than the size spared bytes in
ResourceLoaderGetConfigVars. - But nevertheless the main gain is loading
less in the <head> anyways.

To avoid further complexity in the code, the bitmask is converted to
the according config setting early on instead of adding checks on the
bitmask all over the place.

Tests will be added in follow ups.

Bug: T276716
Change-Id: Ib4f82bed58295b25f0a41cb37e36244e45f16317
2021-03-11 13:38:06 +01:00
Andrew Kostka 82d54945e4 Combine page and reference preview preferences
Update copy and remove unnecessary reference preview preference
in favor of using the default preference. It seems there is no
stable method to link to the subsections on the preference page
for gadgets. So in all cases does the link just point to the
gadgets pref page.

These changes should only be visible when reference previews
are no longer marked as a beta feature.

Bug: T265709
Change-Id: I7b8ab91331092ada04b230315373548673b9272c
2021-02-25 10:21:16 +00:00
Svantje Lilienthal 1962372a44 Add cogwheel to disable ReferencePreviews
I added the common styling for the setting icon to the popup.less
and removed the now empty pagePreview.less.

Bug: T234205
Change-Id: I2a82831bc71a4208c4b66c18e2a4613127c43e1f
2021-02-16 15:39:43 +01:00
WMDE-Fisch df7481af55 Adjust TODO comment to recent needs in the configuration setup
Change-Id: I9e565dddc6af8ca55613358c6d2eb0ceb58dbd0d
2020-12-14 11:52:06 +01:00
Vedmaka ff2ba9ebf5 Adds "$wgPopupsTextExtractsIntroOnly" option to control "intro" parameters for TextExtracts API request
Change-Id: I84f91ab0752bbd4a5b1ee159b7cbe1388f942f24
2020-12-07 15:00:29 -08:00
jenkins-bot 46ece02214 Merge "Use a checkbox for the preference" 2020-11-17 12:31:32 +00:00
Svantje Lilienthal 0b6c859a2b hide reference previews when reference tooltip gadget is active
Change-Id: I5f43270bfeba944c05dc09adf771ed07057237c7
2020-11-16 18:36:04 +01:00
Bartosz Dziewoński 310d587732 Use a checkbox for the preference
Bug: T174726
Change-Id: Ie7dff009adc97653fdb3106f58ea97d26da49f49
2020-10-28 20:40:25 +01:00
Ammar Abdulhamid 5e405eb2f2 Popups: Rename new config variable
In this patch we introduce a new config variable and update its default
to be the same as the production value of $wgPopupsPageBlacklist.

When this code is deployed everywhere, we will remove wgPopupsPageBlacklist
from mediawiki config and defer to the Popups extension as the source of
truth from now on.

Bug: T254676
Change-Id: Ifebdcf8f5eec854a2b947dc390eaf47704a5c5eb
2020-07-07 09:47:59 -07:00
Thiemo Kreuz 092e2a4959 Talk about "exclusions" instead of "blacklists"
AVoid the term if possible, in all internal code. The only remaining
use of the word is in the public $wgPopupsPageBlacklist config
variable.

Change-Id: Ib238731270f473ad44fcff13df617a70433f2452
2020-06-09 08:56:06 +02:00
DannyS712 751e05160a Fix PSR12.Properties.ConstantVisibility.NotFound
Bug: T253169
Change-Id: I6504b960d34726d94c79b68e186a4206a3cf386a
2020-05-19 23:38:59 +00:00
Umherirrender 9fa7f2071c build: Updating mediawiki/mediawiki-codesniffer to 29.0.0
Change-Id: Ifb739130872b192b0fee54351555b65c3099981e
2020-01-26 20:22:03 +01:00
Stephen Niedzielski 36935fe1f3 [hygiene] move ServiceWirings.php to ServiceWiring.php
Remove pluralization from the service wiring filename for consistency
with similar files in other Web repos. There are multiple services in
this file but the point of distinction doesn't seem worthwhile.

Change-Id: I6ff4f9caf66a6156f6aa6a8b808f51c356df3414
2020-01-14 08:49:11 -07:00
Thiemo Kreuz 776f4af6c5 Add tests case for user preferences while in Beta mode
This is a direct follow up for I4d31805. Note the previous patch was
only testing the code path when Beta is disabled. But the bug was about
what happens when Beta is enabled. This is now properly covered by
these tests.

Bug: T240947
Change-Id: I54c5e9751e14a94808e85d935e1972eea0395002
2019-12-17 16:27:26 +01:00
Thiemo Kreuz 5752c2538e Fix initial preferences for newly created user accounts
It appears like we accidentially copy-pasted the behavior for
PagePreviews and made ReferencePreviews behave the same, not taking
into account that the later feature is in Beta mode.

Bug: T240947
Change-Id: I4d31805ee9b2045c49c7ab4179c5a4adbcba0394
2019-12-17 13:37:11 +00:00
Thiemo Kreuz e5b36f6270 Make use of User::getBoolOption() where appropriate
Bug: T233813
Change-Id: I804c34817e093fe7e507e5379647b52f187a686b
2019-10-22 09:58:47 +02:00
Thiemo Kreuz 4d016984c3 Rename PHP constant for ReferencePreview preference
This user option is currently used in the BetaFeatures tab, but we
are going to change this with T233813. We are going to make this a
regular preference on the rendering tab, and would like to keep the
name "popupsreferencepreviews" along with all decisions the users
previously made.

Bug: T233813
Change-Id: I703d8a1a4eee2e7dccc9c597a846cf58a973ee13
2019-10-22 09:25:02 +02:00
Thiemo Kreuz 71ac670d9e Add visibility keywords to all constants in PHP code
Change-Id: I384cffed670c7e845465e3e18808e267327011ed
2019-10-22 07:10:31 +00:00
Thiemo Kreuz fe32c48268 Replace all mock builders with createMock() calls
This was motivated by two things:

1. Notice the bad class name in UserPreferencesChangeHandlerTest. This
was possible because the default mock builder does not check if a class
exists, *and* there was no type hint in place. createMock() *does* check
if a class exists.

2. We are free to use createMock() from PHPUnit 5+ now. It's not only
shorter but more strict and reliable.

Change-Id: I301a171d587026eab0a62575ab2fdbfd7733c661
2019-10-18 14:31:10 +00:00
Thiemo Kreuz a63a1cf91c Split user preferences for Page and Reference previews
Bug: T233813
Change-Id: I89205658c561961b90abaa133a004e54beebfab5
2019-10-17 11:21:21 +02:00
Thiemo Kreuz 55505e786b Refactor PopupsHooks for easier removal and/or expansion
This is done in preparation for the main patch I8920565. This patch
here is not supposed to change anything. Tests should prove this.

Bug: T233813
Change-Id: I0bdc35dc8cb7bca643f45734b30e374f26b24ad2
2019-10-16 13:33:09 +00:00
DannyS712 cd21c7a2f2 Convert mediawiki links from http to https
Bug: T189687
Change-Id: I87704d1df3698d38b594b54a59b4ed249acb592e
2019-04-19 00:02:49 +00:00
Timo Tijhof 81b94eff0a Remove redundant wgPopupsShouldSendModuleToUser variable
It is set based on the same conditional that loads the code,
thus checking it inside the loaded code is a no-op and adds
extra HTML to the <head> that blocks text/layout rendering and
delays fetching of Popups JS.

Bug: T219342
Change-Id: I9c1f4b3861ce2cecb654eb0a78469a616730a40b
2019-04-09 18:31:35 +00:00
Thiemo Kreuz e32fc4914e Add some missing newlines to separate PHP code better
I believe these additional newlines all make the code easier to read.
It's easier to see what belongs together, and what is a separate thing.
I found the Squiz.WhiteSpace.FunctionSpacing sniff very helpful to
enforce this code style. We enabled this already in almost all WMDE
codebases. It is not yet part of the upstream MediaWiki rule set, but
discussed.

Change-Id: Ibdf788529b28637bf98e7940c2516852c3afcef7
2019-03-11 11:33:13 +01:00
jenkins-bot e341ec8268 Merge "Clean up PHPDoc documentation tags for constants" 2019-03-07 21:51:26 +00:00
Stephen Niedzielski 7c4836afdf Hygiene: fix typo in ServiceWirings function arg
Change-Id: I4f4ca2f1c1943928475bfcb42092cb26ab7ed712
2019-02-26 15:39:18 -07:00
jenkins-bot ac6e03cc0d Merge "Update documentation and signatures of hook handlers" 2019-02-26 22:30:57 +00:00
jenkins-bot 33e29e9041 Merge "Remove unused $config constructor parameter from loggers" 2019-02-26 22:00:57 +00:00
Thiemo Kreuz 1697cb9a65 Update documentation and signatures of hook handlers
* Explain the difference between the two hooks that both set config vars.

* Remove by-ref & that are not needed. This is a non-breaking change.
Even if the code calling a hook handler provides a variable by reference,
the hook handler being called does not need to require a reference.
Removing these & makes the code less confusing and easier to read.

* Replace an OutputPage type hint with a more narrow IContextSource.
That's all this code actually needs to know. It doesn't need access to
the entire OutputPage, so it doesn't need to require it.

* Update the signature of the ResourceLoaderGetConfigVars handler to
match the caller.

Bug: T215896
Change-Id: Ie1e4b50cd954812f71dd628003b8e9d40fdf5fe8
2019-02-26 17:45:39 +00:00
jenkins-bot 909585c197 Merge "Remove object passed by references to method" 2019-02-26 11:32:13 +00:00
Derick Alangi f3d415fd27 Remove object passed by references to method
-> Objects by default as passed by reference so removed & in front
   method header.

In addition, updated the PHPDoc comments to reflect the changes.

Change-Id: I69ad2090205f6bd694744779d2c46a3506c85378
2019-02-26 11:26:07 +00:00
Thiemo Kreuz 54af069999 Remove unused $config constructor parameter from loggers
As suggested in I69ad209.

As far as I can tell the idea was to be able to pass logger-specific
configuration to the logger factory, e.g. to be able to toggle certain
things the loggers would do. But this is not used at the moment. There
is not much value in keeping unused code around. It can esaily be
introduced again later when it turns out it is needed.

Furthermore, I'm told most of the logging functionality should be
removed anyway. See T193051.

Change-Id: I6b1ddb2a65eacc0e096f2ba44922d63e63212a65
2019-02-26 12:20:59 +01:00
Thiemo Kreuz bffa3178d5 Clean up PHPDoc documentation tags for constants
Our documentation generator Doxygen is not able to understand @var tags
on constants. A constant is neither a "variable", nor is it possibly to
specify an allowed type for a constant. The type of a constant is strictly
derived from it's value. There is no way to change it, other than changing
the constant itself. There is not much value in repeating the type either.
If it's critical to know the type of a constant (which is a very rare
situation), that should be better explained in the comment.

Doxygen strips all @… tags it does not understand, and renders everything
else as a plain string. This makes it possible to use something like:

/**
 * @const Description…
 */

But this is not different from:

/**
 * Description…
 */

Change-Id: I4531d4f6b2ab2aca7a62f13f10a655f31c4d6a7a
2019-02-26 09:56:07 +01:00
Andrew Kostka f91c160214 Add a beta feature switch for reference previews
Bug: T215896
Change-Id: I6a4cc2103d594dc11f62da247891d3f190619899
2019-02-25 20:38:12 +01:00
Derick Alangi 523f207ccd Use $config instead of $conf for consistency purposes
So $config is used instead of $conf for consistency and this
is how it's used across many many Wikimedia repos (exts) and
even in core.

Change-Id: Ia8e7335bf6892628e0a8b5d901776d726a8ad743
2019-02-11 13:33:37 +01:00