Commit graph

296 commits

Author SHA1 Message Date
jenkins-bot
dd942172f8 Merge "DB: Add img_description_id column" 2018-04-03 01:18:42 +00:00
Eddie Greiner-Petter
27c76fa4ae Overhaul site_stats table
The site stats table holds a bunch of metric fields, two of which are of
data type "bigint unsigned", 3 are "bigint" (signed) and one is int
(signed).  Also the default values differ widely: It is 0 on the
"unsigned" fields and the "int" field, but -1 on the three others. This
patch makes all of this more consistent:

Set all fields (except the ss_row_id, which isn't changed) data type to
"bigint unsigned". Also set NULL as the default value for all those
fields. Obviously -1 isn't a possible default value any more. Also, 0
can easily be mistaken for a real value (e.g. ss_active_users=0 -->
"there is nobody active on this wiki"). NULL, by it's definition, is the
value of choice for a value to insert into fields of which we don't know
a correct value.

The respective patch files were tested locally against MySql, Sqlite,
Postgres and SQL Server 2016. Neither oracle nor the upgrade with
update.php was tested.

Bug: T56888
Change-Id: I7d42aae434852a56b6f8dd559d8a5f3bce416021
2018-03-26 23:51:40 +00:00
daniel
b0bdfd7e9f MCR: replace slot_inherited with slot_origin
Bug: T189004
Change-Id: Ie9dbda3296a71f584c82a5f275098adc225a53d5
2018-03-19 21:51:56 +01:00
Brad Jorsch
267af09d32 DB: Add img_description_id column
This begins the process of merging image_comment_temp into the image
table by adding the needed column. Iab5f5215 will adjust the code
to use it and to add the necessary migration script.

Note this patch puts the new schema change in the 1.30 section rather
than the 1.31 section. This allows Iab5f5215 to have migrateComments.php
migrate the comments directly to the new field instead of having to
populate and then depopulate the temporary table.

Bug: T188132
Change-Id: I2485c5a758bf03bb2b4991eea920abd9d0d30bda
2018-03-13 16:54:25 -04: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
daniel
943c724198 MCR database schema
Schema additions/updates for MySQL, SQLite, PostgreSQL, MSSQL
and Oracle to add new tables:

* content
* content_models
* slots
* slot_roles

See also https://www.mediawiki.org/wiki/Multi-Content_Revisions/Database_Schema

Bug: T174028
Change-Id: I30a3a9834d54d0e6957553d91908b2b73b2c802f
2017-12-23 17:43:09 -05:00
jenkins-bot
8e0d293406 Merge "Add ip_changes to postgres/tables.sql" 2017-11-29 21:29:22 +00:00
Reedy
70951d1971 Add ip_changes to postgres/tables.sql
Follow-up Ic11c64813ee04e8520771bfa156f8e51404273e7

Bug: T177258
Change-Id: I69a278c1928ed91ef5cbe5b66e590eef629a2981
2017-11-29 21:21:57 +00:00
Reedy
47c378bb68 Remove DEFAULT '' from postgres ip_changes.ipc_rev_timestamp
Follows-up Ic11c64813ee04e8520771bfa156f8e51404273e7

Bug: T181672
Change-Id: I58fe5edb1e7656773271634f702ed044c6036497
2017-11-29 20:11:19 +00:00
MusikAnimal
70a602dde4 Add SQL for postgres, and fail gracefully in populateIpChanges
If the ip_changes table doesn't exist, the populateIpChanges maintenance
script will fail gracefully, throwing a descriptive error.

The postgres SQL is untested.

Bug: T177258
Change-Id: Ic11c64813ee04e8520771bfa156f8e51404273e7
2017-11-29 00:52:49 +00:00
Eddie Greiner-Petter
49f7be39e1 Add primary keys to site_stats
As discussed in I7d42aae434852a56b6f8dd559d8a5f3bce416021 primary keys
are needed to perform various schema changes on  the site_stats table.
This patch aims to introduce primary keys for all supported dbms.

The respective *.sql patch files were tested locally against Postgres
and SQL Server 2016. Please note that neither the patch file for Oracle
DB nor the mediawiki upgrade through update.php was tested.

Bug: T56888
Change-Id: Id10e221f0dc120bc09afc22596fd1dbecbf6a61d
2017-10-17 11:59:20 +00:00
Brad Jorsch
5ba7fb251e Fix PostgreSQL patch-add-3d.sql by replacing it
Follows-up 6260545fee, a2f5d05ae8. (T157348)

If updates are run for the first time on an installation that already
has '3D' in the enum (e.g. because it's a fresh install), the update
fails.

Instead of blindly running a patch file, we instead add a method that
checks whether the enum type already contains the value before adding
it.

Bug: T177417
Change-Id: Iad10cb88cf1cb35cfb95ce98a556b33688158a88
2017-10-12 03:24:56 +00:00
Brad Jorsch
91b86399b1 Fix various PostgreSQL failures
* Fix schema for image_comment_temp.
* Provide values in CommentStoreTest::provideInsertRoundTrip() for
  columns where the PG schema doesn't have a default value but the MySQL
  schema does.
* Call nextSequenceValue() from CommentStoreTest::testInsertRoundTrip().
* Correctly handle $options being the string 'FOR UPDATE' in
  DatabasePostgres::selectSQLText()
* Correctly handle the initial table in DatabasePostgres::selectSQLText() FOR
  UPDATE mangling.
* Correctly handle aliases in DatabasePostgres::selectSQLText() FOR
  UPDATE mangling.

Tests in PG are still going to be broken thanks to the fact that
nextSequenceValue() and insertId() can't be separated by another
nextSequenceValue()/insertId() pair. That should be taken care of by
T164898/T164900.

Change-Id: Ia770a003ca9170ab8bcc1436d8afe30700e00ada
2017-08-30 17:18:29 -04:00
Brad Jorsch
08a09b77d5 Fix index in PostgreSQL schema
Followup to Ic3a434c06

Change-Id: I68966726f91b1854e845b2a0757b599644749b4f
2017-08-30 12:28:24 -04:00
Brad Jorsch
11cf01dd9a Add comment table and code to start using it
A subsequent patch will remove the old columns.

Bug: T166732
Change-Id: Ic3a434c061ed6e443ea072bc62dda09acbeeed7f
2017-08-30 15:05:00 +10:00
Matthias Mullie
6260545fee Follow-up to '3D' file type addition
Based on feedback on Id78a504302fa664b353a4c45bdc5d99f95a0180a

Bug: T157348
Change-Id: Id6bfe8d20307f62e4673a5ef30e79f164b1ea034
2017-07-28 23:46:33 +00:00
Eddie Greiner-Petter
b140b73b54 Revert, Follow-up: -1 recent contributors
This reverts commit b67f40e5b0.

There was an issue that the web installer, when inserting initial
values into the db table site_stats, would not insert any value for
ss_active_users. That lead to some places, most notably
Special:CreateAccount, to show off -1 recent contributors.

The commit to revert solved this by setting a default value of 1 for
the ss_active_users field in the database schema. However, while the
default schema has been changed, there hasn't been any schema update
procedure implemented. Also, the default of 1 is inconsistent with
other defaults in that table.

Revert that schema change completely. Instead, make the web installer
insert 0 to the field ss_active_users (just like it does with all other
fields in that table).

Bug: T56888
Change-Id: I4298754c2238f6e5447a5df77a4ada722ba302b2
2017-04-27 01:51:21 +00:00
MZMcBride
b67f40e5b0 Set default to 1 recent contributor instead of -1
Bug: T56888
Change-Id: I06bd0e5959d1ff561d71163bd5ce26f28f73981c
2017-04-18 13:55:53 +02:00
This, that and the other
73224f4f8b User group memberships that expire
This patch adds an ug_expiry column to the user_groups table, a timestamp
giving a date when the user group expires. A new UserGroupMembership class,
based on the Block class, manages entries in this table.

When the expiry date passes, the row in user_groups is ignored, and will
eventually be purged from the DB when UserGroupMembership::insert is next
called. Old, expired user group memberships are not kept; instead, the log
entries are available to find the history of these memberships, similar
to the way it has always worked for blocks and protections.

Anyone getting user group info through the User object will get correct
information. However, code that reads the user_groups table directly will
now need to skip over rows with ug_expiry < wfTimestampNow(). See
UsersPager for an example of how to do this.

NULL is used to represent infinite (no) expiry, rather than a string
'infinity' or similar (except in the API). This allows existing user group
assignments and log entries, which are all infinite in duration, to be
treated the same as new, infinite-length memberships, without special
casing everything.

The whole thing is behind the temporary feature flag
$wgDisableUserGroupExpiry, in accordance with the WMF schema change policy.

The opportunity has been taken to refactor some static user-group-related
functions out of User into UserGroupMembership, and also to add a primary
key (ug_user, ug_group) to the user_groups table.

There are a few breaking changes:
- UserRightsProxy-like objects are now required to have a
  getGroupMemberships() function.
- $user->mGroups (on a User object) is no longer present.
- Some protected functions in UsersPager are altered or removed.
- The UsersPagerDoBatchLookups hook (unused in any Wikimedia Git-hosted
  extension) has a change of parameter.

Bug: T12493
Depends-On: Ia9616e1e35184fed9058d2d39afbe1038f56d7fa
Depends-On: I86eb1d5619347ce54a5f33a591417742ebe5d6f8
Change-Id: I93c955dc7a970f78e32aa503c01c67da30971d1a
2017-01-27 09:24:20 +00:00
Brad Jorsch
c585ec5ed6 Add externallinks.el_index_60 column and indexes
This will allow for replacing the limit-and-offset queries with queries
that page in a sensible manner.

Bug: T59176
Change-Id: If5c137f68496772f3fff3a735b7b0c388426e518
2016-11-21 16:37:49 -05:00
This, that and the other
d0a0e9b417 Add primary key to change_tag and tag_summary tables
Based heavily on 43e386ca16.

Bug: T123225
Change-Id: I33480f4016812259700979f1145099744bb451d4
2016-10-02 13:02:41 +11:00
Brad Jorsch
adf9875c74 Add rc_name_type_patrolled_timestamp index
Bug: T140108
Change-Id: I382a5f0daef703a3d16fe008a5e1d1402f2c7b33
2016-07-14 12:01:04 -04:00
addshore
43e386ca16 Add id field to watchlist db table
Bug: T125990
Change-Id: I3ce3a736d51bc06fe40fd773f079e694039b4f3e
2016-02-18 21:01:01 +00:00
Brad Jorsch
2257fe4228 Revert "Remove SessionManager, temporarily"
This reverts commit 823db5d63dd5200d04c63da50ba6bf16f928e70b.

Change-Id: Ibb3e023e4eb6715295586dea87d0725c344a8271
2016-02-03 21:44:59 +00:00
Brad Jorsch
5083e810eb Remove SessionManager, temporarily
The plan here is to take it out of 1.27.0-wmf.12 and put it back in
1.27.0-wmf.13.

Since BotPasswords depends on SessionManager, that's getting temporarily
removed too.

This reverts the following commits:
* 6acd424e0d SessionManager: Notify AuthPlugin before calling hooks
* 4d1ad32d8a Close a loophole in CookieSessionProvider
* fcdd643a46 SessionManager: Don't save non-persisted sessions to backend storage
* 058aec4c76 MessageCache: Don't get a ParserOptions for $wgUser before the end of Setup.php
* b5c0c03bb7 SessionManager: Save user name to metadata even if the user doesn't exist locally
* 13f2f09a19 SECURITY: Fix User::setToken() call on User::newSystemUser
* 305bc75b27 SessionManager: Don't generate user tokens when checking the tokens
* 7c4bd85d21 RequestContext::exportSession() should only export persisted session IDs
* 296ccfd4a9 SessionManager: Save 'persisted' flag in session metadata
* 94ba53f677 Move CSRF token handling into MediaWiki\Session\Session
* 46a565d6b0 Avoid false "added in both Session and $_SESSION" when value is null
* c00d0b5d94 Log backtrace for "User::loadFromSession called before the end of Setup.php"
* 4eeff5b559 Use $wgSecureCookie to decide whether to actually mark secure cookies as 'secure'
* 7491b52f70 Call session_cache_limiter() before starting a session
* 2c34aeea72 SessionManager: Abstract forceHTTPS cookie setting
* 9aa53627a5 Ignore auth cookies with value 'deleted'
* 43f904b51a SessionManager: Kill getPersistedSessionId()
* 50c5256352 SessionManager: Add SessionBackend::setProviderMetadata()
* f640d40315 SessionManager: Notify AuthPlugin when auto-creating accounts
* 70b05d1ac1 Add checks of $wgEnableBotPasswords in more places
* bfed32eb78 Do not raise a PHP warning when session write fails
* 722a7331ad Only check LoggedOut timestamp on the user loaded from session
* 4f5057b84b SessionManager: Change behavior of getSessionById()
* 66e82e614e Fix typo in [[MediaWiki:Botpasswords-editexisting/en]]
* f9fd9516d9 Add "bot passwords"
* d7716f1df0 Add missing argument for wfDebugLog
* a73c5b7395 Add SessionManager

Change-Id: I2389a8133e25ab929e9f27f41fa9a05df8147a50
2016-02-01 22:06:49 +00:00
Brad Jorsch
f9fd9516d9 Add "bot passwords"
Bot passwords are something like OAuth-lite, or Google's application
passwords: the bot can use API action=login to log in with the special
username and password, and will then be allowed to use the API with a
restricted set of rights.

This is intended to provide an easy migration path for legacy bots and
for bots on wikis without OAuth, since AuthManager is going to greatly
complicate non-interactive authentication. If OAuth is available, an
owner-only consumer would be a better choice.

Bug: T121113
Change-Id: Iaa4015e00edbfbfaedcc8b2d27a2d3fd25009159
Depends-On: I7e15331efb162275c4116bcae61f19d6b884cbe3
2016-01-12 22:37:44 +00:00
Timo Tijhof
baf1721491 resourceloader: Remove obsolete msg_resource database table
No longer used as of 5d5b269e0e.

Change-Id: Ieb8448185cf39aa396e902e025e673f0886ac3c3
2015-12-14 01:24:27 +00:00
Timo Tijhof
cbf5bacae5 resourceloader: Remove obsolete msg_resource_links table
No longer used as of Ia9131f570.

Change-Id: If009e2620e59002e127d21b90a96bdd29e5d2a9d
2015-12-14 01:23:19 +00:00
Jeff
c1371e7f54 PostgreSQL: Fix text search on moved pages
When a page is updated under PostgreSQL, there is code to
de-index all but the most recent version of the page.  But
when a page is moved, it was accidentally de-indexing the
most recent version as well, because rev_text_id is not
incremented in that case.  A simple tweak to the SQL
fixes that.

I added code to the update script to find pages
previously corrupted by this problem and reindex them.

Bug: 66650
Change-Id: I52e1bbbd8592be5e7c7383c225e6b4c19bbe5b9e
2015-02-17 18:15:23 -08:00
Jeff Janes
3603b8d772 PostgreSQL: Drop unneeded foreign key constraint
Change I1c7f3a84f10df05d6b37dccbad4c8232edf51580 causes
an existing foreign key assumption (under PostgreSQL) to be
violated upon deleting a page.  This foreign key assumption does not
explicitly exist in MySQL, and is not implied via documentation.  So
it was probably never needed in the first place.

Don't create the foreign key constraint in PostgreSQL, and drop it
if it already exists when running update.php.

The constraint was previously created with an implicit name, so
drop the constraint involving the specified column name (rc_cur_id),
rather than hard-coding the name of the constraint itself.

This bug probably exists under Oracle and MSSQL as well, but no attempt
was made to address it there.

Bug: T76254
Change-Id: I2abd650c8ce83c5b725aec0545fff14a927a305a
2015-01-30 13:15:29 -08:00
Chad Horohoe
5f8edb2c0a Drop ss_total_views and page_counter fields from MediaWiki
Follows up removal of code using hitcounters in 90d90dad6

RFC: https://www.mediawiki.org/wiki/Requests_for_comment/Removing_hit_counters_from_MediaWiki_core
Change-Id: Ieeb558f9523c11965cbc1941cad4f316c00c85c5
2015-01-09 19:01:01 +00:00
Jeff Janes
44b4b45bfa PostgreSQL: Port update-keys.sql to PostgreSQL
This fixes the same bug in PostgreSQL that was reported
against Oracle as bug 71040, using the same method of copying
the update-keys.sql script into maintenance/postgres.

Since all three copies of this file do the same thing, perhaps
we should find lowest-common-denominator syntax that works in
all databases to avoid redundant copies that can get out of
sync with each other.  (The Oracle and PostgreSQL versions are
already identical to each other).

The comments in the file are confusing and ungrammatical, but
they are a copy of the same language from the other copies.
Since I don't know what it is trying to say, I can't
fix it.

I have verified that this patch fixes the problem where
mediawiki could not be installed with PostgreSQL using
either the CLI or the web installer, due to SQL syntax errors.

I haven't tested the the update-keys actually accomplishes
whatever it was introduced to accomplish, though.

Bug: 72834
Change-Id: I2a0cfa3dd0751b9fb65450b1537b6e77be60009a
2014-10-31 13:21:04 -07:00
Southparkfan
5afea3de7d chmod 755 bash & Perl files, chmod 644 .css file
Bug: 71972
Change-Id: I16d6ffde113838fc431bffaf00be1574d5a0303a
2014-10-30 18:25:16 +00:00
Aaron Schulz
b8c038f678 Redo WhatLinksHere query and add a *_from_namespace field to link tables
* Also tweaked the query so MySQL avoids doing a page_name
  index scan when it should start with the link table index
* Added population script (triggered by update.php)
* Also removed uniqueness from some indexes where it is redundant
* Renamed two confusing variables

Bug: 60618
Change-Id: Icca99b6ae0ef76cb77695faf82c615516191da36
2014-07-21 12:04:56 -07:00
Kunal Grover
50144cd02a First version of Page Language selector
Special page PageLanguage to set the page language of a page.
To enable the feature, set $wgPageLanguageUseDB to true
and assign the 'pagelang' user right to a user group.

Bug: 35489
Change-Id: I0f82b146fbe948f917c1c5d29f7469644d797e80
2014-06-27 23:27:07 +00:00
Brad Jorsch
c396f11ab3 Add wl_user_notificationtimestamp index
Bug: 65246
Change-Id: If3e9e855c8a21874ca69c4976af207833dcc53f2
2014-06-04 06:05:38 +00:00
Jeff Janes
0582e3339d PostgreSQL: Make l10n_cache.lc_value binary
Change-Id I427c6de5a0a29b43cff755db0eb8a750db620173 increases the
probability that a null byte will attempt to be stored in the
lc_value column.  PostgreSQL does not allow that byte in a text
column, so convert the column to bytea.

If the column already contains corrupted data, the upgrade routine
might fail.  To prevent this, delete the contents of the table before
changing the type.

Bug: 62098
Change-Id: Ie8368bde398b2ae4d3cfc9ee7bf35874bd2ded68
2014-05-05 11:20:52 -07:00
Jeff Janes
3fcfced5ad PostgreSQL: Fix syntax error in page_props index
Follows up I217c42656fb877ff35a36eb446a22bdaf119faac

That change introduced a syntax error during update.  I have verified
that this fixes the syntax problem so that update.php runs, but have
not verified that the new functionality behaves as intended.

Also, the PostgreSQL schema changes introduced during the update
process were not present at all in a fresh install to PostgreSQL.  Add
analogous changes to tables.sql.

Bug: 64807
Change-Id: I736344839ec478216402fdfe260968afbd663498
2014-05-05 10:14:02 -07:00
Jeff
8e4b41a508 PostgreSQL: Allow rc_cur_time field to be null.
The column recentchanges.rc_cur_time is no longer populated by SQL,
so PostgreSQL must be changed to allow the NULL value for it.

In MySQL, the empty string is used as a surrogate for NULL, but that
is not allowed in PostgreSQL.

Bug: 61318
Change-Id: I6733ef11152d545382bec087d992515dcf9aec0b
2014-04-22 16:57:49 +00:00
umherirrender
2ba577f69c Add missing DROP SEQUENCE to postgres' tables.sql
To drop all possible existing sequences.
Also add a DROP TYPE for the existing type.

Change-Id: I3aad6b1c6c2b273ca4ed5fd3b448f4379984cd76
2014-02-28 23:10:23 +01:00
csteipp
01c8c421f8 Password Expiration
Add functionality to expire users' passwords:
 * Adds column to the user table to keep a password expiration
 * Adds $wgPasswordExpirationDays, which will force users to reset
   their passwords after a set number of days. By default, this set
   to false, so passwords never expire.
 * Adds a default grace period of 7 days, where if the user's password
   is expired, they can still login, but are encouraged to reset their
   password.
 * Adds hook 'LoginPasswordResetMessage' to update reset message, in
   case an extension wants to vary the message on a particular reset
   event.
 * Adds hook 'ResetPasswordExpiration' to allow extensions to change
   the expiration date when the user resets their password. E.g., if
   an extension wants to vary the expiration based on the user's group.

If the user is in the grace period, they get a password reset form
added to the login successful page. If an extension prevents showing
the login successful page (like CentralAuth), it should be updated to
show a password change form during the grace period. After the grace
period, the user will not be able to login without changing their
password.

Also prevents a successful reset if the user is "changing" their
password to their existing password.

No passwords will expire by default. Sites will have to call
User->expirePassword() from their own maintenance script to trigger a
password reset for a user.

Bug: 54997
Change-Id: I92a9fc63b409b182b1d7b48781d73fc7216f8061
2014-02-20 09:41:51 -08:00
jenkins-bot
7af7ba2f05 Merge "Add missing uploadstash.us_props for PostgreSQL" 2014-01-29 18:19:48 +00:00
umherirrender
305622fbc9 Correct sequence name for fresh Postgres installation
Spotted by gebhkla on bug 60083

Bug: 60083
Change-Id: I34283c2539f4ce9d1b85756b3e1c16d255000ed5
2014-01-27 20:38:59 +01:00
Aaron Schulz
b57e457091 Added a page_links_updated column for job de-duplication
Change-Id: I74b6f507ef7371db92e0c3f058d38c0ca5dea9ef
2013-12-24 10:54:32 +00:00
Jackmcbarn
65a304c444 Add index on logging.log_user_text
Fixing bug #54404 requires querying against logging.log_user_text, which
is currently unindexed. Add an index, to prevent performance from being
adversely affected by the fix.

Bug: 54432
Change-Id: I6b2af65c75bbee57377cb1ec2e75ea41a5091f80
2013-12-19 03:13:05 +00:00
saper
c7f4586fe1 Add missing uploadstash.us_props for PostgreSQL
This field was introduced in e5d41cca90
but only for MySQL.

Change-Id: I057b1dd845a5ab7ae05f5597454981a6e2c12698
2013-12-09 20:46:17 +01:00
This, that and the other
3631901139 Clean up some old readme files and remove references to SVN
docs/README: Updated links, got rid of 2008 date at top of file
docs/maintenance.txt: Updated link
extensions/README: Some cleanup, added link to new git.wikimedia.org
includes/DefaultSettings.php: SVN -> Git for udpprofile
includes/profiler/ProfilerSimpleUDP.php: ditto
languages/MessagesRo.php: removed link to mime.types on SVN from the
  mimesearch-summary message. This file seems to have been deleted from the
  modern-day Git repository
maintenance/postgres/mediawiki_mysql2postgres.pl: removed SVN magic words

That takes care of most of the remaining references to SVN etc.

Bug: 38714
Change-Id: I261921df4b4c0545658d6d38c5f3c1f9dfa63ad1
2013-11-16 10:38:50 +00:00
Erik Bernhardson
6bbd4bca6c Revert "Revert "Add new recentchanges field rc_source to replace rc_type""
This reverts commit 113f49bb21 after the
schema change has been completed.

Change-Id: I5412466444526986e1209d0982dd62cd5b387ad1
2013-10-25 13:10:42 -07:00
tisane
9b2b027ba7 Add archive, externallinks PK
* New fields: ar_id, el_id. el_id is presently not used for
  anything, but will help with online schema changes.

Bug: 15441
Bug: 39675
Change-Id: Ib6b0fc3736d173fa4ba7b786ecfc710b2f4711bb
2013-10-17 18:43:40 +01:00
jenkins-bot
3316e073a8 Merge "Revert "Add new recentchanges field rc_source to replace rc_type"" 2013-10-17 00:37:44 +00:00