addon_migration_tool icon indicating copy to clipboard operation
addon_migration_tool copied to clipboard

Issue when adding content to import batch

Open martbase opened this issue 8 years ago • 1 comments

When adding content to an import batch an error dialog pops up before the process is completed.

Using concrete5 ver 8.2.1 and migration_tool ver 0.8.0

Error details Error $stack->setPosition($position); if ($node->area->blocks->block) { $blocks = $node->area->blocks->block; } elseif ($node->area->block) { // 5.6 $blocks = $node->area->block; } if (isset($blocks)) { $i = 0; foreach ($blocks as $blockNode) { if ($blockNode['type']) { $block = new StackBlock(); $block->setType((string) $blockNode['type']); $block->setName((string) $blockNode['name']); $bFilename = (string) $blockNode['custom-template']; if ($bFilename) { $block->setCustomTemplate($bFilename); } $value = $this->blockImporter->driver('unmapped')->parse($blockNode); if (isset($blockNode->style)) { $styleSet = $this->styleSetImporter->import($blockNode->style); $block->setStyleSet($styleSet); } $block->setBlockValue($value); $block->setPosition($i); $block->setStack($stack); $stack->getBlocks()->add($block); ++$i; } } } ++$position; $collection->getStacks()->add($stack); $stack->setCollection($collection); } } return $collection; }}

Possibly triggered in .\packages\migration_tool\src\PortlandLabs\Concrete5\MigrationTool\Importer\CIF\Element\Stack.php

class Stack implements ElementParserInterface
{
    public function getObjectCollection(\SimpleXMLElement $element, Batch $batch)
    { // Bug likely triggered in this method   
        $this->simplexml = $element;
        $collection = new StackObjectCollection();
        if ($element->stacks) {
            $position = 0;
            foreach ($element->stacks->children() as $node) {
                $stack = $this->parseStack($node);
                $stack->setPosition($position); ```

martbase avatar Nov 08 '17 09:11 martbase

Error still being encountered while importing a batch - using Concrete5 v8.3.1 and migration tool v0.8.6

With error detail in message mode concrete5 reports:- An unexpected error occurred. Call to a member function import() on null

With error detail in debug mode concrete5 outputs:- $stack->setPosition($position); if ($node->area->blocks->block) { $blocks = $node->area->blocks->block; } elseif ($node->area->block) { // 5.6 $blocks = $node->area->block; } if (isset($blocks)) { $i = 0; foreach ($blocks as $blockNode) { if ($blockNode['type']) { $block = new StackBlock(); $block->setType((string) $blockNode['type']); $block->setName((string) $blockNode['name']); $bFilename = (string) $blockNode['custom-template']; if ($bFilename) { $block->setCustomTemplate($bFilename); } $value = $this->blockImporter->driver('unmapped')->parse($blockNode); if (isset($blockNode->style)) { $styleSet = $this->styleSetImporter->import($blockNode->style); $block->setStyleSet($styleSet); } $block->setBlockValue($value); $block->setPosition($i); $block->setStack($stack); $stack->getBlocks()->add($block); ++$i; } } } ++$position; $collection->getStacks()->add($stack); $stack->setCollection($collection); } } return $collection; }} c5modernl8st.zip

I have traced the error to the following file packages\migration_tool\src\PortlandLabs\Concrete5\MigrationTool\Importer\CIF\Element\Stack.php

Adding return $collection; in function getObjectCollection on line 45 just after $stack->setPosition($position); allows the import to continue.

I have attached the import content file for trouble-shooting

Steps to reproduce: Install Concrete5 v8.3.1 with empty content install a custom theme install migration tool (v0.8.6) create import batch add content to batch (c5modernl8st.xml)

martbase avatar Jan 17 '18 21:01 martbase