Commit graph

74 commits

Author SHA1 Message Date
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
Thiemo Kreuz 13015ad317 Fix a series of minor documentation issues in PHP code
E.g. type hints that have been missing, missing indention, and such.

Change-Id: I34610a03ad69d7988e9976a08a289c64121420ca
2019-02-01 09:42:14 +01:00
Thiemo Kreuz 7ca5d1fc9b Update PHPDocs and strict typing for array parameters
This does make generic `array` type hints more specific when possible.

I'm also applying my personal best practice to not have any @return
documentation on test @dataProviders. These don't provide any useful
information, and can't. The best type we could use is `@return array[]`,
but that would be the same for every single data provider. Copy pasting
these comments around is of no real value.

Also it was already inconsistent as some did not had this comment.

Change-Id: Id401c7e32493b6a9faaf6d47cddc01e2227102af
2019-01-24 15:44:26 +01:00
Thiemo Kreuz 485acf1488 Add feature flag to disable reference previews by default
This is a prerequisit for the later patch Ie0ccb03.

Any JavaScript code can check this feature flag via
mw.config.get( 'wgPopupsReferencePreviews' )

Bug: T213415
Change-Id: I17687c62cc8d738a4eb41738c9ce6662a5ec68d8
2019-01-21 11:24:33 +01:00
Thiemo Kreuz 84ef742bc2 Simplify PopupsContext::areDependenciesMet
Change-Id: I4d545f27e05451e44945217520fdbea77cfd881a
2019-01-16 20:20:47 +00:00
Thiemo Kreuz 944153c15f Add @var type hints to all MediaWikiServices::getService calls
This makes the following code work much better in IDEs, e.g. it's now
possible to click method names and actually go there.

Change-Id: Iddbe838f1402c5017ffeb3bc03b4a017b05d8b02
2019-01-16 20:01:29 +00:00
Thiemo Kreuz f67b7b0a66 Remove non-helpful auto-generated comments on constructors
The code literally explains itself. The comments don't add anything
to this. They are more distracting because one must read them first
to understand they don't contain anything.

Change-Id: I6f152962ec634ae15d2bff4472e332453cb9b0bf
2019-01-16 15:34:19 +01:00
Thiemo Kreuz 6ed00b924a Add some more missing @covers tags
I figured a single "@covers ::__construct" in PopupsContextTest should
be enough, especially since this constructor is super trivial.

There is nothing to test in NullLogger. I also removed the duplicated
documentation as it does not really apply, and is still available in the
base class.

Change-Id: I9a2e4b06e5bfd015efa4a92ba802c942290ec49d
2018-12-20 15:31:14 +00:00
Piotr Miazga df9e724d89 Fix failing isTranslatedTitleBlacklistedTest
Somhow the testIsTranslatedTitleBlacklisted start to fail, the test
looks like it's broken but because of some reason it used to work.
For now let me fix the test because it blocks merged, and later
I'll try to investigate whats wrong.

Changes:
 - testIsTranslatedTitleBlacklisted() has to define blacklisted
 pages in canonical way (eg: Special:Preferences, not in a language
 variant)
 - use MediaWikiServices::getSpecialPageFactory() as
 SpecialPageFactory static calls are deprectated

Bug: T203522
Change-Id: I0db1481c96c9c0e27364d028a57c1178865741ba
2018-09-05 21:04:52 +02:00
Umherirrender c65c1d9f95 Declare class fields in PopupsContext
Change-Id: If5754d49d4abdcd946e7958e22eede7d33008851
2018-08-07 09:48:23 +02:00
Piotr Miazga 0837535bdd Always set the PagePreviews visibility state
Changes:
 - ignore autocreated flag and always set the popups visilibity state
 CentralAuth will create users with `autocreated=on` when user logs
 into different wikis
 - do not call saveSettings(). AuthManager will call
 $user->saveSettings() s after calling all hooks.

Bug: T191888
Change-Id: Iac753ebbaaf175636fdc3e20d8f37883771c33d2
2018-06-11 21:46:03 +02:00
jenkins-bot 8ea676892f Merge "Properly escape messages passed to HTMLForm" 2018-05-29 10:17:42 +00:00
jenkins-bot 4c397700d1 Merge "Change the PopupsVisibility state to visible to match anon experience" 2018-05-29 08:14:28 +00:00
Brion Vibber 9602856226 Fix for changes to preferences form
The PreferencesFormPreSave hook now may return any HTMLForm
subclass, not just a PreferencesForm. It may be the new
PreferencesFormLegacy, or the future PreferrencesFormOOUI.

Change the function signature to accept any HTMLForm,
which seems to fix saving of preferences.

Bug: T195580
Change-Id: I41e37d78d87ab8965995c6e19ef76db87f7616fa
2018-05-25 09:52:48 -07:00
Kunal Mehta 87fac42511 Properly escape messages passed to HTMLForm
THe messages in 'options' need to be HTML escaped.

Spotted by the phan-taint-check plugin.

Change-Id: I1e207e5ca644551ae56cdd484f5f29267b6d764f
2018-05-20 13:41:33 -07:00
Thiemo Kreuz 865bd524f2 Add missing "public" visibility in PopupsHooks.php
Public is the default, and hook handlers must be public. I assume this
was nothing but a mistake.

Change-Id: I20eedfd8c4cb954db770afdda3f373e272530b82
2018-05-20 21:13:36 +02:00
Piotr Miazga a492d5f609 Change the PopupsVisibility state to visible to match anon experience
PagePreviews are visible to anonymous users, we would like to match
the same experience, when user creates a new account. On account
creation we mark PagePreviews settings to ON or OFF (configurable
via PopupsOptInStateForNewAccounts settings). With that approach
we can provide the best experience for new users, and keep existing
users happy (not enabling feature by default for everyone).

Bug: T191888
Change-Id: I39f42aa7268ce59c51f038048025ccf1bdf16481
2018-05-10 00:57:44 +02:00
jdlrobson 912402e840 Remove A/B testing code
No longer needed. We can't turn something off again for people
now they expect it to exist.

Clarified usage instructions of PopupsEventLogging to make sure
it's more scary given the implications

Bug: T173952
Change-Id: I7be005b79da498d8e7b7df8f18b60c1327636a2c
2018-05-07 12:37:41 -07:00
jdlrobson 4e3282e5ff Remove BetaFeature code
Popups is out of beta feature and this code is no longer needed.
Removing code is the happiest activity a developer can do.

Other changes:
* Remove redundant type field on extension.json
(If not set, the extension will default to the "other" section.)
* Repurpose `name` with `namemsg` and make use of existing i18n
messages

Bug: T193053
Change-Id: Iea832cd1f37b0e7df6ff95efd66e4a1ff2a9004e
2018-04-26 15:51:48 -07:00
Piotr Miazga 915a9708fb PopupsContext::areDependenciesMet should respect PopupsGateway config
On all wikis Popups use Restbase as default gateway. In that case we
do not require the TextExtracts nor PageImages extensions. Code should
reflect that.

Bug: T190818
Change-Id: If4ce8f709b2ca1bb3cc381afa5e80e978adf2498
2018-03-28 16:31:15 -07:00
Stephen Niedzielski 4dd9df12eb Doc: update some of the popups / preview terminology
Bug: T165036
Change-Id: Id75543d4d886e4cca8278baaf4f4a21c8e4389b7
2018-03-23 11:18:26 +01:00
jdlrobson f5f21a8d09 RESTBase url is configurable
Allow developers to use different endpoints for summaries
= developer happiness

This is useful for the following use cases:
* A developer wants to test against a production endpoint via
CORS
* A developer has setup an API where REST is hosted elsewhere
e.g. http://localhost:6927/en.wikipedia.org/v1/
* A user wants to create their own REST summary compatible
endpoint
* A wiki e.g. wikidata wants to use a different endpoint which is compatible
with the summary endpoint.

We are unlikely to use it ourselves on Wikimedia wikis (the
default should suffice) but this will be a powerful tool for

When not configured this will continue to work as per normal

Change-Id: I8a7e12fbc43cddbac678e0d7b81d1e877b747b22
2018-03-09 16:15:19 +00:00
jdlrobson a702c0f499 Capture page view-like interactions
* New action added PREVIEW_SEEN
* The action will be used to signal that a page view needs
to be recorded.
* PREVIEW_SEEN is a delayed action which is triggered
as a side-effect of the previewShow action. It is only dispatched
if the user is still previewing the same card and the page
related to the card has preview type `page`
* The pageview changelistener is added when
$wgPopupsVirtualPageViews is set to true.
* The page view changelistener listens for page views and logs
them using EventLogging when needed using
https://meta.wikimedia.org/wiki/Schema:VirtualPageView

Note:
* Currently if a user has enabled the DNT header, the
event will not be logged. There is ongoing discussion on the
ticket and fixing this will be addressed separately.
* Only title and referrer are logged in the initial version.
The task demands that "namespace" is logged but this information
is not provided by the summary endpoints we use so will need
to be added later (if indeed needed) either via a change to that
endpoint of by using JavaScript to parse the URL.

Bug: T184793
Change-Id: Id1fe34e4bdada3a41f0d888a753af366d4756590
2018-02-16 23:03:33 +00:00
libraryupgrader cc611bbc85 build: Updating mediawiki/mediawiki-codesniffer to 13.0.0
Change-Id: Ibea048de7fc5f703d7ebf54d7844e35af8eac8d8
2017-09-24 12:31:23 +00:00
Bartosz Dziewoński 2b637e42ef Improve how we render help messages in preferences
* The 'help' parameter expects a string, not a Message object. It
  seemed to be working, but caused fatals when switching the
  preferences form to the OOUI implementation (T117781).
* Use 'help-message' instead, which also avoids using the global
  request context for Message objects.

Bug: T117781
Change-Id: I5b2e44df35a2696da0e7ba8394eccf41914f6dda
2017-09-12 17:07:37 +00:00
Quiddity 311bf8f683 Use Special:MyLanguage in help link for betafeature info
Bug: T145904
Change-Id: I59c0b952cb44b31d0918c3d4659d47f2ddec7761
2017-08-26 20:28:59 +00:00
Piotr Miazga 0de054cd79 Use canonical name for NS_SPECIAL titles when checking the blacklist
Changes
 - when verifying title use canonical names for pages in
 special namespace
 - improve unit tests to verify canonical names and translated titles

Bug: T170169
Change-Id: I49592133eb8286eacf04fd3034df091f7ef2aa50
2017-08-25 15:56:02 +02:00
Timo Tijhof 55f075bf11 Remove aborting of BeforePageDisplay hook
This caused random extensions to not be able to load any ResourceLoader
modules (or do other things) on a random subset of pages and wikis.

Follows-up 29770a3.

Bug: T173411
Change-Id: I8dfc1085cb7d902f9e9be8a71324dc4cd850a500
2017-08-18 16:38:42 -07:00
jdlrobson e4e9bb3bd6 Popups A/B test infrastructure
Introduce PopupsAnonsExperimentalGroupSize config variable. This defines
a population size who will be subject to experimentation. If the group
size is undefined or 0 (default) and PopupsBetaFeature is false
(default value) Popups will be enabled for everyone. If it is any other
value, half that group will see page previews.

Drop the config variable PopupsSchemaSamplingRate - we will now only
EventLog when an experiment is occuring. This means we can simplify the
MWEventLogger class as shouldLog will always be truthy. Given server
side eventlogging is only used for preference changes
traffic should be low and not need sampling.

Introduce getUserBucket which determines whether a user is in a bucket
on, off or control based on the value of
PopupsAnonsExperimentalGroupSize. Add tests showing how these
buckets are calculated.

Caution:
A kill switch wgPopupsEventLogging is provided for safety.
It defaults to false. Before merging, please check if any config changes
are necessary.

Bug: T171853
Change-Id: If2a0c5fceae78262c44cb522af38a925cc5919d3
2017-08-17 21:07:07 +00:00
Kunal Mehta 05fafbf8ba build: Updating mediawiki/mediawiki-codesniffer to 0.11.0
Change-Id: I7b00bf0beb47f54c4543de0d605c80ebdd6cdb4d
2017-08-11 00:21:26 -04:00
Umherirrender afb2db82ad Improve some parameter docs
Change-Id: Ic78a889eb7374731a282312c9eadb701483ae298
2017-08-10 13:24:00 +02:00
Baha 29770a3ff7 Disable Previews on blacklisted pages
Introduce a config variable `PopupsPageBlacklist`. Previews code won't
be shipped to pages listed in the config variable.

Bug: T170169
Change-Id: Ia8342b55c682f444ba79e959dcc1180527a31374
2017-07-31 09:10:30 -04:00
Piotr Miazga 3d0c5b1cc3 Hygiene: Dependency Injection for Popups
Changes:
 - removed ugly PopupsContext::getInstance
 - removed ugly PopupsContextTestWrapper helper
 - defined all services inside ServiceWirings
 - fixed unit tests to test classes directly or use MediawikiServices

Change-Id: Ie27e28bb07aebe01014848c290369b1b1f098e9b
2017-07-24 22:41:28 +00:00
Kunal Mehta 9dfa3e5ee5 build: Updating mediawiki/mediawiki-codesniffer to 0.10.1
Change-Id: I835fadf053efea56a3037d7b64af8feca12f9c0f
2017-07-23 00:35:36 -07:00
Piotr Miazga c0052fcb08 Re-enable MediaWiki.Commenting.FunctionComment.MissingDocumentationPublic sniff
Bug: T168384
Change-Id: I4d4681121df974a8471d7c4c8df8a6158f8df22a
2017-07-13 21:14:29 +02:00
jenkins-bot 8ea2211719 Merge "Re-enable MediaWiki.Commenting.FunctionComment.MissingReturn sniff" 2017-07-13 17:42:22 +00:00
jenkins-bot 22d9ef3e24 Merge "Re-enable MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment sniff" 2017-07-13 17:42:21 +00:00
Piotr Miazga 75ef7c4f93 Re-enable MediaWiki.Commenting.FunctionComment.MissingReturn sniff
Bug: T168384
Change-Id: I8d7b750503ca9c951267a948862c3685ea036100
2017-07-13 15:47:00 +02:00
Piotr Miazga 5b62bc625b Re-enable MediaWiki.Commenting.FunctionComment.MissingParamTag sniff
Changes also solve the MediaWiki.Commenting.FunctionComment.ParamNameNoMatch
sniff

Bug: T168384
Change-Id: Idd80e42943a57a4b6211c50a4aac2f1d20e6232d
2017-07-13 10:43:00 +00:00