Commit graph

56 commits

Author SHA1 Message Date
Reedy
b1e515e36e Fix even more PSR12.Properties.ConstantVisibility.NotFound
Change-Id: I4a30a44bc33fc98479799438d65342f6529e14f9
2020-05-16 00:51:46 +01:00
Aaron Schulz
6b12696452 Move UIDGenerator code to a service and put it under /libs
All MediaWiki dependencies have been removed or injected.

Change-Id: I01c9e96edd6b03496c1595670967ffa5a4069c9d
2020-02-18 00:20:40 +00:00
Petr Pchelko
4b75c6d2f9 UIDGenerator::getTimestampFromUUIDv1 - replace wfTimestamp
Change-Id: I4f862d59747b643c417b7f6dbda0f939dfdd7e4e
2020-01-21 18:12:53 -08:00
Petr Pchelko
0a8aba4a9a Provide UIDgenerator::getTimestampFromUUIDv1 method
Returns a timestamp in desired format extracted from a UUIDv1.

Change-Id: I009241710654d4b0bc8a1a4b1f353ba815efc9f0
2020-01-21 13:26:13 -08:00
James D. Forrester
4f2d1efdda Coding style: Auto-fix MediaWiki.Classes.UnsortedUseStatements.UnsortedUse
Change-Id: I94a0ae83c65e8ee419bbd1ae1e86ab21ed4d8210
2020-01-10 09:32:25 -08:00
Umherirrender
eb2373dcd1 Set visibility on php magic functions __destruct/sleep/wakeup/get/call
All the magic functions needs public visibility to be callable from php
internals like garbage collector

Change-Id: I1baf04bf8ff787da880d46e4a6daa77f5a6de73f
2019-12-05 18:52:55 +01:00
Fomafix
9cbb8f104d Use https://www.php.net/ instead of https://secure.php.net/
Change-Id: I0acca592c6909e91b28b904da49dcbd6a43cd2a5
2019-04-12 06:44:48 +02:00
Thiemo Kreuz
9314453c93 Make use of the list() feature where it makes sense
This code is functionally identical, but less error prone (not so easy
to forget or mix these numerical indexes).

This patch happens to touch the Parser, which might be a bit scary. We
can remove this file from this patch if you prefer.

Change-Id: I8cbe3a9a6725d1c42b86e67678c1af15fbc5961a
2019-03-24 20:12:23 +00:00
Jakub Vrana
28dbef2f96 Do not pass unused parameter
Found by PHPStan.

Change-Id: I6c33aa29af02b7a5ca01e2e20103e4a873cb722a
2018-12-01 18:08:56 +01:00
jenkins-bot
81cbe34e4d Merge "UIDGenerator: Remove the clock skew problem" 2018-10-05 19:29:40 +00:00
jenkins-bot
a3c780d08c Merge "Clean up UIDGenerator field comments" 2018-10-04 19:53:45 +00:00
Timo Tijhof
e1d7271e42 UIDGenerator: Remove the clock skew problem
In a nutshell:

This commmit removes the use of drifting microtime()
in favour of non-drifting time(). Then, we increase the size of
the counter by x1000, and consider every 1000 increments as 1ms
for the purposes of UUID.

Why:

This means we eliminate the whole code that can produce a fatal
exception when the clock drifts by more than we can wait for,
which puts us in a logical conundrum we can't get out of, hence
it previously fatalled.

Not aborting random end-user requests and jobs is good.

This also means we avoid the vast majority of cases where
MediaWiki would busy-loop for upto 10ms in a likely-to-fail
attempt to sync the clock. This means the method runs faster,
which is a nice win, albeit not the main objective.

Bug: T94522
Change-Id: Ia8a847078ec76d633854db6823a20f0961c80f80
2018-10-04 20:08:44 +01:00
Timo Tijhof
1d0e26cf83 UIDGenerator: Misc clean up
Various miscellaneous clean ups with no change to any of the
logical code. This to make the next commit have a cleaner diff
for easier review.

* Make internal millitime() non-static.

* Improve documentation and add missing @covers annotations.

* Correct getTimestampedID88() documentation to state that
  only two values need to be passed, not three.
  This is significant because the Flow extension is actually
  using this method in a subclass and passes only two values.

Bug: T94522
Change-Id: I2a0c51bea58df4cc0c253c1c10de3ac383f04c8e
2018-10-04 12:44:17 +02:00
Aaron Schulz
d739e97884 Clean up UIDGenerator field comments
Change-Id: I0c6d125ec03a56fe0b3456cff7d498d231315e0d
2018-10-04 01:11:26 -07:00
Fomafix
1472f02b36 Phabricator: Use Tddddd instead of Bug ddddd in comments
Change-Id: Ic9fe03cab270bd6be738af346164ad5d31a0d780
2018-10-04 09:15:02 +02:00
Aaron Schulz
6767035840 Make UID clock drift error have more details.
Change-Id: Ic682e48b06161c2a286f5da9016f4831ee72a31e
2018-10-03 18:03:01 -04:00
petarpetkovic
b7a4e82545 Fix some of the common typos
* supress -> suppress (Except in backup_LogTest.php)
* recomend -> recommend
* becuase -> because
* accross -> across

Bug: T201491
Change-Id: I8faa4e6cc688b3ee204b3f79ab55eb7b65cc1fdd
2018-08-16 00:59:32 +02:00
Reedy
a075271157 Update composer/spdx-licenses to 1.4.0 and mediawiki/mediawiki-codesniffer to 21.0.0
https://github.com/composer/spdx-licenses/compare/1.3.0...1.4.0

Change-Id: I39f7a1310455159866bfed5224536e800befec0d
2018-07-26 17:44:28 +00:00
Bartosz Dziewoński
4fd27f006f Use PHP 5.6 '**' operator instead of 'pow()' function
Change-Id: Ieb22e1dbfcffaa4e7b3dcfabbcc999e5dd59a4bf
2018-05-30 18:05:19 -07:00
Reedy
39f0f919c5 Update suppressWarning()/restoreWarning() calls
Bug: T182273
Change-Id: I9e1b628fe5949ca54258424c2e45b2fb6d491d0f
2018-02-10 08:50:12 +00:00
Chad Horohoe
5c93fabafd Drop XCache support
It was never super popular anyway, APC was always the best option.
The project has no plans to move to PHP7, so it's quickly reaching
its end of life. Oh, and Fedora dropped it from their repos 2 years
ago.

Change-Id: Ia3257e86a6323d8943f04a5c05c72c0bd4c4b0a9
2018-02-07 13:45:40 -08:00
Kunal Mehta
251a0b97e5 Treat phpdbg as run from the command line when checking PHP_SAPI
phpdbg is a gdb-style debugger for PHP that is run from the command
line. However, it has a different PHP_SAPI value, so it was impossible
to run maintenance scripts with it (until now).

To avoid having to check both PHP_SAPI values in a bunch of places,
introduce wfIsCLI() to easily check whether running from the
command-line or not.

We're (CI team) interested in generating code coverage with phpdbg
instead of xdebug, hence this patch.

Bug: T184043
Change-Id: Id1f994ca146d7858cd8bb6ab6cdbb7718ff524fb
2018-01-03 23:00:37 -08:00
Umherirrender
3f1a52805e Use short type bool/int in param documentation
Enable the phpcs sniffs for this and used phpcbf

Change-Id: Iaa36687154ddd2bf663b9dd519f5c99409d37925
2017-08-20 13:20:59 +02:00
Aaron Schulz
82e2c924e4 Remove "@author Aaron Schulz" annotations
Bug: T139301
Change-Id: Ib5248e8e27d60611c7373bce4b29dd5e85aa3489
2017-06-27 15:24:14 -07: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
Sam Wilson
66e215baee Remove spaces after cast operators
This fixes the outstanding mis-spaced cast operators to bring them
into line with the coding standards on mediawiki.org (and with the
more common usage within this codebase).

Bug: T149545
Change-Id: Ib7bcf95bbee83d20c05f6d621ce7b4e1fb58a347
2016-10-31 13:57:39 +00:00
Aaron Schulz
88aa91f84a Clean up some ObjectCache factory callers
* Use services container in more places.
* Undeprecated getLocalServerInstance() since $fallback is not
  handled elsewhere.

Change-Id: Id1fcd1c465d2d92653357523f4225f1c4d1ace2f
2016-10-03 11:44:55 -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
Matthew Flaschen
aa920550a8 Fix comment; these are the least signifincant bits (LSBs), not MSBs
Change-Id: I0102e4969d95c6392a48d4a5b2f2bec096a828a5
2016-01-21 22:13:22 +00:00
jenkins-bot
e1ae107298 Merge "Remove arbitrary newSequentialPerNodeIDs() $count limit" 2015-12-23 20:57:29 +00:00
Aaron Schulz
5ffaa6ae0d Avoid "Unable to set value to APCBagOStuff" exceptions
* This can happen due to incr/add races. Use incrWithInit()
  instead to handle such cases.
* Also made BagOStuff:incrWithInit() return the new value like incr().

Change-Id: I0e3b02a4cff7c20544a9db2eaabd3f61e5a470b1
2015-12-21 20:41:43 -08:00
Aaron Schulz
45330afebd Remove arbitrary newSequentialPerNodeIDs() $count limit
The increment is done in one step, so there is no real reason
to limit this (e.g. performance). It simply makes errors that
can break things.

Bug: T122068
Change-Id: I3278b4ddfe862f8043b6788b3e82e90be730f68c
2015-12-21 11:16:41 -08:00
Aaron Schulz
fb338573ac Fix PHPDoc for getTimeAndDelay()
Change-Id: I7e5b368d13489afec6df56cdc3e71c2e60e07e20
2015-12-05 14:02:46 -08:00
Aaron Schulz
fc428b1670 Fix IDEA error in intervalsSinceGregorianBinary()
Change-Id: Icc90a3050d5d918176dfbb88636a4d9b742fd4b0
2015-12-05 13:34:45 -08:00
Ori Livneh
f5eba88680 Add UUIDv1 function to UIDGenerator
* Added some more unit tests.

Change-Id: Ieb7e66b1319df2e9c6da1518cc9539f276da1838
2015-12-05 20:14:11 +00:00
Aaron Schulz
2fcafc51a2 Remove MWException use from UIDGenerator
Change-Id: Ib0ad346c6c8c4f515b388f63840db4a03b99facb
2015-11-24 15:42:59 -08:00
Reedy
00c426e3c2 Replace wfBaseConvert with Wikimedia\base_convert
Change-Id: Iadab3d018c3559daf79be90edb23d131729bdb68
2015-11-24 22:51:42 +00:00
Timo Tijhof
8a821011ce Remove getLocalServerInstance try/catch in UIDGenerator and DBLockManager
Follows-up 17c91ad610 in which the exception was removed.

Change-Id: If0c8465d0e04f69f29f3f2602dac7ae4538f7542
2015-11-02 22:16:05 +00:00
Aaron Schulz
17c91ad610 Replace newAccelerator() with getLocalServerInstance()
The name is clearer and more consistent, with simpler arguments.

Change-Id: I7205a99ce033e8b086a52cd02c8a721e99c84b1e
2015-11-02 21:39:08 +00:00
Timo Tijhof
79ce51d1c9 objectcache: Make first parameter of newAccelerator optional
Makes it more convenient to use.

Change-Id: I1e11f7a759bd2816e47d1c2453cbe39b8f44b2f0
2015-08-24 23:43:19 +02:00
Kunal Mehta
f6e5079a69 Use mediawiki/at-ease library for suppressing warnings
wfSuppressWarnings() and wfRestoreWarnings() were split out into a
separate library. All usages in core were replaced with the new
functions, and the wf* global functions are marked as deprecated.

Additionally, some uses of @ were replaced due to composer's autoloader
being loaded even earlier.

Ie1234f8c12693408de9b94bf6f84480a90bd4f8e adds the library to
mediawiki/vendor.

Bug: T100923
Change-Id: I5c35079a0a656180852be0ae6b1262d40f6534c4
2015-06-11 18:49:29 +00:00
daniel
7081228214 Start using the Assert helper class for checking parameters.
This introduces https://github.com/wmde/Assert as a dependency,
as discussed in the RFC T91071.

This change uses assertions to check some parameters in some places,
to showcase the main intended use case for assertions in MediaWiki.

Bug: T91071
Change-Id: I93ac39b7c146f10532e37b51d973b59b9c424b2f
2015-05-11 17:54:07 +00:00
Aaron Schulz
6921770414 Updated some try-catch statements: MWException -> Exception
Change-Id: I76601a86e30f4984e3b1a8c8ec5ef5a0f652433a
2015-01-09 17:20:22 -08:00
Reedy
4d9143c7f5 Add lots of @throws
Change-Id: I09d0c13070f966fcf23d2638d8fc1328279a5995
2014-12-24 13:49:20 +00:00
Aaron Schulz
d82ce50741 Fixed UID comment
Change-Id: I2e44bd69f4acafa032e0c4207749008409afcd53
2014-08-27 16:19:11 -07:00
umherirrender
21e0c1c533 Correct variable names in @param to match method declarations
Some @param have a typo in the variable name,
some @param's were in wrong order.

Change-Id: Ie25806831027112b398f6f4a909c59147ac3a5fa
2014-08-13 21:48:28 +02:00
umherirrender
d435aa2c58 Fixed some @params documentation (includes/utils)
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.

Change-Id: I9bd4ef370016cbbcce42d2612031a264eb3de61b
2014-07-21 20:58:14 +02:00
Aaron Schulz
211d6062e1 Add some casts for sanity before BagOStuff::add() calls
Change-Id: I6ecb609c88e4fc1ef614e94c551199bd610ca360
2014-06-26 16:25:31 -07:00
Siebrand Mazeland
25f917688c Fix CodeSniffer errors and warnings in includes/utils/
Change-Id: I5e59dd8136fcbd8dc833d7c9f6288656e13df6e9
2014-05-08 21:15:09 +02:00