Commit graph

264 commits

Author SHA1 Message Date
Umherirrender
efe5761c93 build: Updating mediawiki/mediawiki-codesniffer to 23.0.0
Avoid use of __METHOD__ magic constant in closure

Change-Id: I28d519530ca2fcde026a6cbb419848098d4617ca
2018-12-01 23:11:16 +01:00
Brad Jorsch
d65e96b763 Use new externallinks.el_index_60 field
This adds a method to LinkFilter to build the query conditions necessary
to properly use it, and adjusts code to use it.

This also takes the opportunity to clean up the calculation of el_index:
IPs are handled more sensibly and IDNs are canonicalized.

Also weird edge cases for invalid hosts like "http://.example.com" and
corresponding searches like "http://*..example.com" are now handled more
regularly instead of being treated as if the extra dot were omitted,
while explicit specification of the DNS root like "http://example.com./"
is canonicalized to the usual implicit specification.

Note that this patch will break link searches for links where the host
is an IP or IDN until refreshExternallinksIndex.php is run.

Bug: T59176
Bug: T130482
Change-Id: I84d224ef23de22dfe179009ec3a11fd0e4b5f56d
2018-11-12 22:33:18 +00:00
jenkins-bot
dea8f5344b Merge "Create JobQueueEnqueueUpdate class to call JobQueueGroup::pushLazyJobs()" 2018-10-28 23:10:53 +00:00
Aaron Schulz
6030e9cf2c Create JobQueueEnqueueUpdate class to call JobQueueGroup::pushLazyJobs()
This assures that MergeableUpdate tasks that lazy push job will actually
have those jobs run instead of being added after the lone callback update
to call JobQueueGroup::pushLazyJobs() already ran.

This also makes it more obvious that push will happen, since a mergeable
update is added each time lazyPush() is called and a job is buffered,
rather than rely on some magic callback enqueued into DeferredUpdates at
just the right point in multiple entry points.

Bug: T207809
Change-Id: I13382ef4a17a9ba0fd3f9964b8c62f564e47e42d
2018-10-28 22:19:06 +00:00
Aaron Schulz
e2088f1170 Make UserEditCountUpdate faster by using auto-commit mode
Bug: T202715
Change-Id: I92c08694cb5e1c367809439cff42e33a56ff9878
2018-10-27 13:52:45 -07:00
Aaron Schulz
390fce6db1 Move user_editcount updates to a mergeable deferred update
This should reduce excess contention and lock timeouts.
Previously, it used a pre-commit hook which ran just before the
end of the DB transaction round.

Also removed unused User::incEditCountImmediate() method.

Bug: T202715
Depends-on: I6d239a5ea286afb10d9e317b2ee1436de60f7e4f
Depends-on: I0ad3d17107efc7b0e59f1dd54d5733cd1572a2b7
Change-Id: I0d6d7ddd91bbb21995142808248d162e05696d47
2018-10-25 15:32:18 -07:00
jenkins-bot
4ddc1da854 Merge "Make MergeableUpdate jobs avoid the sub-queue so they can always merge" 2018-10-12 01:13:29 +00:00
Aaron Schulz
f61868f13d Make MergeableUpdate jobs avoid the sub-queue so they can always merge
Change-Id: I5b100fae29b785ab4524d165dad2e8ee46406b0c
2018-10-12 00:36:39 +00:00
Aaron Schulz
9fb67b9a41 Make merged MergeableUpdate items always go to the end of the queue
Change-Id: I2e8aa28f7426470d9b8b9e11b902deea793069b3
2018-10-11 14:51:36 -07:00
James D. Forrester
054d5ff1a1 Drop DeferredUpdates::setImmediateMode(), deprecated since 1.29
Change-Id: I8ae7dedf956034981081d2bcec630d6724921269
2018-10-10 15:30:00 -07:00
Aaron Schulz
59242afaa7 messagecache: use MergeableUpdate for the deferred replace() update
This combines the load loop for multiple messages for a language code.

Bug: T203925
Bug: T193271
Change-Id: Ie5e1e83d6740344b7ca641c99fb3bd4ad5718492
2018-10-05 20:14:41 +00:00
Aaron Schulz
5c03b91e3b Add type hint to invalidateImageDescriptions()
Change-Id: Ie6322f25c959f5de4bbccd8f47d40f112817d00b
2018-10-01 23:20:10 -07:00
Timo Tijhof
3d758d7495 jobqueue: Use explicit retry when refreshLinks can't get a lock
While RefreshLinksJob is de-duplicated by page-id, it is possible
for two jobs to run for the same page ID if the second one was queued
after the first one started running. In that case they the newer
one must not be skipped or ignored because it will have newer
information to record to the database, but it also has no way
to stop the old one, and we can't run them concurrently.

Instead of letting the lock exception mark the job as error,
making it implicitly retry, do this more explicitly, which avoids
logspam.

Bug: T170596
Co-Authored-By: Aaron Schulz <aschulz@wikimedia.org>
Change-Id: Id2852d73d00daf83f72cf5ff778c638083f5fc73
2018-08-28 22:39:01 +01:00
Umherirrender
40d3ce8d17 Reduce calls to MediaWikiServices::getInstance()
In some functions MediaWikiServices::getInstance() was called twices or
in loops. Extract the variable to reduce calls.

Change-Id: I2705db11d7a9ea73efb9b5a5c40747ab0b3ea36f
2018-08-18 06:02:39 +02: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
Kunal Mehta
de9d19b481 Have WANCacheReapUpdate::getEventAffectedKeys() accept LinkTarget
Nothing specifically requires TitleValue here.

Change-Id: I62ee1995c49071db2871149b941277b29836a94a
2018-08-15 02:30:27 -07:00
Aryeh Gregor
90d4f56fe4 Mass conversion of $wgContLang to service
Brought to you by vim macros.

Bug: T200246
Change-Id: I79e919f4553e3bd3eb714073fed7a43051b4fb2a
2018-08-11 22:44:29 -06:00
Bartosz Dziewoński
62f7cdc331 Use multibyte-aware truncation to avoid invalid UTF-8 in cl_sortkey_prefix
The invalid UTF-8 could cause incorrect sorting of affected pages in
category lists on wikis using UCA collations. On my local testing
wiki, the generated cl_sortkey was just 0x30 regardless of the value
of cl_sortkey_prefix.

This doesn't fix existing bad data in the database. It will only be
updated when the affected page is edited (or null-edited).

The cl_timestamp field will also be updated when that happens, which
apparently may affect Wikinews' DynamicPageList extension, according
to comments on T27254. This is not easily avoidable.

Bug: T200623
Change-Id: I4baa9ea3c7f831ff3c9c51e6b8e5d66e7da42a91
2018-07-30 21:52:38 +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
Aaron Schulz
70ed89ad43 Reduce the rate of calls to Category::refreshCounts
Bug: T199762
Change-Id: I23e2e1ebf187d21ea4bd22304aa622199a8b9c5b
2018-07-18 00:46:38 +01:00
Umherirrender
130ec2523d Fix PhanTypeMismatchDeclaredParam
Auto fix MediaWiki.Commenting.FunctionComment.DefaultNullTypeParam sniff

Change-Id: I865323fd0295aabd06f3e3c75e0e5043fb31069e
2018-07-07 00:34:30 +00:00
Kevin Israel
a50f61009d MWNamespace: Add getCategoryLinkType() method
This method returns the value used as cl_type for category links that
are "from" pages within the namespace, and is added to avoid duplication
of code across a few classes.

Change-Id: I4e55932a5a27858cfedb12009b455fcd02f9b5df
2018-06-29 15:37:11 +00:00
Aaron Schulz
9a2ba8e21d Reduce frequency of refreshCounts() calls in LinksDeletionUpdate
Bug: T195397
Change-Id: I0a39c735ec516b70c43c7a40583c43289550b687
2018-06-12 17:50:52 +00:00
Max Semenik
8085c58a4b Replace call_user_func_array(), part 1
Uses new PHP 5.6 syntax like ...parameter unpacking and
calling anything looking like a callback to make the code more readable.
There are much more occurrences but this commit is intentionally limited
to an easily reviewable size.

Change-Id: Idcec077ef3fdf029b632cceafd0150851ad723e3
2018-06-04 23:39:04 -07:00
Brad Jorsch
aef72c5cf6 Populate externallinks.el_index_60 and drop default
Adds a maintenance script to populate the field, has that be
automatically run during update.php, and drops the no-longer-needed
default value on the column (where possible: mssql has some sort of
constraint thing going on that I have no idea how it works).

Bug: T59176
Change-Id: I971edf013a1a39466aca3b6e34c915cb24fd3aa7
2018-05-15 12:08:35 -04:00
Umherirrender
fc871584ec Remove deprecated SqlDataUpdate class
Deprecated since 1.28

Change-Id: I4dcbc8fcfdb99caa0469e7cf63745b94e19cd21d
2018-05-05 11:18:47 +02:00
Aaron Schulz
8659c59dcf Use AutoCommitUpdate in LinksUpdate::doUpdate
The hook handlers are likely to write to secondary databases, in which
case it is better to wrap the callback in its own transaction round.

This lowers the chance of pending write warnings happening in
runMasterTransactionIdleCallbacks() as well as DBTransactionError
exceptions in LBFactory due to recursion during commit.

Bug: T191282
Bug: T193668
Change-Id: Ie207ca312888b6bb076f783d41f05b701f70a52e
2018-05-03 23:47:17 +00:00
Aaron Schulz
a79b9737f1 Make DeferredUpdates avoid running during LBFactory::commitMasterChanges
Bug: T193668
Change-Id: I50890ef17ea72481a14c4abcd93ae58b93f15d28
2018-05-03 15:11:38 -07:00
daniel
a430307fad Make DeferredUpdates re-throw exceptions during testing.
This is a stop-gap solution for the problem described in T190178.
A better solution would probably include changing the behavior
of LegacyLogger.

Bug: T190178
Change-Id: I433be04b8ee725becd174e567270aa674d2661df
2018-05-02 21:16:05 +00:00
Aaron Schulz
de75c4e63b Avoid triggering Category::refreshCounts() on HTTP GET requests
Trigger count refreshes more often during updates instead.

Change-Id: I0f4575e648109befb86a2c8f08b491a132fe56c3
2018-04-19 04:45:24 +00:00
Aaron Schulz
c6b668c2ec Do not start explicit transaction rounds for RecentChangesUpdateJob
The replaces the hacky use of onTransactionIdle(), which no longer runs
immediately in explicit transaction rounds since d4c31cf841.

Also clarified TransactionRoundDefiningUpdate comment about rounds.

Change-Id: Ie17eacdcaea4e47019cc94e1c7beed9d7fec5cf2
2018-04-17 12:39:05 +00:00
Aaron Schulz
ab2bf12cf8 Add test for WikiPage post-edit stats update
Bug: T187585
Change-Id: I734b7f42799a9bfe77a1fb1269bb3d48b3852ffd
2018-03-06 00:43:39 +00:00
Brad Jorsch
27c61fb1e9 Add actor table and code to start using it
Storing the user name or IP in every row in large tables like revision
and logging takes up space and makes operations on these tables slower.
This patch begins the process of moving those into one "actor" table
which other tables can reference with a single integer field.

A subsequent patch will remove the old columns.

Bug: T167246
Depends-On: I9293fd6e0f958d87e52965de925046f1bb8f8a50
Change-Id: I8d825eb02c69cc66d90bd41325133fd3f99f0226
2018-02-23 10:06:20 -08:00
Timo Tijhof
d6cc261cb2 Use lock(,,0) instead of lockIsFree && lock(,,1) for non-blocking locks
This pattern is already used elsewhere and seems like a more efficient
way to acquire locks in a non-blocking way.

Change-Id: Idb369e7cb03b793d5f8295e956fecd8d1f849e17
2018-02-15 14:30:26 -08:00
Stephane Bisson
b5ea51dce6 Fix typehint for multiple dbs in addCallableUpdate
Change-Id: Ic4fe6c529d9394cfd0c8c8652a28f47973342096
Follow-up: I0371ecd20101c5e622497e5912676300b040865e
2018-02-13 15:50:49 -05:00
Aaron Schulz
6094897687 Various cleanup to SiteStats classes
* Mark method visibility
* Remove unused code/methods
* Use WAN cache process cache in pagesInNs()
* Remove "m" prefix from SiteStatsInit fields
* Avoid use of $wg variables

Change-Id: Iab4001f02c9b2e8667ca4bac033fd4f6ef272148
2018-02-12 15:09:19 -08:00
Aaron Schulz
a21924267c deferred: Make MWCallableUpdate support a list of DB handles
Change-Id: I0371ecd20101c5e622497e5912676300b040865e
2018-01-31 20:04:48 -05:00
Tim Starling
dc2948d76d A few doc comment fixups
* Remove some creation dates, they are not protected by GPL
* Remove duplicate @defgroup API
* Remove @ingroup from some @file doc comments on class files. It is not
  useful to list class files alongside classes in the doxygen module menu.
  Add @ingroup to some more class files that had @ingroup on their file,
  that was probably the author's intent.
* In PackedOverlayImageGallery, use the file comment as a class comment
* Don't put @defgroup and @file in the same comment. @defgroup makes the
  whole doc comment describe the group.
* Instead of putting AnsiTermColorer in two groups, use hierarchical
  groups.

Change-Id: If54f6e0b2bc1ea6de42045885cf836ee67b8e961
2017-12-04 11:11:52 +11:00
Aaron Schulz
3247bae0e7 Add action/user tracking to html cache purge jobs
Change-Id: Ic7155a7303debfaf26b13cb836497ccbc89ea238
2017-10-30 10:47:30 -07:00
Aaron Schulz
8f829de5f0 Add action/user tracking to link refresh jobs
Change-Id: Ie7261eacddb869988b005ba2f17968df88c7003e
2017-10-23 11:06:16 -07:00
Timo Tijhof
6b2f8639b6 deferred: Introduce TransactionRoundDefiningUpdate
This allows scheduling of updates that need to start their own
transaction round. Specifically for cases where the ability to
commit early is not enough (which is already possible via LBFactory
getEmptyTransactionTicket and commitAndWaitForReplication).

Change-Id: I0910587b61c8ddf825f91e92c2f93582cc7ebd80
2017-10-13 21:24:11 +00:00
Timo Tijhof
31c461e75e deferred: Improve DeferredUpdates test coverage
From 1% of lines to 12% in deferred/.
From 6% of lines to 68% in DeferredUpdates.php.

* Adding relevant @covers tags to existing tests.
* Add coverage for MWCallableUpdate.
* Add coverage for MergeableUpdate.

Also:
* Make MergeableUpdate extend DeferrableUpdate.
  1. Because PHPUnit doesn't support implementing multiple interfaces
     in a mock, and would make the mock fail the typehint at run-time.
  2. It DeferredUpdates doesn't support having a MergeableUpdate that isn't
     itself a DeferrableUpdate given the only way to reach that code is past
     methods that are type-hinted with DeferrableUpdate.
  3. Making the interface extend DeferrableUpdate helps produce better and
     earlier errors. Instead of run-time error:
     > Argument 1 passed to addUpdate() must implement interface DeferrableUpdate
     > instance of MergeableUpdate given
     We get:
     > Fatal error: Class .. contains 1 abstract method and must therefore be
     > declared abstract or implement the remaining methods (doUpdate)

Change-Id: Ie384bf849a96bb37dc3e4a4154da2b02889e9fc8
2017-10-12 21:18:12 +01:00
jenkins-bot
f638ac8b9a Merge "Clean up wiki ID and DB domain ID handling" 2017-10-01 20:50:07 +00:00
Aaron Schulz
a005f1de98 Clean up wiki ID and DB domain ID handling
Bug: T174017
Change-Id: I42299a393c6691d39817db1d83a176a17df2474b
2017-09-30 10:25:03 +00:00
Brian Wolff
73e7b9cfcc Do not include RC_EXTERNAL in number active users on Special:Statistics
We already exclude external (mostly Wikidata) actions from counting on
Special:ActiveUsers as of 56524c05. Should be consistent.

Change-Id: Ib69a614a65246a0f4f47365751f9bef130f47475
2017-09-29 05:09:29 +00:00
Umherirrender
f739a8f368 Improve some parameter docs
Add missing @return and @param to function docs and fixed some @param

Change-Id: I810727961057cfdcc274428b239af5975c57468d
2017-09-10 20:32:31 +02:00
Kunal Mehta
0cb2a09b6d Always put type information before variable name for @var tags
Like other tags, @var should have the type information before the
variable name.

<https://docs.phpdoc.org/references/phpdoc/tags/var.html>

Change-Id: I9eca6957b1990fa8cc687103dc02ee38af5f9086
2017-09-04 11:06:51 -07:00
Brad Jorsch
01a10dba5a Remove reference to deprecated IDatabase->nextSequenceValue()
The method was deprecated and made unnecessary in Ib308190c.

Change-Id: I1729ac0b3a88270a4c2f064187a2472112aaeb1e
2017-09-01 12:28:39 -04:00
Erik Bernhardson
3370b052fc Batch request titles for cdn purge from db
Xenon shows a significant amount of time is spent individually fetching
the content model for titles being purged. It's probably not a huge
improvement but lets fetch them all in one go instead of lazily as
needed.

Change-Id: I71af6f13c84e740c1367617d7a51210501363b33
2017-08-30 18:22:11 +00: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