Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArticleIndexer throws error when property value is null #597

Open
ymc-sise opened this issue Nov 1, 2021 · 0 comments
Open

ArticleIndexer throws error when property value is null #597

ymc-sise opened this issue Nov 1, 2021 · 0 comments

Comments

@ymc-sise
Copy link

ymc-sise commented Nov 1, 2021

Q A
Bug? maybe
New Feature? no
SuluArticleBundle Version
Sulu Version 2.3.6

Actual Behavior

When I remove a locale of an article programmatically, the ArticleIndexer will throw an error:

  at /var/www/sulu/vendor/sulu/article-bundle/Document/Index/ArticleIndexer.php:294
 Sulu\Bundle\ArticleBundle\Document\Index\ArticleIndexer->getBlockContentFieldsRecursive() at /var/www/sulu/vendor/sulu/article-bundle/Document/Index/ArticleIndexer.php:279
 Sulu\Bundle\ArticleBundle\Document\Index\ArticleIndexer->getContentFields() at /var/www/sulu/vendor/sulu/article-bundle/Document/Index/ArticleIndexer.php:245
 Sulu\Bundle\ArticleBundle\Document\Index\ArticleIndexer->createOrUpdateArticle() at /var/www/sulu/vendor/sulu/article-bundle/Document/Index/ArticleIndexer.php:440
 Sulu\Bundle\ArticleBundle\Document\Index\ArticleIndexer->removeLocale() at /var/www/sulu/vendor/sulu/article-bundle/Document/Subscriber/ArticleSubscriber.php:471
 Sulu\Bundle\ArticleBundle\Document\Subscriber\ArticleSubscriber->handleRemoveLocale() at /var/www/sulu/vendor/symfony/event-dispatcher/EventDispatcher.php:230
 Symfony\Component\EventDispatcher\EventDispatcher->callListeners() at /var/www/sulu/vendor/symfony/event-dispatcher/EventDispatcher.php:59
 Symfony\Component\EventDispatcher\EventDispatcher->dispatch() at /var/www/sulu/vendor/sulu/sulu/src/Sulu/Component/DocumentManager/DocumentManager.php:70
 Sulu\Component\DocumentManager\DocumentManager->removeLocale() at 

Expected Behavior

removeLocale will run as expected

Steps to Reproduce

The behaviour is strange and difficult to explain. For a particular article, I can't remove the locale because of this error.

It happens in $contentFields = array_merge($contentFields, $this->getBlockContentFieldsRecursive($blocks, $document, $property, $tag)); of getContentFields() in Document/Index/ArticleIndexer.php

$blocks is null and it will throw an error, but it in my opinion $blocks should be [].

The block property which gives a null value does not appear in the according XML content in the phpcr_nodes table. What could be the problem here? Its confusing, because If I add a new article without setting this block property (and the property does not appear in the XML content as well), the locale can be removed without any error.

Possible Solutions

Maybe add an if in getContentFields()-Method?

               if ($blocks === null) {
                    $blocks = [];
                }

If I add the if block, the locale can be removed without any error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant