modmore / Gitify

Command line toolkit to make managing a MODX site in git a lot easier.
MIT License
122 stars 55 forks source link

Fails to extract content of Articles #87

Open mjsarfatti opened 9 years ago

mjsarfatti commented 9 years ago

Due to the way Articles is structured gitify fails to extract their content, with the following error:

(ERROR @ /.../gitify) Instantiated a derived class modDocument that is not a subclass of the requested class ArticlesContainer
PHP Fatal error:  Call to undefined method modDocument_mysql::getArchivistCall() in /.../core/components/articles/model/articles/article.class.php on line 58

A quick solution is to exclude them in Gitify/src/CommandExtractCommand.php around line 264

·   if (method_exists($object, 'getContent')
·       && !($object instanceof \modStaticResource)
·       && !($object instanceof \modDashboardWidget)
+       && !($object instanceof \Article)
·   ) {
--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/12484085-fails-to-extract-content-of-articles?utm_campaign=plugin&utm_content=tracker%2F2783338&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F2783338&utm_medium=issues&utm_source=github).
Mark-H commented 9 years ago

Hmm the static resource and dashboard widgets are excluded there because the getContent method was returning the output instead of just the "raw" content. Is that the same with Articles?

mjsarfatti commented 9 years ago

No it's a different problem, but to be honest I don't completely understand it. The Article/getContent method wants to instantiate it's container (ArticlesContainer) but for some reason it fails, or it ends up instantiating a different class. All I have is that pair of errors above. This is the Article/getContent method:

public function getContent(array $options = array()) {
    if ($this->xpdo instanceof modX) {
        $settings = $this->getContainerSettings();
        if ($this->xpdo->getOption('commentsEnabled',$settings,true)) {
            $this->getCommentsCall($settings);
            $this->getCommentsReplyCall($settings);
            $this->getCommentsCountCall($settings);
            $this->xpdo->setPlaceholder('comments_enabled',1);
        } else {
            $this->xpdo->setPlaceholder('comments_enabled',0);
        }
        $this->getTagsCall($settings);
        /** @var ArticlesContainer $container */
        $container = $this->getOne('Container');
        if ($container) {
            $container->getArchivistCall(); // <= this is line 58 as per above error
            $container->getLatestCommentsCall();
            $container->getLatestPostsCall();
            $container->getTagListerCall();
        }
    }
    $content = parent::getContent($options);
    return $content;
}

As you can see for some reason the call $this->getOne('Container') instantiates modDocument instead of ArticlesContainer.