Skip to content

Commit

Permalink
Merge branch '2.2' of https://github.com/sulu/SuluArticleBundle into 2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasnatter committed Mar 10, 2021
2 parents 788105e + 70aade4 commit 37e9da7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/test-application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:

env:
DATABASE_URL: mysql://root:[email protected]:3306/sulu_test?serverVersion=5.7
PHPCR_TRANSPORT: ${{ matrix.phpcr-transport }}

strategy:
fail-fast: false
Expand All @@ -29,7 +30,6 @@ jobs:
lint: false
env:
SYMFONY_DEPRECATIONS_HELPER: disabled
PHPCR_TRANSPORT: doctrinedbal
ELASTICSEARCH_HOST: '127.0.0.1:9200'
DATABASE_CHARSET: UTF8
DATABASE_COLLATE: UTF8_BIN
Expand All @@ -45,7 +45,6 @@ jobs:
lint: true
env:
SYMFONY_DEPRECATIONS_HELPER: weak
PHPCR_TRANSPORT: jackrabbit
ELASTICSEARCH_HOST: '127.0.0.1:9200'

- php-version: '8.0'
Expand All @@ -59,7 +58,6 @@ jobs:
lint: false
env:
SYMFONY_DEPRECATIONS_HELPER: weak
PHPCR_TRANSPORT: jackrabbit
ELASTICSEARCH_HOST: '127.0.0.1:9200'

services:
Expand Down
1 change: 1 addition & 0 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public function getConfigTreeBuilder()
->end()
->arrayNode('types')
->useAttributeAsKey('name')
->normalizeKeys(false)
->prototype('array')
->children()
->scalarNode('translation_key')->end()
Expand Down
16 changes: 9 additions & 7 deletions Resources/phpcr-migrations/Version202005250920.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private function upgrade(SessionInterface $session)
{
$queryManager = $session->getWorkspace()->getQueryManager();

$query = 'SELECT * FROM [nt:unstructured] WHERE ([jcr:mixinTypes] = "sulu:article")';
$query = 'SELECT * FROM [nt:unstructured] WHERE ([jcr:mixinTypes] = "sulu:article" OR [jcr:mixinTypes] = "sulu:articlepage")';
$rows = $queryManager->createQuery($query, 'JCR-SQL2')->execute();

foreach ($rows as $row) {
Expand All @@ -54,8 +54,9 @@ private function upgrade(SessionInterface $session)
foreach ($node->getProperties() as $property) {
if (\is_string($property->getValue())) {
$propertyValue = json_decode($property->getValue(), true);
if (\is_array($propertyValue) && \array_key_exists('presentAs', $propertyValue) &&
\array_key_exists('limitResult', $propertyValue) && \array_key_exists('sortBy', $propertyValue)) {

// decide if property is of type smart_content type by checking for presentAs and sortBy
if (\is_array($propertyValue) && \array_key_exists('presentAs', $propertyValue) && \array_key_exists('sortBy', $propertyValue)) {
if (is_array($propertyValue['sortBy'])) {
$propertyValue['sortBy'] = \count($propertyValue['sortBy']) > 0 ? $propertyValue['sortBy'][0] : null;
}
Expand All @@ -71,7 +72,7 @@ private function downgrade(SessionInterface $session)
{
$queryManager = $session->getWorkspace()->getQueryManager();

$query = 'SELECT * FROM [nt:unstructured] WHERE ([jcr:mixinTypes] = "sulu:article")';
$query = 'SELECT * FROM [nt:unstructured] WHERE ([jcr:mixinTypes] = "sulu:article" OR [jcr:mixinTypes] = "sulu:articlepage")';
$rows = $queryManager->createQuery($query, 'JCR-SQL2')->execute();

foreach ($rows as $row) {
Expand All @@ -80,9 +81,10 @@ private function downgrade(SessionInterface $session)
foreach ($node->getProperties() as $property) {
if (\is_string($property->getValue())) {
$propertyValue = json_decode($property->getValue(), true);
if (\is_array($propertyValue) && \array_key_exists('presentAs', $propertyValue) &&
\array_key_exists('limitResult', $propertyValue) && \array_key_exists('sortBy', $propertyValue)) {
if (is_array($propertyValue['sortBy'])) {

// decide if property is of type smart_content type by checking for presentAs and sortBy
if (\is_array($propertyValue) && \array_key_exists('presentAs', $propertyValue) && \array_key_exists('sortBy', $propertyValue)) {
if (!\is_array($propertyValue['sortBy'])) {
$propertyValue['sortBy'] = [$propertyValue['sortBy']];
}

Expand Down

0 comments on commit 37e9da7

Please sign in to comment.