Upgrade 8.1.0 to 8.4.3 - need help

Permalink
After an upgrade from 8.1.0 to 8.4.3

Exception Occurred: /concrete/src/File/Image/BasicThumbnailer.php:374 Call to a member function make() on null (0)

Please help :-)

 
core77 replied on at Permalink Reply
Seems like you ran in this issue:
https://github.com/concrete5/concrete5/issues/7113...

There is already a pull request.
ajk replied on at Permalink Reply
No, but thanks.

public function getThumbnail($obj, $maxWidth, $maxHeight, $crop = false)
    {
        $config = $this->app->make('config');
        if ($config->get('concrete.misc.basic_thumbnailer_generation_strategy') == 'async') {
            return $this->returnThumbnailObjectFromResolver($obj, $maxWidth, $maxHeight, $crop);
        } else {
            return $this->checkForThumbnailAndCreateIfNecessary($obj, $maxWidth, $maxHeight, $crop);
        }
    }

The Debugger shows the error on the -> $config = $this->app->make('config'); Line.
A3020 replied on at Permalink Reply
A3020
Do you call File/Image/BasicThumbnailer.php directly? If so, it needs to be resolved via the 'Container', to set the `app` property.

You'd use the thumbnailer e.g. via `$app->make('helper/image')`, to create an instance of the BasicThumbnailer class.

If you don't know, I'd suggest to search your custom code for 'BasicThumbnailer' occurrences, e.g. in the directories application/blocks and packages/.
ajk replied on at Permalink Reply
This is the code in My.php

public static function getImagesFromSet($fsName) {
        $thumbnailer = new BasicThumbnailer();
        $images = array();
        $files = Set::getFilesBySetName($fsName);
        if (count($files) > 0) {
            foreach ($files as $file) {
                /**
                 * @var \Concrete\Core\Entity\File\File $file
                 * @var Version $av
                 */
                $av = $file->getApprovedVersion();
                if (strpos($av->getMimeType(), 'image') !== false) {
                    $image = $thumbnailer->getThumbnail($file, 2400, 2400)->src;
                    $images[] = $image;
                }
A3020 replied on at Permalink Best Answer Reply
A3020
You shouldn't be instantiating BasicThumbnailer like that. It needs to be instantiated via the container. See https://documentation.concrete5.org/developers/appendix/concrete5-ve...

In your case that might be `$app->make('helper/image')`, for example. But it really depends on the rest of your code.
ajk replied on at Permalink Reply
Thanks A3020

I added
use Concrete\Core\Application\ApplicationAwareTrait;


and in the function getImagesFromSet()

$app = \Concrete\Core\Support\Facade\Application::getFacadeApplication();
$im = $app->make('helper/image');


An it works, thanks!
A3020 replied on at Permalink Reply
A3020
The trait is only useful if your class is also instantiated via the Container. Otherwise the `app` property won't be set.

The facade you're using now, is an OK solution.