MediaWiki REL1_30
|
CommentStore handles storage of comments (edit summaries, log reasons, etc) in the database. More...
Public Member Functions | |
__construct ( $key, Language $lang=null) | |
createComment (IDatabase $dbw, $comment, array $data=null) | |
Create a new CommentStoreComment, inserting it into the database if necessary. | |
getComment ( $row, $fallback=false) | |
Extract the comment from a row. | |
getCommentLegacy (IDatabase $db, $row, $fallback=false) | |
Extract the comment from a row, with legacy lookups. | |
getFields () | |
Get SELECT fields for the comment key. | |
getJoin () | |
Get SELECT fields and joins for the comment key. | |
insert (IDatabase $dbw, $comment, $data=null) | |
Insert a comment in preparation for a row that references it. | |
insertWithTempTable (IDatabase $dbw, $comment, $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. | |
static | newKey ( $key) |
Static constructor for easier chaining. | |
Public Attributes | |
const | COMMENT_CHARACTER_LIMIT = 1000 |
Maximum length of a comment in UTF-8 characters. | |
const | MAX_COMMENT_LENGTH = 65535 |
Maximum length of a comment in bytes. | |
const | MAX_DATA_LENGTH = 65535 |
Maximum length of serialized data in bytes. | |
Static Protected Member Functions | |
static | decodeMessage ( $data) |
Decode a message that was encoded by self::encodeMessage() | |
static | encodeMessage (Message $msg) |
Encode a Message as a PHP data structure. | |
Protected Attributes | |
array null | $joinCache = null |
Cache for self::getJoin() | |
string | $key |
Language | $lang |
Language to use for comment truncation. | |
int | $stage |
One of the MIGRATION_* constants. | |
Static Protected Attributes | |
static array | $formerTempTables = [] |
Fields that formerly used $tempTables Key is '$key', value is the MediaWiki version in which it was removed from $tempTables. | |
static array | $tempTables |
Define fields that use temporary tables for transitional purposes Keys are '$key', values are arrays with four fields: | |
Private Member Functions | |
getCommentInternal (IDatabase $db=null, $row, $fallback=false) | |
Extract the comment from a row. | |
insertInternal (IDatabase $dbw, $comment, $data) | |
Implementation for self::insert() and self::insertWithTempTable() | |
CommentStore handles storage of comments (edit summaries, log reasons, etc) in the database.
Definition at line 30 of file CommentStore.php.
CommentStore::__construct | ( | $key, | |
Language | $lang = null ) |
string | $key | A key such as "rev_comment" identifying the comment field being fetched. |
Language | $lang | Language to use for comment truncation. Defaults to $wgContLang. |
Definition at line 100 of file CommentStore.php.
References $key, $lang, $wgCommentTableSchemaMigrationStage, $wgContLang, and key.
CommentStore::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 383 of file CommentStore.php.
References encodeMessage(), hash(), Wikimedia\Rdbms\IDatabase\insert(), Wikimedia\Rdbms\IDatabase\insertId(), MAX_DATA_LENGTH, MIGRATION_OLD, CommentStoreComment\newUnsavedComment(), Wikimedia\Rdbms\IDatabase\selectField(), true, and wfMessage().
Referenced by insertInternal().
|
staticprotected |
Decode a message that was encoded by self::encodeMessage()
array | $data |
Definition at line 558 of file CommentStore.php.
References $key, array(), and decodeMessage().
Referenced by decodeMessage(), and getCommentInternal().
|
staticprotected |
Encode a Message as a PHP data structure.
Message | $msg |
Definition at line 539 of file CommentStore.php.
References $key, $params, and encodeMessage().
Referenced by createComment(), and encodeMessage().
CommentStore::getComment | ( | $row, | |
$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).
object | array | $row | Result row. |
bool | $fallback | If true, fall back as well as possible instead of throwing an exception. |
Definition at line 340 of file CommentStore.php.
References $fallback, and getCommentInternal().
|
private |
Extract the comment from a row.
Shared implementation for getComment() and getCommentLegacy()
IDatabase | null | $db | Database handle for getCommentLegacy(), or null for getComment() |
object | array | $row | |
bool | $fallback |
Definition at line 216 of file CommentStore.php.
References $fallback, $key, $t, array(), decodeMessage(), MIGRATION_NEW, MIGRATION_OLD, object, and wfLogWarning().
Referenced by getComment(), and getCommentLegacy().
CommentStore::getCommentLegacy | ( | IDatabase | $db, |
$row, | |||
$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 |
object | array | $row | Result row. |
bool | $fallback | If true, fall back as well as possible instead of throwing an exception. |
Definition at line 359 of file CommentStore.php.
References $fallback, and getCommentInternal().
CommentStore::getFields | ( | ) |
Get SELECT fields for the comment key.
Each resulting row should be passed to self::getCommentLegacy()
to get the actual comment.
self::getJoin()
instead. $vars
to IDatabase->select()
. All fields are aliased, so +
is safe to use. Definition at line 129 of file CommentStore.php.
References $key, key, MIGRATION_NEW, and MIGRATION_OLD.
CommentStore::getJoin | ( | ) |
Get SELECT fields and joins for the comment key.
Each resulting row should be passed to self::getComment()
to get the actual comment.
Definition at line 160 of file CommentStore.php.
References $joinCache, $key, $t, $tables, key, MIGRATION_NEW, and MIGRATION_OLD.
|
static |
Hashing function for comment storage.
string | $text | Comment text |
string | null | $data | Comment data |
Definition at line 577 of file CommentStore.php.
Referenced by createComment(), and MigrateComments\loadCommentIDs().
CommentStore::insert | ( | IDatabase | $dbw, |
$comment, | |||
$data = null ) |
Insert a comment in preparation for a row that references it.
IDatabase | $dbw | Database handle to insert on |
string | Message | CommentStoreComment | $comment | As for self::createComment() |
array | null | $data | As for self::createComment() |
Definition at line 493 of file CommentStore.php.
References insertInternal(), key, and list.
|
private |
Implementation for self::insert()
and self::insertWithTempTable()
IDatabase | $dbw | |
string | Message | CommentStoreComment | $comment | |
array | null | $data |
Definition at line 450 of file CommentStore.php.
References $key, $t, createComment(), Wikimedia\Rdbms\IDatabase\insert(), key, and MIGRATION_WRITE_BOTH.
Referenced by insert(), and insertWithTempTable().
CommentStore::insertWithTempTable | ( | IDatabase | $dbw, |
$comment, | |||
$data = null ) |
Insert a comment in a temporary table in preparation for a row that references it.
This is currently needed for "rev_comment" and "img_description". In the future that requirement will be removed.
IDatabase | $dbw | Database handle to insert on |
string | Message | CommentStoreComment | $comment | As for self::createComment() |
array | null | $data | As for self::createComment() |
Definition at line 518 of file CommentStore.php.
References insertInternal(), key, list, and wfDeprecated().
|
static |
Static constructor for easier chaining.
string | $key | A key such as "rev_comment" identifying the comment field being fetched. |
Definition at line 114 of file CommentStore.php.
References $key.
Referenced by Revision\__construct(), RenameUserCleanup\checkRenameLog(), RevDelLogList\doQuery(), WikiPage\doUpdateRestrictions(), WikiExporter\dumpFrom(), FeedUtils\formatDiff(), DeletedContribsPager\formatRevisionRow(), ImageListPager\formatValue(), ProtectedPagesPager\formatValue(), BlockListPager\formatValue(), RevDelLogItem\getApiData(), RecentChange\getAttribute(), Block\getAutoblockUpdateArray(), LocalFile\getCacheFields(), DatabaseLogEntry\getComment(), RCDatabaseLogEntry\getComment(), Block\getDatabaseArray(), RevDelLogItem\getHTML(), EditPage\getLastDelete(), IRCColourfulRCFeedFormatter\getLine(), BlockListPager\getQueryInfo(), DeletedContribsPager\getQueryInfo(), NewPagesPager\getQueryInfo(), ProtectedPagesPager\getQueryInfo(), ImageListPager\getQueryInfoReal(), PageArchive\getRevision(), DatabaseLogEntry\getSelectQueryData(), WikiRevision\importLogItem(), Block\initFromRow(), ManualLogEntry\insert(), Revision\insertOn(), PageArchive\listRevisions(), RecentChange\loadFromRow(), ArchivedFile\loadFromRow(), LocalFile\loadFromRow(), Revision\newFromArchiveRow(), OldLocalFile\recordOldUpload(), SpecialNewpages\revisionFromRcResult(), RecentChange\save(), LogPage\saveContent(), Revision\selectArchiveFields(), Block\selectFields(), RecentChange\selectFields(), ArchivedFile\selectFields(), LocalFile\selectFields(), OldLocalFile\selectFields(), Revision\selectFields(), EditPage\showEditForm(), ApiQueryBase\showHiddenUsersAddBlockInfo(), CommentStoreTest\testConstructor(), PageArchive\undeleteRevisions(), XmlDumpWriter\writeLogItem(), and XmlDumpWriter\writeRevision().
|
staticprotected |
Fields that formerly used $tempTables Key is '$key', value is the MediaWiki version in which it was removed from $tempTables.
Definition at line 80 of file CommentStore.php.
|
protected |
|
protected |
Definition at line 83 of file CommentStore.php.
Referenced by __construct(), decodeMessage(), encodeMessage(), getCommentInternal(), getFields(), getJoin(), insertInternal(), and newKey().
|
protected |
Language to use for comment truncation.
Definition at line 92 of file CommentStore.php.
Referenced by __construct().
|
protected |
One of the MIGRATION_* constants.
Definition at line 86 of file CommentStore.php.
|
staticprotected |
Define fields that use temporary tables for transitional purposes Keys are '$key', values are arrays with four fields:
Definition at line 60 of file CommentStore.php.
const CommentStore::COMMENT_CHARACTER_LIMIT = 1000 |
Maximum length of a comment in UTF-8 characters.
Longer comments will be truncated.
Definition at line 36 of file CommentStore.php.
Referenced by CommentStoreTest\testInsertTruncation().
const CommentStore::MAX_COMMENT_LENGTH = 65535 |
Maximum length of a comment in bytes.
Longer comments will be truncated.
Definition at line 43 of file CommentStore.php.
const CommentStore::MAX_DATA_LENGTH = 65535 |
Maximum length of serialized data in bytes.
Longer data will result in an exception.
Definition at line 50 of file CommentStore.php.
Referenced by createComment().