wintercms / wn-blog-plugin

Blog plugin for Winter CMS
https://wintercms.com/
MIT License
18 stars 24 forks source link

Incompatibility when module CMS is disabled. (Cms\Classes not found) #43

Open AdrienAdB opened 1 year ago

AdrienAdB commented 1 year ago

Hi, I am mainly using WinterCMS as a backend+api with JS framework as front-end (React, Vue...). Most of the time I disable CMS module in config/cms.php (loadModules).

Blog plugin was working well until last winter update 1.2.x I re-enabled CMS Module to allow use of CMS\Classes.

Error: Class "Cms\Classes\Theme" not found in /var/www/xxxxx/plugins/winter/blog/models/Post.php:394

https://github.com/wintercms/wn-blog-plugin/blob/main/models/Post.php#L394

LukeTowers commented 1 year ago

@AdrienAdB that would be because we improved our class loader to completely ignore unloaded modules and plugins in 1.2. As a general rule of thumb I recommend removing the cms module from your composer.json if you aren't using it to make these issues more obvious; however in this specific case this is a bug in the plugin in that it doesn't yet support being run in an environment like yours.

I would be more than happy to accept a PR to fix support for your use case though; it should be as simple as

/**
 * Get the list of pages that can be used to display the post
 */
public function getCmsPageOptions(): array
{
    $result = [];

    if (!class_exists(Theme::class)) {
        return $result;
    }

    // ...
}