Skip to content

Commit

Permalink
Merge branch '7.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Longosz committed May 29, 2018
2 parents 6b81118 + be796c6 commit 2c01703
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 23 deletions.
6 changes: 4 additions & 2 deletions data/mysql/schema.sql
Expand Up @@ -625,7 +625,8 @@ CREATE TABLE `ezcontentobject` (
KEY `ezcontentobject_lmask` (`language_mask`),
KEY `ezcontentobject_owner` (`owner_id`),
KEY `ezcontentobject_pub` (`published`),
KEY `ezcontentobject_status` (`status`)
KEY `ezcontentobject_status` (`status`),
KEY `ezcontentobject_section` (`section_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;

Expand Down Expand Up @@ -764,7 +765,8 @@ CREATE TABLE `ezcontentobject_tree` (
KEY `ezcontentobject_tree_p_node_id` (`parent_node_id`),
KEY `ezcontentobject_tree_path` (`path_string` (191)),
KEY `ezcontentobject_tree_path_ident` (`path_identification_string`(50)),
KEY `modified_subnode` (`modified_subnode`)
KEY `modified_subnode` (`modified_subnode`),
KEY `ezcontentobject_tree_contentobject_id_path_string` (`path_string`, `contentobject_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;

Expand Down
6 changes: 6 additions & 0 deletions data/update/mysql/dbupdate-6.7.7-to-6.7.8.sql
@@ -0,0 +1,6 @@
SET default_storage_engine=InnoDB;
-- Set storage engine schema version number
UPDATE ezsite_data SET value='6.7.8' WHERE name='ezpublish-version';

CREATE INDEX `ezcontentobject_tree_contentobject_id_path_string` ON `ezcontentobject_tree` (`path_string`, `contentobject_id`);
CREATE INDEX `ezcontentobject_section` ON `ezcontentobject` (`section_id`);
5 changes: 5 additions & 0 deletions data/update/postgres/dbupdate-6.7.7-to-6.7.8.sql
@@ -0,0 +1,5 @@
-- Set storage engine schema version number
UPDATE ezsite_data SET value='6.7.8' WHERE name='ezpublish-version';

CREATE INDEX ezcontentobject_tree_contentobject_id_path_string ON ezcontentobject_tree (path_string, contentobject_id);
CREATE INDEX ezcontentobject_section ON ezcontentobject (section_id);
Expand Up @@ -40,6 +40,11 @@ class DoctrineDatabase extends Gateway
*/
protected $handler;

/**
* @var \Doctrine\DBAL\Connection
*/
protected $connection;

/**
* Construct from database handler.
*
Expand All @@ -48,6 +53,7 @@ class DoctrineDatabase extends Gateway
public function __construct(DatabaseHandler $handler)
{
$this->handler = $handler;
$this->connection = $handler->getConnection();
}

/**
Expand Down Expand Up @@ -1330,39 +1336,49 @@ public function removeElementFromTrash($id)
/**
* Set section on all content objects in the subtree.
*
* @param mixed $pathString
* @param mixed $sectionId
* @param string $pathString
* @param int $sectionId
*
* @return bool
*/
public function setSectionForSubtree($pathString, $sectionId)
{
$query = $this->handler->createUpdateQuery();

$subSelect = $query->subSelect();
$subSelect
->select($this->handler->quoteColumn('contentobject_id'))
->from($this->handler->quoteTable('ezcontentobject_tree'))
$selectContentIdsQuery = $this->connection->createQueryBuilder();
$selectContentIdsQuery
->select('t.contentobject_id')
->from('ezcontentobject_tree', 't')
->where(
$subSelect->expr->like(
$this->handler->quoteColumn('path_string'),
$subSelect->bindValue($pathString . '%')
$selectContentIdsQuery->expr()->like(
't.path_string',
$selectContentIdsQuery->createPositionalParameter("{$pathString}%")
)
);

$query
->update($this->handler->quoteTable('ezcontentobject'))
$contentIds = array_map(
'intval',
$selectContentIdsQuery->execute()->fetchAll(PDO::FETCH_COLUMN)
);

if (empty($contentIds)) {
return false;
}

$updateSectionQuery = $this->connection->createQueryBuilder();
$updateSectionQuery
->update('ezcontentobject')
->set(
$this->handler->quoteColumn('section_id'),
$query->bindValue($sectionId)
'section_id',
$updateSectionQuery->createPositionalParameter($sectionId, PDO::PARAM_INT)
)
->where(
$query->expr->in(
$this->handler->quoteColumn('id'),
$subSelect
$updateSectionQuery->expr()->in(
'id',
$contentIds
)
);
$query->prepare()->execute();
$affectedRows = $updateSectionQuery->execute();

return $affectedRows > 0;
}

/**
Expand Down
Expand Up @@ -207,7 +207,8 @@ CREATE TABLE ezcontentobject (
KEY ezcontentobject_owner (owner_id),
KEY ezcontentobject_pub (published),
UNIQUE KEY ezcontentobject_remote_id (remote_id),
KEY ezcontentobject_status (status)
KEY ezcontentobject_status (status),
KEY ezcontentobject_section (section_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

DROP TABLE IF EXISTS ezcontentobject_attribute;
Expand Down Expand Up @@ -311,7 +312,8 @@ CREATE TABLE ezcontentobject_tree (
KEY ezcontentobject_tree_p_node_id (parent_node_id),
KEY ezcontentobject_tree_path (path_string),
KEY ezcontentobject_tree_path_ident (path_identification_string(50)),
KEY modified_subnode (modified_subnode)
KEY modified_subnode (modified_subnode),
KEY ezcontentobject_tree_contentobject_id_path_string (path_string, contentobject_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

DROP TABLE IF EXISTS ezcontentobject_version;
Expand Down
Expand Up @@ -520,6 +520,8 @@ CREATE UNIQUE INDEX ezcontentobject_remote_id ON ezcontentobject USING btree (re

CREATE INDEX ezcontentobject_status ON ezcontentobject USING btree (status);

CREATE INDEX ezcontentobject_section ON ezcontentobject USING btree (section_id);

CREATE INDEX ezcontentobject_attribute_co_id_ver_lang_code ON ezcontentobject_attribute USING btree (contentobject_id, "version", language_code);

CREATE INDEX ezcontentobject_attribute_language_code ON ezcontentobject_attribute USING btree (language_code);
Expand Down Expand Up @@ -564,6 +566,8 @@ CREATE INDEX ezcontentobject_tree_path ON ezcontentobject_tree USING btree (path

CREATE INDEX ezcontentobject_tree_path_ident ON ezcontentobject_tree USING btree (path_identification_string);

CREATE INDEX ezcontentobject_tree_contentobject_id_path_string ON ezcontentobject_tree USING btree (path_string, contentobject_id);

CREATE INDEX modified_subnode ON ezcontentobject_tree USING btree (modified_subnode);

CREATE INDEX ezcobj_version_creator_id ON ezcontentobject_version USING btree (creator_id);
Expand Down
Expand Up @@ -189,6 +189,7 @@ CREATE INDEX ezcontentobject_lmask ON ezcontentobject (language_mask);
CREATE INDEX ezcontentobject_owner ON ezcontentobject (owner_id);
CREATE INDEX ezcontentobject_pub ON ezcontentobject (published);
CREATE INDEX ezcontentobject_status ON ezcontentobject (status);
CREATE INDEX ezcontentobject_section ON ezcontentobject (section_id);

CREATE TABLE ezcontentobject_attribute (
attribute_original_id integer DEFAULT 0,
Expand Down Expand Up @@ -286,6 +287,7 @@ CREATE INDEX ezcontentobject_tree_p_node_id ON ezcontentobject_tree (parent_node
CREATE INDEX ezcontentobject_tree_path ON ezcontentobject_tree (path_string);
CREATE INDEX ezcontentobject_tree_path_ident ON ezcontentobject_tree (path_identification_string);
CREATE INDEX modified_subnode ON ezcontentobject_tree (modified_subnode);
CREATE INDEX ezcontentobject_tree_contentobject_id_path_string ON ezcontentobject_tree (path_string, contentobject_id);

CREATE TABLE ezcontentobject_version (
contentobject_id integer,
Expand Down

0 comments on commit 2c01703

Please sign in to comment.