Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.1.1-rc on Craft 4 beta.4] Admin panel inaccessible after creating link field #214

Closed
Nellyaa opened this issue Apr 22, 2022 · 2 comments
Labels

Comments

@Nellyaa
Copy link

Nellyaa commented Apr 22, 2022

After updating to 2.1.1-rc I attempted to create a link field and got this error rendering the admin panel inaccessible.

Steps to recreate:

  1. Click new field
  2. Choose link field
  3. Make some adjustments to field
  4. Press save
  5. Get error

TypeError
array_merge(): Argument #2 must be of type array, null given
1. in /var/www/vendor/sebastianlenz/craft-utils/src/foreignField/ForeignFieldQueryExtension.phpat line 258
249250251252253254255256257258259260261262263264265266267  /**
   * @param ElementQuery $query
   * @param ForeignField $field
   * @return bool
   */
  static protected function enableJoin(ElementQuery $query, ForeignField $field): bool {
    $items = array_merge(
      is_array($query->orderBy) ? $query->orderBy : [$query->orderBy],
      $query->groupBy,
      [Json::encode($query->where)]
    );
 
    foreach ($items as $key => $value) {
      if (
        str_contains($key, $field->handle) ||
        str_contains($value, $field->handle)
      ) {
        return true;
      }
6. in /var/www/vendor/sebastianlenz/craft-utils/src/foreignField/ForeignFieldQueryExtension.php at line 258– array_merge([''], null, ['null'])
252253254255256257258259260261262263264   * @return bool
   */
  static protected function enableJoin(ElementQuery $query, ForeignField $field): bool {
    $items = array_merge(
      is_array($query->orderBy) ? $query->orderBy : [$query->orderBy],
      $query->groupBy,
      [Json::encode($query->where)]
    );
 
    foreach ($items as $key => $value) {
      if (
        str_contains($key, $field->handle) ||
        str_contains($value, $field->handle)
7. in /var/www/vendor/sebastianlenz/craft-utils/src/foreignField/ForeignFieldQueryExtension.php at line 191– lenz\craft\utils\foreignField\ForeignFieldQueryExtension::enableJoin(craft\elements\db\UserQuery, lenz\linkfield\fields\LinkField)
185186187188189190191192193194195196197 
    $filters = ArrayHelper::getValue($options, 'filters');
    $forceEagerLoad = !!ArrayHelper::getValue($options, 'forceEagerLoad', false);
    $forceJoin = !!ArrayHelper::getValue($options, 'forceJoin', false);
 
    $enableEagerLoad = static::enableEagerLoad($query, $field) || $forceEagerLoad;
    $enableJoin = static::enableJoin($query, $field) || $filters || $forceJoin;
 
    if ($enableEagerLoad || $enableJoin) {
      $options = [
        'enableEagerLoad' => $enableEagerLoad,
        'enableJoin' => $enableJoin,
        'field' => $field,
8. in /var/www/vendor/sebastianlenz/craft-utils/src/foreignField/ForeignField.php at line 127– lenz\craft\utils\foreignField\ForeignFieldQueryExtension::attachTo(craft\elements\db\UserQuery, lenz\linkfield\fields\LinkField, ['filters' => null])
121122123124125126127128129130131132133  /**
   * @inheritDoc
   * @throws Exception
   */
  public function modifyElementsQuery(ElementQueryInterface $query, $value): void {
    static::queryExtensionClass()::attachTo($query, $this, [
      'filters' => static::prepareQueryFilter($value),
    ]);
  }
 
  /**
   * @inheritDoc
   * @throws Exception
9. in /var/www/vendor/craftcms/cms/src/elements/db/ElementQuery.php at line 2045– lenz\craft\utils\foreignField\ForeignField::modifyElementsQuery(craft\elements\db\UserQuery, null)
2039204020412042204320442045204620472048204920502051                if ($field->columnPrefix !== null) {
                    $contentService->fieldColumnPrefix = $field->columnPrefix;
                }
 
                $exception = null;
                try {
                    $field->modifyElementsQuery($this, $fieldAttributeValue);
                } catch (QueryAbortedException $exception) {
                }
 
                // Set it back
                $contentService->fieldColumnPrefix = $originalFieldColumnPrefix;
 
10. in /var/www/vendor/craftcms/cms/src/elements/db/ElementQuery.php at line 1263– craft\elements\db\ElementQuery::_joinContentTable('craft\elements\User')
1257125812591260126112621263126412651266126712681269        if (Craft::$app->getIsMultiSite(false, true)) {
            $this->subQuery->andWhere(['elements_sites.siteId' => $this->siteId]);
        }
 
        if ($class::hasContent() && isset($this->contentTable)) {
            $this->customFields = $this->customFields();
            $this->_joinContentTable($class);
        } else {
            $this->customFields = null;
        }
 
        if ($this->distinct) {
            $this->query->distinct();
11. in /var/www/vendor/yiisoft/yii2/db/QueryBuilder.php at line 227– craft\elements\db\ElementQuery::prepare(craft\db\mysql\QueryBuilder)
12. in /var/www/vendor/yiisoft/yii2/db/Query.php at line 157– [yii\db\QueryBuilder::build](http://www.yiiframework.com/doc-2.0/yii-db-querybuilder.html#build()-detail)(craft\elements\db\UserQuery)
13. in /var/www/vendor/yiisoft/yii2/db/Query.php at line 287– [yii\db\Query::createCommand](http://www.yiiframework.com/doc-2.0/yii-db-query.html#createCommand()-detail)(craft\db\Connection)
14. in /var/www/vendor/craftcms/cms/src/db/Query.php at line 180– [yii\db\Query::one](http://www.yiiframework.com/doc-2.0/yii-db-query.html#one()-detail)(null)
174175176177178179180181182183184185186     */
    public function one($db = null): mixed
    {
        $limit = $this->limit;
        $this->limit = 1;
        try {
            $result = parent::one($db);
            // Be more like Yii 2.1
            if ($result === false) {
                $result = null;
            }
        } catch (QueryAbortedException) {
            $result = null;
15. in /var/www/vendor/craftcms/cms/src/elements/db/ElementQuery.php at line 1417– craft\db\Query::one(null)
1411141214131414141514161417141814191420142114221423    {
        // Cached?
        if (($cachedResult = $this->getCachedResult()) !== null) {
            return reset($cachedResult) ?: null;
        }
 
        if ($row = parent::one($db)) {
            $elements = $this->populate([$row]);
            return reset($elements) ?: null;
        }
 
        return null;
    }
16. in /var/www/vendor/craftcms/cms/src/elements/User.php at line 535– craft\elements\db\ElementQuery::one()
529530531532533534535536537538539540541    {
        /** @var User|null $user */
        $user = self::find()
            ->addSelect(['users.password'])
            ->id($id)
            ->status(null)
            ->one();
 
        if ($user === null) {
            return null;
        }
 
        /** @var static $user */
17. in /var/www/vendor/yiisoft/yii2/web/User.php at line 697– craft\elements\User::findIdentity(1)
18. in /var/www/vendor/craftcms/cms/src/web/User.php at line 500– [yii\web\User::renewAuthStatus](http://www.yiiframework.com/doc-2.0/yii-web-user.html#renewAuthStatus()-detail)()
494495496497498499500501502503504505506        } else {
            $authTimeout = $this->authTimeout;
            // Was a specific session duration specified on login?
            if (SessionHelper::has($this->authDurationParam)) {
                $this->authTimeout = SessionHelper::get($this->authDurationParam);
            }
            parent::renewAuthStatus();
            $this->authTimeout = $authTimeout;
        }
    }
 
    /**
     * @inheritdoc
19. in /var/www/vendor/yiisoft/yii2/web/User.php at line 198– craft\web\User::renewAuthStatus()
20. in /var/www/vendor/craftcms/cms/src/web/Application.php at line 423– [yii\web\User::getIdentity](http://www.yiiframework.com/doc-2.0/yii-web-user.html#getIdentity()-detail)()
417418419420421422423424425426427428429 
        if ($request->getIsLivePreview() || $request->getIsPreview()) {
            return;
        }
 
        // Only load the debug toolbar if it's enabled for the user, or Dev Mode is enabled and the request wants it
        $user = $this->getUser()->getIdentity();
        $pref = $request->getIsCpRequest() ? 'enableDebugToolbarForCp' : 'enableDebugToolbarForSite';
        if (!(
            ($user && $user->admin && $user->getPreference($pref)) ||
            (App::devMode() && $request->getHeaders()->get('X-Debug') === 'enable')
        )) {
            return;
21. in /var/www/vendor/craftcms/cms/src/web/Application.php at line 107– craft\web\Application::debugBootstrap()
101102103104105106107108109110111112113        if (!App::isEphemeral()) {
            $this->ensureResourcePathExists();
        }
 
        $this->_postInit();
        $this->authenticate();
        $this->debugBootstrap();
    }
 
    /**
     * @inheritdoc
     */
    public function bootstrap(): void
22. in /var/www/vendor/yiisoft/yii2/base/BaseObject.php at line 109– craft\web\Application::init()
23. in /var/www/vendor/yiisoft/yii2/base/Application.php at line 204– [yii\base\BaseObject::__construct](http://www.yiiframework.com/doc-2.0/yii-base-baseobject.html#__construct()-detail)(['env' => 'dev', 'components' => ['config' => craft\services\Config, 'addresses' => ['class' => 'craft\services\Addresses'], 'announcements' => ['class' => 'craft\services\Announcements'], 'api' => ['class' => 'craft\services\Api'], ...], 'id' => 'CraftCMS--ef6f2275-44e8-4251-92e...', 'name' => 'Craft CMS', ...])
24. [yii\base\Application::__construct](http://www.yiiframework.com/doc-2.0/yii-base-application.html#__construct()-detail)(['env' => 'dev', 'components' => ['config' => craft\services\Config, 'addresses' => ['class' => 'craft\services\Addresses'], 'announcements' => ['class' => 'craft\services\Announcements'], 'api' => ['class' => 'craft\services\Api'], ...], 'id' => 'CraftCMS--ef6f2275-44e8-4251-92e...', 'name' => 'Craft CMS', ...])
25. in /var/www/vendor/yiisoft/yii2/di/Container.php at line 419– ReflectionClass::newInstanceArgs([['vendorPath' => '/var/www/vendor', 'env' => 'dev', 'components' => ['config' => craft\services\Config, 'addresses' => ['class' => 'craft\services\Addresses'], 'announcements' => ['class' => 'craft\services\Announcements'], 'api' => ['class' => 'craft\services\Api'], ...], 'id' => 'CraftCMS--ef6f2275-44e8-4251-92e...', ...]])
26. in /var/www/vendor/yiisoft/yii2/di/Container.php at line 170– [yii\di\Container::build](http://www.yiiframework.com/doc-2.0/yii-di-container.html#build()-detail)('craft\web\Application', [], ['vendorPath' => '/var/www/vendor', 'env' => 'dev', 'components' => ['config' => craft\services\Config, 'addresses' => ['class' => 'craft\services\Addresses'], 'announcements' => ['class' => 'craft\services\Announcements'], 'api' => ['class' => 'craft\services\Api'], ...], 'id' => 'CraftCMS--ef6f2275-44e8-4251-92e...', ...])
27. in /var/www/vendor/yiisoft/yii2/BaseYii.php at line 365– [yii\di\Container::get](http://www.yiiframework.com/doc-2.0/yii-di-container.html#get()-detail)('craft\web\Application', [], ['vendorPath' => '/var/www/vendor', 'env' => 'dev', 'components' => ['config' => craft\services\Config, 'addresses' => ['class' => 'craft\services\Addresses'], 'announcements' => ['class' => 'craft\services\Announcements'], 'api' => ['class' => 'craft\services\Api'], ...], 'id' => 'CraftCMS--ef6f2275-44e8-4251-92e...', ...])
28. in /var/www/vendor/craftcms/cms/src/Craft.php at line 53– [yii\BaseYii::createObject](http://www.yiiframework.com/doc-2.0/yii-baseyii.html#createObject()-detail)(['vendorPath' => '/var/www/vendor', 'env' => 'dev', 'components' => ['config' => craft\services\Config, 'addresses' => ['class' => 'craft\services\Addresses'], 'announcements' => ['class' => 'craft\services\Announcements'], 'api' => ['class' => 'craft\services\Api'], ...], 'id' => 'CraftCMS--ef6f2275-44e8-4251-92e...', ...], [])
47484950515253545556575859     * @phpstan-param class-string<T>|array{class:class-string<T>}|callable():T $type
     * @param array $params
     * @return T
     */
    public static function createObject($type, array $params = [])
    {
        return parent::createObject($type, $params);
    }
 
    /**
     * Checks if a string references an environment variable (`$VARIABLE_NAME`)
     * and/or an alias (`@aliasName`), and returns the referenced value.
     *
29. in /var/www/vendor/craftcms/cms/bootstrap/bootstrap.php at line 239– Craft::createObject(['vendorPath' => '/var/www/vendor', 'env' => 'dev', 'components' => ['config' => craft\services\Config, 'addresses' => ['class' => 'craft\services\Addresses'], 'announcements' => ['class' => 'craft\services\Announcements'], 'api' => ['class' => 'craft\services\Api'], ...], 'id' => 'CraftCMS--ef6f2275-44e8-4251-92e...', ...])
233234235236237238239240241242243244245    $configService->getConfigFromFile('app'),
    $configService->getConfigFromFile("app.{$appType}")
);
 
// Initialize the application
/** @var \craft\web\Application|craft\console\Application $app */
$app = Craft::createObject($config);
 
// If there was a max_input_vars error, kill the request before we start processing it with incomplete data
if ($lastError && strpos($lastError['message'], 'max_input_vars') !== false) {
    throw new ErrorException($lastError['message']);
}
 
30. in /var/www/vendor/craftcms/cms/bootstrap/web.php at line 40– require('/var/www/vendor/craftcms/cms/boo...')
34353637383940 
// Load Craft
// -----------------------------------------------------------------------------
 
$appType = 'web';
 
return require __DIR__ . '/bootstrap.php';
31. in /var/www/web/index.php at line 11– require('/var/www/vendor/craftcms/cms/boo...')
56789101112 
// Load shared bootstrap
require dirname(__DIR__) . '/bootstrap.php';
 
// Load and run Craft
/** @var craft\web\Application $app */
$app = require CRAFT_VENDOR_PATH . '/craftcms/cms/bootstrap/web.php';
$app->run();
$_COOKIE = [
    '08b50206495ab19261c35e647aeb027a_username' => 'b0c2835ac35779244c9bcdd2512d6d67f9422aaf083ad1d7945978e58ba0a2e0a:2:{i:0;s:41:"08b50206495ab19261c35e647aeb027a_username";i:1;s:16:"[email protected]";}',
    'CraftSessionId' => 'c59571205ea85bf567df1ae42056a738',
    '08b50206495ab19261c35e647aeb027a_identity' => 'd919126a9a2567b2f5d96ea9104e85827be39eff0210b3c28ceb2a4fc32f7ad3a:2:{i:0;s:41:"08b50206495ab19261c35e647aeb027a_identity";i:1;s:162:"[1,"[\\"p1AhRR9rELvyjmDKntX2RwCHOuFPdHO0Qtr51Lq8qx0KOmo7KzPxhC3puvmPCSus9EexkGTB-X7Y20pK3tEz8B3wSPoiE67u5yJG\\",null,\\"09af53e829b1687c5db16483617c3ced\\"]",1209600]";}',
    'CRAFT_CSRF_TOKEN' => '7053939bc26853c02f098e58d6f8713da30a4479d17be61611d80b0bcc7105f0a:2:{i:0;s:16:"CRAFT_CSRF_TOKEN";i:1;s:147:"-oPWkpi6lHL83nL09Y-XHTMgnry5kZMXciit-e2l|70281f995115deed570e580d9b34e8c1d041630973b4b732a48406ac9594fe2a-oPWkpi6lHL83nL09Y-XHTMgnry5kZMXciit-e2l|1";}',
];

$_SESSION = [
    'a50e111d5f13061b3bc1c20c2a9c215d__flash' => [
        'cp-notice' => -1,
    ],
    '08b50206495ab19261c35e647aeb027a__token' => 'p1AhRR9rELvyjmDKntX2RwCHOuFPdHO0Qtr51Lq8qx0KOmo7KzPxhC3puvmPCSus9EexkGTB-X7Y20pK3tEz8B3wSPoiE67u5yJG',
    '08b50206495ab19261c35e647aeb027a__id' => 1,
    '__authKey' => '["p1AhRR9rELvyjmDKntX2RwCHOuFPdHO0Qtr51Lq8qx0KOmo7KzPxhC3puvmPCSus9EexkGTB-X7Y20pK3tEz8B3wSPoiE67u5yJG",null,"09af53e829b1687c5db16483617c3ced"]',
    '__duration' => 1209600,
    'commerce_cart' => 'b01e6b1ee47746861a90b61b597890f0',
    '08b50206495ab19261c35e647aeb027a__expire' => 1651847175,
    'a50e111d5f13061b3bc1c20c2a9c215d__auth_access' => [
        'seomaticPreviewAuthorizationKey343',
        'previewElement:343',
        'saveAssets:10',
    ],
    'cp-notice' => 'Field saved.',
];
@davidhellmann
Copy link

Same here, same versions :)

internetztube added a commit to internetztube/craft-utils that referenced this issue Apr 26, 2022
internetztube added a commit to internetztube/craft-linkfield that referenced this issue Apr 26, 2022
@sebastian-lenz
Copy link
Owner

Thanks @internetztube! The fix is within a dependency so n new version of this plugin is needed. You'll receive the fix by running composer update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants