Commit graph

79 commits

Author SHA1 Message Date
DannyS712
fa42bf5639 Category.php - add a variable $loadBalancer instead of calling wfGetDB
Change-Id: I80bbfb77904d30eda4042755eb4c9398ee74c296
2020-05-27 14:21:17 +00:00
Reedy
a8467a0fd7 Fix numerous PSR12.Properties.ConstantVisibility.NotFound
Change-Id: I157220c4e9ff516283a60f06af99efa2439332e3
2020-05-12 18:41:43 +00:00
Aaron Schulz
98a4fa1b37 Cleanup various calls to IDatabase::upsert()
Change-Id: Ic82154f6f62014f892a64e39b4fb6aed202f32eb
2020-02-27 15:27:29 -08:00
Umherirrender
92a0db8165 Pass 1 always as string to IDatabase::select and friends
Column names or other sql fragments are strings, not integer

Change-Id: I7950b6e7ce4fa3b97c8b8ed55c8d7d0119eaac7e
2020-01-11 00:36:13 +00:00
Daimona Eaytoy
f18af0b61f Remove more Oracle and Mssql leftovers
Follows-up 4d10bb14e8 and 807d793ab9.

According to codesearch [0], these were the last usages. Note that this
patch leaves two constants in places, IDatabase::DBO_SYSDBA and
DBO_DDLMODE. These are public constants used "mostly for oracle" according
to the docs, but maybe we could find other use cases in the future (?).

[0] - https://codesearch.wmflabs.org/core/?q=oracle%7Cmssql&i=fosho&files=%5C.%5B%5Ej%5Cd%5D%7Cen%5C.json&repos=

Bug: T230418
Change-Id: Ibfb748b4b23b885a77f4de161af4bf2ab9649a89
2019-08-25 17:21:49 +00:00
Aaron Schulz
d2331a6823 Reinstate small category refresh logic in LinksDeletionUpdate
Add new Category::refreshCountsIfSmall() method that will do a non-locking
SELECT with LIMIT before deciding whether to do a full locking SELECT and
refresh. Call this from LinksDeletionUpdate.

Bug: T18036
Change-Id: I9de8311565988453b8e29a7f3d95d758182fcec1
2019-04-23 17:07:07 -07:00
jenkins-bot
3a02647387 Merge "Category: Remove "todo" comment about moving code from CategoryPage" 2019-04-12 23:44:51 +00:00
Eugene Gvozdetsky
8f798fd8b9 Category: Remove "todo" comment about moving code from CategoryPage
All stuff was already moved from CategoryPage.php to Category.php

Change-Id: I19820ec573c39d7368e3c6644e7c54ca9d8104c5
2019-04-12 23:22:47 +00:00
Agabi10
d19a6fe542 Avoid hitting DB in Category getters when they have the required info
Bug: T63045
Change-Id: Ib881ce263fa7a4a8256f627a56b774aaa815d3df
2019-04-04 12:40:14 -07: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
jenkins-bot
216865344b Merge "rdbms: add IDatabase::lockForUpdate() convenience method" 2018-07-11 19:52:31 +00:00
Aaron Schulz
9eff263e8e rdbms: add IDatabase::lockForUpdate() convenience method
Change-Id: I238fd96407e1122e90058e2c4acf743044a267ec
2018-07-10 20:09:01 +01:00
Umherirrender
130ec2523d Fix PhanTypeMismatchDeclaredParam
Auto fix MediaWiki.Commenting.FunctionComment.DefaultNullTypeParam sniff

Change-Id: I865323fd0295aabd06f3e3c75e0e5043fb31069e
2018-07-07 00:34:30 +00:00
jenkins-bot
b5d0251882 Merge "Reduce frequency of refreshCounts() calls in LinksDeletionUpdate" 2018-06-15 13:38:36 +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
Brad Jorsch
4aa09d4759 Category: Lock the category row before the categorylinks rows
We've noticed a large increase in deadlocks between
LinksDeletionUpdate deleting categorylinks rows and
Category::refreshCounts() trying to update the category table.

My best guess as to what's going on there is that LinksDeletionUpdate
locks the category row via the call to WikiPage::updateCategoryCounts()
then the categorylinks rows via its own deletions, while Category first
locks the categorylinks rows (in share mode) and then the category row
when it tries to update or delete it.

To break the deadlock, let's have Category do a SELECT FOR UPDATE on the
category row first before it locks the categorylinks rows.

Bug: T195397
Change-Id: Ie11baadf2ff0ba2afbc86b10bc523525c570a490
2018-06-12 11:28:25 -04:00
jenkins-bot
172925ae62 Merge "Avoid locking aggregated SELECT in Category::refresh" 2018-04-23 20:00:14 +00:00
Aaron Schulz
0b5ff6454a Make getScopedLockAndFlush() in Category::refreshCounts non-blocking
Change-Id: I675ec38e064f57a4e960b3934c472833a945b695
2018-04-19 11:43:09 -07:00
Aaron Schulz
3fc98b9c6b Avoid locking aggregated SELECT in Category::refresh
LOCK IN SHARE MODE is not allowed with aggregation on postgres/oracle.
Split out the locking and aggregation into two separate queries.

Change-Id: I7f8d113fb678b368437dad84bdb93e81db314cd5
2018-04-18 16:10:04 -07:00
addshore
f3e2941be4 Fix phpdoc for Category::newFromName
Change-Id: I78e18b41acda9aa143360a49fd161b8af1d218be
2017-11-30 19:23:48 +01: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
Umherirrender
b5cddfb27b Remove empty lines at begin of function, if, foreach, switch
Organize phpcs.xml a bit

Change-Id: Ifb767729b481b4b686e6d6444cf48b1f580cc478
2017-07-01 11:34:16 +00:00
Aaron Schulz
f6140e3196 Avoid duplicate refreshCounts() updates
The refresh method uses the initialize() method, which itself
might trigger the refresh method again after the row is created.

Change-Id: I6702bebea66fcb8b94cd2e6a496e55f52fa70b69
2017-05-10 15:38:00 -07:00
Aaron Schulz
52c3a50028 Fix bogus field reference in Category::getCountMessage() callback
Follows-up 922e68f739. (T162121)

Bug: T162941
Change-Id: I40623203e97f7155c2af171a37b1128a59415315
2017-04-19 21:25:37 -07:00
James D. Forrester
9635dda73a includes: Replace implicit Bugzilla bug numbers with Phab ones
It's unreasonable to expect newbies to know that "bug 12345" means "Task T14345"
except where it doesn't, so let's just standardise on the real numbers.

Change-Id: I6f59febaf8fc96e80f8cfc11f4356283f461142a
2017-02-21 18:13:24 +00:00
Erik Bernhardson
d67197fa11 Cleanup some incorrect return annotations
Most of these are simply changing annotations to reflect
reality. If a function can return false to indicate failure
the @return should indicate it.

Some are fixing preg_match calls, preg match returns 1, 0 or false,
but the functions all claim to return booleans.

This is far from all the incorrect return types in mediawiki, there
are around 250 detected by phan, but have to start somewhere.

Change-Id: I1bbdfee6190747bde460f8a7084212ccafe169ef
2016-12-12 10:15:05 -08:00
Aaron Schulz
950cf6016c Rename DB_SLAVE constant to DB_REPLICA
This is more consistent with LoadBalancer, modern, and inclusive
of master/master mysql, NDB cluster, and MariaDB galera cluster.

The old constant is an alias now.

Change-Id: I0b37299ecb439cc446ffbe8c341365d1eef45849
2016-09-05 22:55:53 -07:00
Brad Jorsch
47e2ef34b0 Only store currently-existing categories in the categories table
A "currently-existing category" is defined as a category that either
contains any pages or has a description page. Thus:
* Category::initialize() now schedules an update to insert a row if the
  title exits but the row is missing.
* Category::refreshCounts() now removes the row if the title doesn't
  exist and the category is empty.
* WikiPage::onArticleCreate() loads the Category object, to trigger
  bullet #1.
* WikiPage::updateCategoryCounts() refreshes the counts if it results in
  the row showing 0 pages, to trigger bullet #2.
* LinksDeletionUpdate refreshes the counts if the row shows 0 pages, to
  trigger bullet #2.

A maintenance script is provided to update the category table for this
new definition.

Bug: T28411
Bug: T50824
Change-Id: I0f0adf124c181ae5d3c7c95b3b5fb275a725794c
2016-07-18 12:52:19 -04:00
Aaron Schulz
29b0524b4e Avoid DBPerformance warnings in Category::initialize()
Use DeferredUpdates and zero-out negative values in the meantime.

Bug: T92357
Change-Id: Ia1339395b70b042edba6dc1d570acb92c90a287b
2016-06-03 15:30:02 -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
Aaron Schulz
63bf378f7e Fix "Notice: Undefined property: Category::$mId" errors
This should also improve performance while at it.

Change-Id: Ib62ce801f597c653d0a8d5fc19b81c1ce8e0f5f2
2015-10-29 21:37:11 +00:00
Kevin Israel
aebdfef5fe Avoid creating lots and lots of cat_id gaps
Currently, INSERT...ON DUPLICATE KEY UPDATE is used to update the page
counts in the category table. However, MySQL 5.1.22 and newer, by default,
increment the counter for cat_id before checking for duplicate key errors.
This creates many gaps in the cat_id sequence.

To avoid this, check for existing category rows, and instead UPDATE any
that were found. It is hoped that the extra queries will not significantly
harm performance.

Change-Id: Ic2ab9ff14f04a0c7ea90a5b6756cade0c78e2885
2015-10-16 23:31:08 -04:00
Kevin Israel
456b146367 Category::refreshCounts(): Save new counts using upsert()
This doesn't completely address the TODO comment. However, I intend
to finish doing so in a separate change.

Change-Id: I71c6dafd4223d79a0153fa8ce7cb0ee1354c0ec6
2015-10-16 23:19:45 -04:00
Ricordisamoa
2ae155da52 Fix phpcs errors in includes/
Mostly Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines

Change-Id: I678b2f0902f11cd1dfa1611b9da24e7237df9122
2015-01-08 20:15:07 +01:00
Chad Horohoe
aa21e125a3 Remove obvious function-level profiling
Xhprof generates this data now. Custom profiling of various
sub-function units are kept.

Calls to profiler represented about 3% of page execution
time on Special:BlankPage (1.5% in/out); after this change
it's down to about 0.98% of page execution time.

Change-Id: Id9a1dc9d8f80bbd52e42226b724a1e1213d07af7
2015-01-07 11:14:24 -08:00
umherirrender
3b2b6a2773 Add missing @param to function docs
Change-Id: I47fa96a976f55a1a93cb75397285edb8c7f4cd8a
2014-08-14 20:22:52 +02:00
Aaron Schulz
e79535a582 Avoid begin/commit in Category::getCountMessage()
Change-Id: I64e4a859a9adf2930265e282f59816c82e1c3070
2014-06-24 18:07:55 -07: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
Siebrand Mazeland
7a635c5dfd Try to make a dent in CodeSniffer reports on includes/ (1)
Change-Id: Iaf3120b4e32cc5835ef9ed86236d98679e2b87fa
2014-03-23 01:29:41 +00:00
umherirrender
4c81a710fa Fix formatting of some php docs
php docs of functions should have newline in it and not in one line.

Change-Id: If4a29aefb46a7f73d75593814e597fdb792d5470
2014-03-15 20:49:55 +00:00
Timo Tijhof
acb292d733 phpcs: Fix Squiz.WhiteSpace.ScopeClosingBrace.ContentBefore violations
ERROR: Closing brace must be on a line by itself
Squiz.WhiteSpace.ScopeClosingBrace.ContentBefore

- For non-empty scopes it means the closing brace must be on a separate
  line. This is already the case in most classes in some cases the "lazy
  closing" is still used.
  array(
   'x' ); // Moved } to next line
  function () { return 'x'; } // Moved } to next line
  case 1:
    stuff; break; // Moved break to next line
- For empty function it serves as a visual distinction between there not
  being a scope block / function body and there being an empty function
  body.
  function foo(); // No body
  function foo() {} // Empty body - violation
  function bar() { // Empty body corrected
  }

Change-Id: I0310ec379c6d41cc7d483671994d027a49f32164
2013-04-11 07:34:41 +00:00
Yuri Astrakhan
9506e3d812 Spellchecked /includes directory
* Ran spell-checker over code comments in /includes/
* A few spellchecking fixes for wfDebug() calls

Found one very strange (NOOP?) line in Linker.php - see "TODO: BUG?"

Change-Id: Ibb86b51073b980eda9ecce2cf0b8dd33f058adbf
2013-03-13 03:42:41 -04:00
Tyler Anthony Romeo
4dcc7961df Fixed @param tags to conform with Doxygen format.
Doxygen expects parameter types to come before the
parameter name in @param tags. Used a quick regex
to switch everything around where possible. This
only fixes cases where a primitve variable (or a
primitive followed by other types) is the variable
type. Other cases will need to be fixed manually.

Change-Id: Ic59fd20856eb0489d70f3469a56ebce0efb3db13
2013-03-11 13:15:01 -04:00
umherirrender
1044b0b8df fix some spacing
Change-Id: I8f976013f33c5818e4402604fe8610aa3f43b0c6
2013-02-04 20:18:33 +00:00
Vitaliy Filippov
e59f5eb22c Fix PHP notice in Category.php
Change-Id: I52838a1125298da330f60ef1e761130ff0e4faba
2012-11-20 00:29:54 +04:00
Siebrand Mazeland
56f00409ea Add profiling for database interaction
Also reformat some code.

Change-Id: Iee18ffeab422bdd2581aab7cab0eab482aec3a80
2012-11-08 12:35:12 +01:00
Siebrand Mazeland
d4b046a893 Update docs for return and exception info
* Removed some inline tabs in the process.
* IDE fixed some incorrect leading spaces, too.

Change-Id: Ic9303eff6db4424ac3f1fa2816839692b43e6190
2012-10-09 09:41:58 +00:00
umherirrender
7a5f4b431d Allow array condition for Database::conditional
Change the one use of that method to use the new syntax.
Add some tests.

Change-Id: I9ad4e5b5e97d1d13cfd858105167ca5d20ffaf83
2012-08-25 20:24:59 +02:00
umherirrender
aff21af9ae Allow aliased field names with separated syntax
This introduce the syntax from aliased table names for aliased field
names into the abstract database layer:

array( 'alias' => 'field' ) gives 'field AS alias'

This patch also includes changes to query pages, api and some more
places to show, how the new syntax looks in "production".

This allow us to remove the "AS" for Non-PostgreSQL databases, if we
want that.

Change-Id: I5f0de1c2f29092c173aec3de93ffdef436799e8d
2012-08-15 15:16:09 +02:00
Alexandre Emsenhuber
1082c71e9b Added missing GPLv2 headers in some places.
Also made file/class documentation more consistent.

Change-Id: Ibe7815124d6915792dcbb150d01df21d9b22b0b0
2012-05-21 21:56:39 +02:00