presseddigital / linkit

Linkit Plugin for Craft 4
Other
28 stars 18 forks source link

presseddigital\linkit\base\ElementLink::getUrl(): Return value must be of type string, null returned #107

Closed Troops994 closed 2 years ago

Troops994 commented 2 years ago

Getting the following errors for Linkit.

Strill seeing an issue where the type string is referenced.

in /var/www/craft/vendor/presseddigital/linkit/src/base/ElementLink.phpat line 71 62636465666768697071727374757677787980 if (!is_null($this->customSelectionLabel) && $this->customSelectionLabel != '') { return $this->customSelectionLabel; } return $this->defaultSelectionLabel(); }

public function getUrl(): string
{
    $element = $this->getElement();
    return $element ? $element->getUrl() : '';
}

public function getText(): string
{
    return $this->getCustomOrDefaultText() ?? ($this->getElement() ? $this->getElement()->title : null) ?? $this->getUrl() ?? '';
}

public function getElement()
{
  1. in /var/www/craft/vendor/yiisoft/yii2/base/Component.php at line 139– presseddigital\linkit\base\ElementLink::getUrl()
  2. in /var/www/craft/vendor/craftcms/cms/src/helpers/Template.php at line 90– [yii\base\Component::get](http://www.yiiframework.com/doc-2.0/yii-base-component.html#get()-detail)('url') 84858687888990919293949596 if ( $type !== TwigTemplate::METHOD_CALL && $object instanceof BaseObject && $object->canGetProperty($item) ) { return $isDefinedTest ? true : $object->$item; }

    // Convert any \Twig\Markup arguments back to strings (unless the class *extends* \Twig\Markup)
    foreach ($arguments as $key => $value) {
        if (is_object($value) && get_class($value) === Markup::class) {
            $arguments[$key] = (string)$value;
Troops994 commented 2 years ago

This issue seems to be only with Entries, I think it is the one you might be already investigating.

Troops994 commented 2 years ago

Morning, any idea when the fix will be out, this is effecting our live environments so we are keen to get this resolved asap.

andrewfairlie commented 2 years ago

Any update on this?

ben-callaway commented 2 years ago

Fixed in 3.0.3 / 4.0.3