dachcom-digital / pimcore-seo

The last SEO Bundle for Pimcore you'll ever need!
Other
38 stars 14 forks source link

ElementMetaDataManager::getElementData(): Argument #2 ($elementId) must be of type int, null given #57

Closed NiklasBr closed 6 months ago

NiklasBr commented 7 months ago
Q A
Bug report? yes
Feature request? no

Running CLI with an up() migration causes this error:

    public function up(Schema $schema): void
    {
        $sites = [ /* listing of Site */  ];
        foreach ($sites as $site) {
            $newFolder = Folder::create($site->getRootDocument()->getId(), [
                'key' => 'Configurators',
                'locked' => true,
            ]);
            $this->write("Created folder: {$newFolder->getRealFullPath()}");

            $newPage = Page::create($newFolder->getId(), [
                'key' => 'ultima-connect',
                'controller' => 'App\Controller\ConfiguratorController::indexAction',
                'template' => 'product/configurator/uc.html.twig',
                'locked' => true,
                'published' => true,
            ]);
            $this->write("Created page: {$newPage->getRealFullPath()}");
        }
    }

Error

15:32:59 [notice] Created folder: /Main sites/DK/Configurators
15:32:59 [error] Migration App\Migrations\Version20230830115802 failed during Execution. Error: "SeoBundle\Manager\ElementMetaDataManager::getElementData(): Argument #2 ($elementId) must be of type int, null given, called in /var/www/pimcore/vendor/dachcom-digital/seo/src/SeoBundle/MetaData/Extractor/IntegratorExtractor.php on line 62"
15:33:00 
15:33:00 In ElementMetaDataManager.php line 52:
15:33:00                                                                                
15:33:00   SeoBundle\Manager\ElementMetaDataManager::getElementData(): Argument #2 ($e  
15:33:00   lementId) must be of type int, null given, called in /var/www/pimcore/vendo  
15:33:00   r/dachcom-digital/seo/src/SeoBundle/MetaData/Extractor/IntegratorExtractor.  
15:33:00   php on line 62                                                     
NiklasBr commented 7 months ago

Same issue appears in Pimcore admin on Save / publish

image

solverat commented 6 months ago

@NiklasBr thanks! But I'm curious: How is this even possible (especially your second comment)? If $elementType is not null, one of those the statements were right:

if ($element instanceof Concrete) {
    $elementId = $element->getId();
    $elementType = 'object';
} elseif ($element instanceof Document) {
    $elementId = $element->getId();
    $elementType = 'document';
}

Why the heck does $element->getId() returns null?

NiklasBr commented 6 months ago

I have no idea actually, well except for the fact that somehow palpatine surv... I mean the method returned null. Thanks for merging.