X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fcontent_moderation%2Fsrc%2FRevisionTracker.php;fp=web%2Fcore%2Fmodules%2Fcontent_moderation%2Fsrc%2FRevisionTracker.php;h=0000000000000000000000000000000000000000;hp=201123784337bd80ea1c4f7eabfb123e0224c9be;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hpb=aea91e65e895364e460983b890e295aa5d5540a5 diff --git a/web/core/modules/content_moderation/src/RevisionTracker.php b/web/core/modules/content_moderation/src/RevisionTracker.php deleted file mode 100644 index 201123784..000000000 --- a/web/core/modules/content_moderation/src/RevisionTracker.php +++ /dev/null @@ -1,152 +0,0 @@ -connection = $connection; - $this->tableName = $table; - } - - /** - * {@inheritdoc} - */ - public function setLatestRevision($entity_type_id, $entity_id, $langcode, $revision_id) { - try { - $this->recordLatestRevision($entity_type_id, $entity_id, $langcode, $revision_id); - } - catch (DatabaseExceptionWrapper $e) { - $this->ensureTableExists(); - $this->recordLatestRevision($entity_type_id, $entity_id, $langcode, $revision_id); - } - - return $this; - } - - /** - * Records the latest revision of a given entity. - * - * @param string $entity_type_id - * The machine name of the type of entity. - * @param string $entity_id - * The Entity ID in question. - * @param string $langcode - * The langcode of the revision we're saving. Each language has its own - * effective tree of entity revisions, so in different languages - * different revisions will be "latest". - * @param int $revision_id - * The revision ID that is now the latest revision. - * - * @return int - * One of the valid returns from a merge query's execute method. - */ - protected function recordLatestRevision($entity_type_id, $entity_id, $langcode, $revision_id) { - return $this->connection->merge($this->tableName) - ->keys([ - 'entity_type' => $entity_type_id, - 'entity_id' => $entity_id, - 'langcode' => $langcode, - ]) - ->fields([ - 'revision_id' => $revision_id, - ]) - ->execute(); - } - - /** - * Checks if the table exists and create it if not. - * - * @return bool - * TRUE if the table was created, FALSE otherwise. - */ - protected function ensureTableExists() { - try { - if (!$this->connection->schema()->tableExists($this->tableName)) { - $this->connection->schema()->createTable($this->tableName, $this->schemaDefinition()); - return TRUE; - } - } - catch (SchemaObjectExistsException $e) { - // If another process has already created the table, attempting to - // recreate it will throw an exception. In this case just catch the - // exception and do nothing. - return TRUE; - } - return FALSE; - } - - /** - * Defines the schema for the tracker table. - * - * @return array - * The schema API definition for the SQL storage table. - */ - protected function schemaDefinition() { - $schema = [ - 'description' => 'Tracks the latest revision for any entity', - 'fields' => [ - 'entity_type' => [ - 'description' => 'The entity type', - 'type' => 'varchar_ascii', - 'length' => 255, - 'not null' => TRUE, - 'default' => '', - ], - 'entity_id' => [ - 'description' => 'The entity ID', - 'type' => 'int', - 'length' => 255, - 'not null' => TRUE, - 'default' => 0, - ], - 'langcode' => [ - 'description' => 'The language of the entity revision', - 'type' => 'varchar', - 'length' => 12, - 'not null' => TRUE, - 'default' => '', - ], - 'revision_id' => [ - 'description' => 'The latest revision ID for this entity', - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - ], - ], - 'primary key' => ['entity_type', 'entity_id', 'langcode'], - ]; - - return $schema; - } - -}