Comments final readonly class
Minn\Content\Comments · public/minn/src/Minn/Content/Comments.php · 245 lines
Reads and writes over the comments table.
Constants and properties
| private | UPDATABLE = array ( 0 => 'comment_post_ID', 1 => 'comment_author', 2 => 'comment_author_email', 3 => 'comment_author_url', 4 => 'comment_author_IP', 5 => 'comment_date', 6 => 'comment_date_gmt', 7 => 'comment_content', 8 => 'comment_karma', 9 => 'comment_approved', 10 => 'comment_agent', 11 => 'comment_type', 12 => 'comment_parent', 13 => 'user_id', ) | |
| private | FIELD_LENGTHS = array ( 'comment_author' => 245, 'comment_author_email' => 100, 'comment_author_url' => 200, 'comment_content' => 65525, ) | The comment form fields whose length the table limits, with the length a stock table gives each. |
| private | readonly Minn\Db $db | Promoted from the constructor. |
Public
| new | __construct(Minn\Db $db)# | |||||||
| method | find(int $id): ?Minn\Content\CommentRecord# | The comment with this id, or null. | ||||||
| method | meta(int $id, string $key): ?string# | One meta value of a comment, or null when it has none. | ||||||
| method | addMeta(int $id, string $key, string $value): void# | Adds a meta row; a second row with the same key is allowed, as the reference allows it. | ||||||
| method | duplicate(int $postId, string $author, string $email, string $content, int $userId): bool# | The same words on the same post from the same person, in any status but trash or spam. | ||||||
| method | duplicateId(int $postId, string $author, string $email, string $content, int $userId): ?int# | The id of a comment this one would repeat (same post, same author, same words, not spam or trash), or null. | ||||||
| method | lastCommentTime(int $userId, string $address, string $email, string $sinceGmt): ?int# | When the commenter last commented since the GMT time given, as a Unix time: matched by user id when signed in, else by address, or by email either way. Null when they have not. | ||||||
| method | pendingCounts(array $postIds): array# | Held comments per post, for the ids given (a post without any reads 0). | ||||||
| method | previouslyApproved(string $author, string $email): bool# | True when this name and email already have an approved comment. | ||||||
| method | insert(array $columns): int# | Inserts a row from column => value pairs and returns the new id.
| ||||||
| method | update(int $id, array $columns): void# | Sets the given columns on one comment.
| ||||||
| method | fieldLengths(): array# | How long each comment form field may be, read from the table as it is: a character column allows its declared length, a text column ten bytes fewer than it holds. A column the schema does not describe keeps the stock table's length. @return array<string, int> | ||||||
| method | idsOf(int $postId): array# | The ids of every comment on a post, whatever its status, oldest first. @return list<int> @return list<int> | ||||||
| method | statusesOf(int $postId): array# | Every comment on a post as id => status, which the trash keeps to give back. @return array<int, string> @return array<int, string> | ||||||
| method | setStatusOf(array $ids, string $status): void# | Sets one status on the given comments. @param list<int> $ids
| ||||||
| method | orphanReplies(int $id, int $parent): void# | A deleted comment's replies move up to its parent. | ||||||
| method | delete(int $id): void# | Removes the comment and its meta; the post's count is the caller's to recount. | ||||||
| method | recount(int $postId): void# | Recomputes a post's stored comment_count (approved comments only). | ||||||
| static | statusOf(string $approved): string# | DB approval token to the wp/v2 status string. | ||||||
| static | tokensFor(string $status): ?array# | wp/v2 status parameter to DB token(s); null for an unknown status. @return list<string>|null | ||||||
| static | changedColumns(array $data, array $current): array# | The columns an update really changes, compared as strings against the stored row; the approval shorthands hold/approve become the stored 0/1.
@return array<string, mixed> |
Nothing matches.