Commit graph

22 commits

Author SHA1 Message Date
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
a2cad5be15 Remove unnecesary else blocks
Change-Id: Ic11e0e6b86557cbffcc5faa54de218b4676b4712
2018-09-24 14:08:31 +01:00
Umherirrender
130ec2523d Fix PhanTypeMismatchDeclaredParam
Auto fix MediaWiki.Commenting.FunctionComment.DefaultNullTypeParam sniff

Change-Id: I865323fd0295aabd06f3e3c75e0e5043fb31069e
2018-07-07 00:34:30 +00:00
Kunal Mehta
a57b64436c Use wikimedia/timestamp
Bug: T100924
Depends-On: I0a067367cda6885fa45631ed7c18799d653dc9bf
Change-Id: I69ba64e364df8af089c1c918cdf32f99454e693a
2017-02-28 21:15:38 -08:00
Kunal Mehta
8e9d2e93ca Rename Convert*a*bleTimestamp to Convert*i*bleTimestamp
Per the dictionary.

Change-Id: I3dcef9fb020c8c6764ee073111ed8c032e4c5a63
2016-09-21 21:43:32 -07:00
Aaron Schulz
e10f272a05 Split out ConvertableTimestamp class
* Make TimestampException a regular exception.
* Make DatabaseBase use ConvertableTimestamp.

Change-Id: I849737c9c187e8e0c6e080887ec0656e034f80d2
2016-09-16 03:00:09 +00:00
Kunal Mehta
144ca9c5fe MWTimestamp: Allow providing a DateTime object directly
For cases where you already have a DateTime object on hand and want to
use MWTimestamp's formatting code. Since MWTimestamp stores DateTime
objects internally, just set it to the $timestamp member variable.

Change-Id: Ie60392e32743d4d082d2c9347ef68418d5eb86ad
2016-08-21 19:17:01 -07: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
Kunal Mehta
f5bbdeccb9 Move 90e1b22166 release notes to 1.27 file, and fix @since tag
Change-Id: Ie40280f3bd0fb6b6fb817e1af1bca8c1901a6891
2015-11-21 00:13:06 +00:00
Amir E. Aharoni
c37d6549fd Fix Generic.Files.LineLength phpcs failure in 11 files under includes/
Bug: T102614
Change-Id: I0d759be6ef568c2c6f28606d3002484ad77a1830
2015-10-03 17:08:26 +00:00
Vivek Ghaisas
c54766586a Fix issues identified by SpaceBeforeSingleLineComment sniff
Change-Id: I048ccb1fa260e4b7152ca5f09b053defdd72d8f9
2015-09-26 23:06:52 +00:00
gladoscc
90e1b22166 Add MWTimestamp::getTimezoneString(), use it in file revert message
MWTimestamp::getTimezoneString() returns the timezone name as a message,
that supports wiki localization. The code is moved from Parser::pstPass2.

The default file revert message is currently always in UTC.

This patch sets the default timestamp to be in the wiki timezone (similar
to ~~~~). The timezone is passed as a new parameter to the message, with
the date / time parameters being merged and handled by
$wgContentLang->timeanddate

Bug: T36948
Change-Id: I48772f5f3b1635d33b6185776cedfc4ee1882494
2015-09-23 13:38:16 -07:00
Aaron Schulz
1d4fe4abf5 Made MWTimestamp handle UNIX floats
* This avoids "wfTimestamp() fed bogus time value" errors
  that show up in the debug log on page views, do to
  User::getTouched() usage.

Change-Id: I899d6edd2b59c02e618ed14f8d29dea53d866f05
2015-08-20 00:10:11 -07:00
Brian Wolff
5cef81dcc6 Move MWTimestamp::getHumanTimestamp() to Language
We're trying to remove MediaWiki dependencies from MWTimestamp so it can
be split out into a separate library. In addition to getting rid of a
dependency on RequestContext, Language, and User, it makes more logical
sense there anyways.

Bug: T100924
Change-Id: If46eaea42d8a5a808c10f0dc353e181714295a44
2015-05-31 01:53:54 -07:00
Brad Jorsch
e27ff73b32 Reject out-of-range output when converting to TS_MW
TS_MW is a 14-character string "YYYYMMDDHHIISS", and thus cannot
represent timestamps earlier than 00000101000000 or later than
99991231235959.

MWTimestamp should throw an exception if asked to represent out-of-range
times in this format, rather than returning invalid values that are
likely to be truncated by the database.

Bug: T51580
Change-Id: I744e446356f3ed9193dfaaaec5dc81c611dab4a3
2014-12-19 17:06:38 -05:00
Aaron Schulz
e369f66d00 Replace wfRunHooks calls with direct Hooks::run calls
* This avoids the overhead of an extra function call

Change-Id: I8ee996f237fd111873ab51965bded3d91e61e4dd
2014-12-10 12:26:59 -08:00
umherirrender
b1e5d32908 Remove unmatched @param
There is no method parameter for this @param

Change-Id: I42d1e3439e5b767be09920d536bee34bcd017ec9
2014-08-16 22:50:02 +02:00
umherirrender
1c68a1ee86 Cleanup some docs (includes/*.php)
- Swap "$variable type" to "type $variable"
- Added missing types
- Fixed spacing inside docs
- Makes beginning of @param/@return/@var/@throws in capital
- Changed some types to match the more common spelling

Change-Id: I783e4dbfe5f6f98b32b9a03ccf6439e13e132bcc
2014-07-24 19:42:24 +02:00
Alexandre Emsenhuber
dfe47c9ef9 Don't use isset() to check for null
$wgLocalTZoffset is defined in DefaultSettings.php so it is always set.

Change-Id: I86518176b30da4e13f6dbfde8f1c77c8ced58d9f
2014-06-30 21:51:29 +02:00
Siebrand Mazeland
3f0a2a94c9 Make phpcs-strict pass on includes/ (6/~10)
Change-Id: I566183b5d660a55bb3b2aa7186aaed5355ead2c6
2014-05-12 16:46:52 +02:00
umherirrender
8ad1c92441 Fixed some @params documentation (includes/*)
Swapped some "$var type" to "type $var" or added missing types
before the $var. Changed some other types to match the more common
spelling. Makes beginning of some text in captial.
Also added some missing @param.

Change-Id: I7f605aa9e117b5fd80d9b1440864fe526d2b14a5
2014-04-20 21:16:57 +02:00
addshore
853291c7d6 Split Timestamp.php into class and exception files
Change-Id: I438adfe5479a1017baee8f2b663f3fb2e49c685a
2014-01-25 16:24:04 +01:00
Renamed from includes/Timestamp.php (Browse further)