MediaWiki REL1_40
|
Inherited by MediaWiki\CommentStore\CommentStore.
Public Member Functions | |
__construct ( $tempTables, Language $lang, $stage) | |
createComment (IDatabase $dbw, $comment, array $data=null) | |
Create a new CommentStoreComment, inserting it into the database if necessary. | |
getComment ( $key, $row=null, $fallback=false) | |
Extract the comment from a row. | |
getCommentLegacy (IDatabase $db, $key, $row=null, $fallback=false) | |
Extract the comment from a row, with legacy lookups. | |
getFields ( $key) | |
Get SELECT fields for the comment key. | |
getJoin ( $key) | |
Get SELECT fields and joins for the comment key. | |
getTempTableMigrationStage (string $key) | |
insert (IDatabase $dbw, $key, $comment=null, $data=null) | |
Insert a comment in preparation for a row that references it. | |
insertWithTempTable (IDatabase $dbw, $key, $comment=null, $data=null) | |
Insert a comment in a temporary table in preparation for a row that references it. | |
Static Public Member Functions | |
static | hash ( $text, $data) |
Hashing function for comment storage. | |
Public Attributes | |
const | COMMENT_CHARACTER_LIMIT = 500 |
Maximum length of a comment in UTF-8 characters. | |
const | MAX_DATA_LENGTH = 65535 |
Maximum length of serialized data in bytes. | |
Protected Attributes | |
$tempTables | |
Define fields that use temporary tables for transitional purposes Array keys are field names, values are arrays with these possible fields: | |
Definition at line 38 of file CommentStoreBase.php.
MediaWiki\CommentStore\CommentStoreBase::__construct | ( | $tempTables, | |
Language | $lang, | ||
$stage ) |
array | $tempTables | Define fields that use temporary tables for transitional purposes |
Language | $lang | Language to use for comment truncation. Defaults to content language. |
int | $stage | One of the MIGRATION_* constants, or an appropriate combination of SCHEMA_COMPAT_* constants. |
Definition at line 86 of file CommentStoreBase.php.
References $lang, MediaWiki\CommentStore\CommentStoreBase\$tempTables, SCHEMA_COMPAT_READ_BOTH, and SCHEMA_COMPAT_WRITE_BOTH.
MediaWiki\CommentStore\CommentStoreBase::createComment | ( | IDatabase | $dbw, |
$comment, | |||
array | $data = null ) |
Create a new CommentStoreComment, inserting it into the database if necessary.
If a comment is going to be passed to self::insert()
or the like multiple times, it will be more efficient to pass a CommentStoreComment once rather than making self::insert()
do it every time through.
$comment->id
if it's not already set. If $comment->id
is already set, it will not be verified that the specified comment actually exists or that it corresponds to the comment text, message, and/or data in the CommentStoreComment. IDatabase | $dbw | Database handle to insert on. Unused if $comment is a CommentStoreComment and $comment->id is set. |
string | Message | CommentStoreComment | $comment | Comment text or Message object, or a CommentStoreComment. |
array | null | $data | Structured data to store. Keys beginning with '_' are reserved. Ignored if $comment is a CommentStoreComment. |
Definition at line 401 of file CommentStoreBase.php.
References FormatJson\ALL_OK, FormatJson\encode(), MediaWiki\CommentStore\CommentStoreBase\hash(), Wikimedia\Rdbms\IDatabase\insert(), Wikimedia\Rdbms\IDatabase\insertId(), MediaWiki\CommentStore\CommentStoreBase\MAX_DATA_LENGTH, Wikimedia\Rdbms\IReadableDatabase\newSelectQueryBuilder(), MediaWiki\CommentStore\CommentStoreComment\newUnsavedComment(), SCHEMA_COMPAT_WRITE_NEW, and true.
MediaWiki\CommentStore\CommentStoreBase::getComment | ( | $key, | |
$row = null, | |||
$fallback = false ) |
Extract the comment from a row.
Use self::getJoin()
to ensure the row contains the needed data.
If you need to fake a comment in a row for some reason, set fields {$key}_text
(string) and {$key}_data
(JSON string or null).
string | $key | A key such as "rev_comment" identifying the comment field being fetched. |
stdClass | array | null | $row | Result row. |
bool | $fallback | If true, fall back as well as possible instead of throwing an exception. |
Definition at line 344 of file CommentStoreBase.php.
References $fallback.
MediaWiki\CommentStore\CommentStoreBase::getCommentLegacy | ( | IDatabase | $db, |
$key, | |||
$row = null, | |||
$fallback = false ) |
Extract the comment from a row, with legacy lookups.
If $row
might have been generated using self::getFields()
rather than self::getJoin()
, use this. Prefer self::getComment()
if you know callers used self::getJoin()
for the row fetch.
If you need to fake a comment in a row for some reason, set fields {$key}_text
(string) and {$key}_data
(JSON string or null).
IDatabase | $db | Database handle to use for lookup |
string | $key | A key such as "rev_comment" identifying the comment field being fetched. |
stdClass | array | null | $row | Result row. |
bool | $fallback | If true, fall back as well as possible instead of throwing an exception. |
Definition at line 372 of file CommentStoreBase.php.
References $fallback.
MediaWiki\CommentStore\CommentStoreBase::getFields | ( | $key | ) |
Get SELECT fields for the comment key.
Each resulting row should be passed to self::getCommentLegacy()
to get the actual comment.
self::getJoin()
instead.string | $key | A key such as "rev_comment" identifying the comment field being fetched. |
$vars
to IDatabase->select()
. All fields are aliased, so +
is safe to use. Definition at line 115 of file CommentStoreBase.php.
References MIGRATION_NEW, SCHEMA_COMPAT_READ_BOTH, SCHEMA_COMPAT_READ_NEW, and SCHEMA_COMPAT_READ_OLD.
MediaWiki\CommentStore\CommentStoreBase::getJoin | ( | $key | ) |
Get SELECT fields and joins for the comment key.
Each resulting row should be passed to self::getComment()
to get the actual comment.
string | $key | A key such as "rev_comment" identifying the comment field being fetched. |
$table
to IDatabase->select()
or SelectQueryBuilder::tables
$vars
to IDatabase->select()
or SelectQueryBuilder::fields
$join_conds
to IDatabase->select()
or SelectQueryBuilder::joinConds
All tables, fields, and joins are aliased, so +
is safe to use. Definition at line 154 of file CommentStoreBase.php.
References $t, MIGRATION_NEW, SCHEMA_COMPAT_READ_BOTH, SCHEMA_COMPAT_READ_NEW, and SCHEMA_COMPAT_READ_OLD.
MediaWiki\CommentStore\CommentStoreBase::getTempTableMigrationStage | ( | string | $key | ) |
string | $key |
Definition at line 573 of file CommentStoreBase.php.
|
static |
Hashing function for comment storage.
string | $text | Comment text |
string | null | $data | Comment data |
Definition at line 623 of file CommentStoreBase.php.
Referenced by MediaWiki\CommentStore\CommentStoreBase\createComment().
MediaWiki\CommentStore\CommentStoreBase::insert | ( | IDatabase | $dbw, |
$key, | |||
$comment = null, | |||
$data = null ) |
Insert a comment in preparation for a row that references it.
IDatabase | $dbw | Database handle to insert on |
string | $key | A key such as "rev_comment" identifying the comment field being fetched. |
string | Message | CommentStoreComment | null | $comment | As for self::createComment() |
array | null | $data | As for self::createComment() |
Definition at line 509 of file CommentStoreBase.php.
References MIGRATION_NEW, and SCHEMA_COMPAT_WRITE_OLD.
MediaWiki\CommentStore\CommentStoreBase::insertWithTempTable | ( | IDatabase | $dbw, |
$key, | |||
$comment = null, | |||
$data = null ) |
Insert a comment in a temporary table in preparation for a row that references it.
This is currently needed for "rev_comment". In the future that requirement will be removed.
IDatabase | $dbw | Database handle to insert on |
string | $key | A key such as "rev_comment" identifying the comment field being fetched. |
string | Message | CommentStoreComment | null | $comment | As for self::createComment() |
array | null | $data | As for self::createComment() |
Definition at line 545 of file CommentStoreBase.php.
References wfDeprecated().
|
protected |
Define fields that use temporary tables for transitional purposes Array keys are field names, values are arrays with these possible fields:
Definition at line 63 of file CommentStoreBase.php.
Referenced by MediaWiki\CommentStore\CommentStoreBase\__construct().
const MediaWiki\CommentStore\CommentStoreBase::COMMENT_CHARACTER_LIMIT = 500 |
Maximum length of a comment in UTF-8 characters.
Longer comments will be truncated.
Definition at line 44 of file CommentStoreBase.php.
const MediaWiki\CommentStore\CommentStoreBase::MAX_DATA_LENGTH = 65535 |
Maximum length of serialized data in bytes.
Longer data will result in an exception.
Definition at line 51 of file CommentStoreBase.php.
Referenced by MediaWiki\CommentStore\CommentStoreBase\createComment().