Skip to content

MagicPreview errors #150

@verstratenbram

Description

@verstratenbram

We are getting a lot of errors in the log about MagicPreview because the extra is not installed.

  • VersionX 3.2.1-pl
  • Modx 3.1.2-pl
  • PHP 8.3
[2025-07-10 13:59:18] (ERROR @ /var/web/public_html/core/vendor/xpdo/xpdo/src/xPDO/xPDO.php : 667) Could not load class: MagicPreview from magicpreview
[2025-07-10 13:59:18] (ERROR @ /var/web/public_html/core/vendor/xpdo/xpdo/src/xPDO/xPDO.php : 1273) Problem getting service magicpreview, instance of class MagicPreview, from path /var/web/public_html/core/components/magicpreview/model/magicpreview/

Our current workaround is to add an extra check if $path exists to the magicPreviewLoaded() function:

public function magicPreviewLoaded(): bool
{
    $path = $this->modx->getOption(
        'magicpreview.core_path',
        [],
        $this->modx->getOption('core_path') . 'components/magicpreview/'
    ) . 'model/magicpreview/';

    if (!file_exists($path) || !$magicPreview = $this->modx->getService('magicpreview', 'MagicPreview', $path)) {
        return false;
    }

    return version_compare($magicPreview::VERSION, '1.5.1-pl', '>=');
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions