Commit graph

37 commits

Author SHA1 Message Date
Fomafix
c7ebc1ec44 Fix various typos in documentation
Bug: T201491
Change-Id: I144c120cc88bda723c8608ed7fb0ccb709f295f1
2021-08-23 09:03:44 +00:00
Umherirrender
a08baebd9f Ensure CommentStoreComment->id is always int as documented
Selecting the id from the database does not provide an int as everything
from the database is a string (at least in mysql)

Change-Id: I4c6673cab2a75c93bd11be7264b2ad6dfbaa8fb6
2021-08-06 01:15:03 +02:00
Thiemo Kreuz
91f8f7eb7e Turn CommentStore::$tempTables into a constant
It's private, and no code writes to this array. It is a
constant, just not implemented as one.

Change-Id: Ida13ce8ccc99802a8c673e06411955e5c74a417f
2021-02-16 09:42:30 +01:00
jenkins-bot
5ea464b234 Merge "Use static closures where safe to use" 2021-02-14 23:05:48 +00:00
Umherirrender
8de3b7d324 Use static closures where safe to use
This is micro-optimization of closure code to avoid binding the closure
to $this where it is not needed.

Created by I25a17fb22b6b669e817317a0f45051ae9c608208

Change-Id: I0ffc6200f6c6693d78a3151cb8cea7dce7c21653
2021-02-11 00:13:52 +00:00
Thiemo Kreuz
947a8cfc00 Use ?? instead of isset/array_key_exists where possible
This patch touches all uncontroversial (I hope) places where a chain
of isset(), array_key_exist() and the ternary ?: operator can be
replaced with the much shorter ?? feature from PHP 7.

?? does the same. It checks if the element before the ?? is set and
not null. When this check fails, the element after the ?? is used.

Change-Id: Id612e2782ae928164b26b6f0de676c6c7d8302f3
2021-02-10 20:32:25 +01:00
Umherirrender
9fb6d107ba Improve docs about @param/@return object $row to stdClass
Change-Id: I743d992db703f2b46b6e3abf80c14d026c6599f4
2020-11-13 00:08:21 +01:00
Timo Tijhof
d89d2eb677 CommentStore: Add documentation defgroup/ingroup annotations
Change-Id: I61afc0ecaaa401323b1b2c45841fbd27d7edab34
2020-07-25 05:42:20 +00:00
jenkins-bot
820bed0fee Merge "Use private instead of protected in CommentStore" 2020-05-23 10:16:18 +00:00
Reedy
a8467a0fd7 Fix numerous PSR12.Properties.ConstantVisibility.NotFound
Change-Id: I157220c4e9ff516283a60f06af99efa2439332e3
2020-05-12 18:41:43 +00:00
Thiemo Kreuz
f5465e742a Use private instead of protected in CommentStore
No subclasses exist:
https://codesearch.wmflabs.org/search/?q=extends%5CW*CommentStore

"protected" is just another way of making code public, increases
complexity, and makes it much harder to change the code. Private doesn't
have these problems. If we really need a subclass, we can easily make
stuff protected that's actually needed, or – much more likely – find a
better way to support the use case.

Change-Id: I9a73bf0422985e87fd8b5c5cc61c01f856654f64
2020-03-24 09:52:35 +01:00
DannyS712
cb5bcac4ff Remove CommentStore::newKey, deprecated and unused
Bug: T241957
Change-Id: If074df75e4c739a633e9d7f6578c34130264e89d
2020-02-20 02:00:15 +00:00
Daimona Eaytoy
e3412efac3 Unsuppress PhanParamReqAfterOpt, use PHP71 nullable types
These were all checked with codesearch to ensure nothing is overriding
these methods.
For the most part, I've updated the signature to use nullable types; for
two Pager's, I've just made all parameters non-optional, because you're
already forced to pass them with a required parameter at the end.

Bug: T231636
Change-Id: Ie047891f55fcd322039194cfa9a8549e4f1f6f14
2019-10-10 11:53:58 +02:00
Brad Jorsch
b8efacc227 CommentStore: Accept SCHEMA_COMPAT_* constants
Extensions doing an actor and comment migration at the same time will
likely want to use the same constants for each, and that will most
likely be using write-both/read-old and write-both/read-new for the
middle stages rather than write-both/read-both and write-new/read-both
as implemented by the MIGRATION_* constants. See Ie29fd05 for example.

This patch changes CommentStore's internal logic to work correctly when
passed write-both/read-old or write-both/read-new.

Bug: T233449
Change-Id: Iebec80f969ad1c4f9f51a4f25656319cca32b0dd
2019-09-26 11:17:50 +00:00
Gergő Tisza
d18c861aa9
Improve documentation of getJoin() methods for static analysis
Change-Id: I3943b4b4a630777d06d1689714d8f36c4430cd24
2019-07-03 15:45:01 +02:00
Kunal Mehta
5f8d76336d Fix misc phan errors by adjusting documentation (#8)
PhanTypeInvalidRightOperand was triggering on
ApiQueryBase::showHiddenUsersAddBlockInfo() on the line
`$actorQuery['tables'] + $commentQuery['tables']` (and the next one).
For whatever reason, phan was unable to automatically understand that
the right side was an array (though it was able to understand
$actorQuery, which has nearly identical code...), so I added more
specific hinting to CommentStore::getJoin() using phan's union types,
which resolved the issue.

And incorrect documentation on LogEntry::getDeleted() was triggering
PhanTypeMismatchBitwiseBinaryOperands since you can't do bitwise
operations on a string and an integer.

Change-Id: I13b791e4b754ffbc340b55cfb752e2d9226f1949
2019-04-05 23:31:16 -07:00
Brad Jorsch
0abb9338f8 Mostly drop old comment schemas
This removes most of the pre-CommentStore text columns, and the
$wgCommentTableSchemaMigrationStage setting that used to determine
whether the columns were used.

rev_comment remains in the code, as on Wikimedia wikis the revision
table is too large to alter at this time. A future change will combine
that with the removal of rev_user_text, rev_content_model, and
rev_content_format (and the addition of rev_comment_id and rev_actor).

CommentStore's constructor continues to take a $stage parameter, and
continues to have the logic for handling it, for the benefit of
extensions that might need their own migration process.

Bug: T166733
Change-Id: I1479c73774e01ead1490adf6128f820c09bce9d4
2019-02-07 16:59:27 +11:00
Brad Jorsch
d099bb6f95 Drop the image_comment_temp table
It is no longer used.

Bug: T188132
Change-Id: Ic8efeddc030f48e82ba861926121b64eca37d169
2018-11-14 15:04:31 -05:00
Bill Pirkle
5a166f00d8 Comments, tests, and tweaks for JSON decoding quirks
PHP JSON decoding has surprising behavior on some edge cases.
Documented this via comments, added related tests, and tweaked
related CommentStore code.

Bug: T206411
Change-Id: I6927fdaf616b37a04d81a638a0ed257afac9b844
2018-11-07 13:04:21 -06:00
Brad Jorsch
7a422138a7 Migrate image descriptions from image_comment_temp
image_comment_temp was always intended to be temporary, until an
expensive schema change on Wikimedia Commons's image table could be
done. Now that that has been done, stop writing image_comment_temp and
add a migration script to copy existing data into img_description_id.

Ic8efeddc will remove the reads from image_comment_temp and drop the
image_comment_temp table.

Bug: T188132
Change-Id: Iab5f521577a415b2dc213b517ee8a0dca4fdd0aa
2018-10-02 10:30:00 -04:00
James D. Forrester
733704ed82 CommentStore: Hard-deprecate newKey()
Not used by any extensions known to Wikimedia git.

Change-Id: I3c07ad6db9d88feddad1cf29d4794fef622298ea
2018-09-20 10:15:39 -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
jenkins-bot
ef97002179 Merge "Simplify PHP by using ?? and ?:" 2018-07-11 09:09:18 +00:00
Fomafix
6866cfec37 Simplify PHP by using ?? and ?:
Also remove not necessary surrounding parentheses.

Change-Id: I0eb5c9c1bdfb09a800258379cdcefb5fd4d3d21c
2018-07-10 20:03:17 +00:00
C. Scott Ananian
0935e47a72 Remove most uses of deprecated Language::truncate()
The Language::truncate() function was split into
Language::truncateForVisual() (which measures characters) and
Language::truncateForDatabase() (which measures bytes) in 1.31, but
the patch which soft-deprecated Language::truncate() didn't actually
remove all the uses in the codebase.  Replace most of those old uses
now, which should actually improve the situation for
non-latin-alphabet users who were getting unfairly squeezed in a
number of places.

Bug: T197492
Change-Id: I2291c69d9df17c1a9e4ab1b7d4cbc73bc51d3ebb
2018-07-09 13:36:27 -04:00
Umherirrender
130ec2523d Fix PhanTypeMismatchDeclaredParam
Auto fix MediaWiki.Commenting.FunctionComment.DefaultNullTypeParam sniff

Change-Id: I865323fd0295aabd06f3e3c75e0e5043fb31069e
2018-07-07 00:34:30 +00:00
Bartosz Dziewoński
485f66f174 Use PHP 7 '??' operator instead of '?:' with 'isset()' where convenient
Find: /isset\(\s*([^()]+?)\s*\)\s*\?\s*\1\s*:\s*/
Replace with: '\1 ?? '

(Everywhere except includes/PHPVersionCheck.php)
(Then, manually fix some line length and indentation issues)

Then manually reviewed the replacements for cases where confusing
operator precedence would result in incorrect results
(fixing those in I478db046a1cc162c6767003ce45c9b56270f3372).

Change-Id: I33b421c8cb11cdd4ce896488c9ff5313f03a38cf
2018-05-30 18:06:13 -07:00
Umherirrender
7eb7f04771 Change @throw to @throws
Phpcs does not look at private functions

Change-Id: I9adedf1f1c488e74db7de89e97cb6a481bf7d567
2018-04-27 21:53:19 +02:00
Niharika Kohli
acc7ab62a5 This patch reduces the edit summary length to 500 characters
Per discussion on ticket.

Bug:T188798
Change-Id: I621a98f4befd70d84f53e3c877314b64f749001c
2018-03-21 16:28:11 -07:00
addshore
e5879da149 Pass $key into CommentStore methods and use MediawikiServices
This allows CommentStore to be added to MediaWikiServices
without the need of an aditional Factory.

This change includes a compatability layer to allow the behaviour
from 1.30 to continue to be used while deprecated.

CommentStore::newKey has been deprecated.
Keys are now passed into the public methods of CommentStore
where needed.
The following CommentStore methods have had their signatures changed
to introduced a $key parameter, but when used in conjunction with
CommentStore::newKey behaviour will remain unchanged:
  * CommentStore::getFields
  * CommentStore::getJoin
  * CommentStore::getComment
  * CommentStore::getCommentLegacy
  * CommentStore::insert
  * CommentStore::insertWithTemplate

Change-Id: I3abb62a5cfb0dcd456da9f4eb35583476ae41cfb
2018-02-05 15:34:12 +00:00
Brad Jorsch
5c228f5a18 Have CommentStore limit the maximum character length of comments
I92954c9 accidentally allowed comments, when CommentStore is enabled, to
be the full 65535 bytes available in the database field. This was never
intended.

There is not yet any consensus in T6714 or T6715 on just how long the
longer comments should be, for now we'll set 1000 because Tim says so.
Note this doesn't change the UI to actually allow more characters and
will only take effect once $wgCommentTableSchemaMigrationStage is raised
above MIGRATION_OLD.

Note this also doesn't make the limit configurable. That too can be done
later if needed, again along with whatever changes are necessary to the
UI to account for a variable limit.

Change-Id: I7e0c55619210ebab467436f0bb915271c0a7ccdc
2017-10-10 20:59:52 -04:00
Brad Jorsch
01271ff6d8 Add CommentStoreComment::newUnsavedComment()
Revision (or more accurately, its upcoming MCR replacement) should allow
for the full flexibility of CommentStore in its interface, and the most
straightforward way to do that is to use CommentStoreComment. But for
that to work sanely, we need a non-@private way to create a new
CommentStoreComment that hasn't been saved to the database yet.

Change-Id: I76028e8ef3da4568a16e098cdfbc806a67b814e3
2017-09-11 14:29:22 -04:00
Kunal Mehta
f3312cdc61 CommentStore: Try to improve description of insert()
And the similar insertWithTempTable() too.

Change-Id: Ibf0f96d3b9b0f7fe53eb9e11b94fabadc4580632
2017-09-05 12:02:33 -07:00
jenkins-bot
a17d459d4b Merge "Handle comment truncation in CommentStore" 2017-09-05 18:39:21 +00:00
Brad Jorsch
6ec1a31502 Handle comment truncation in CommentStore
Since the caller doesn't (and shouldn't) know whether CommentStore is
using the old or the new schema, it should leave truncation of comments
to CommentStore.

Change-Id: I92954c922514271d774518d6a6c28a01f33c88c2
2017-09-01 15:03:45 -04: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
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