frontend-services / craft-timetraveler

Other
0 stars 0 forks source link

Creating timezone field kills admin #1

Open danieltott opened 3 years ago

danieltott commented 3 years ago

After installing, I created a field following the readme (called timeZone) and now the admin throws a 500 on any page:

From the error and dump:

Call to a member function getSettings() on null

Full dump: ``` 1. in /app/vendor/matotominac/time-traveler/src/fields/TimeZone.php at line 110 101102103104105106107108109110111112113114115116117118119 { $this->options = [ [ 'label' => Craft::t('site', 'Default'), 'value' => '', 'disabled' => true, ] ]; foreach (TimeTraveler::getInstance()->getSettings()->getTimezoneList() as $timezone => $label) { $this->options[] = [ 'label' => $label, 'value' => $timezone, 'default' => $timezone == Craft::$app->getTimeZone() ? 1 : null ]; } } public function defaultValue() 2. in /app/vendor/matotominac/time-traveler/src/fields/TimeZone.php at line 49 – matotominac\timetraveler\fields\TimeZone::getTimezoneOptions() 43444546474849505152535455 /** * @inheritdoc */ public function init() { // set our options before Craft's BaseOptionsField normalizes them. $this->getTimezoneOptions(); parent::init(); } /** * @inheritdoc 3. in /app/vendor/yiisoft/yii2/base/BaseObject.php at line 109 – matotominac\timetraveler\fields\TimeZone::init() 4. yii\base\BaseObject::__construct(['id' => '35', 'dateCreated' => '2021-05-14 13:21:49', 'dateUpdated' => '2021-05-14 13:21:49', 'groupId' => '5', ...]) 5. in /app/vendor/yiisoft/yii2/di/Container.php at line 420 – ReflectionClass::newInstanceArgs([['id' => '35', 'dateCreated' => '2021-05-14 13:21:49', 'dateUpdated' => '2021-05-14 13:21:49', 'groupId' => '5', ...]]) 6. in /app/vendor/yiisoft/yii2/di/Container.php at line 171 – yii\di\Container::build('matotominac\timetraveler\fields\...', [], ['id' => '35', 'dateCreated' => '2021-05-14 13:21:49', 'dateUpdated' => '2021-05-14 13:21:49', 'groupId' => '5', ...]) 7. in /app/vendor/yiisoft/yii2/BaseYii.php at line 365 – yii\di\Container::get('matotominac\timetraveler\fields\...', [], ['id' => '35', 'dateCreated' => '2021-05-14 13:21:49', 'dateUpdated' => '2021-05-14 13:21:49', 'groupId' => '5', ...]) 8. in /app/vendor/craftcms/cms/src/helpers/Component.php at line 111 – yii\BaseYii::createObject(['id' => '35', 'dateCreated' => '2021-05-14 13:21:49', 'dateUpdated' => '2021-05-14 13:21:49', 'groupId' => '5', ...]) 105106107108109110111112113114115116117 // Merge the settings sub-key into the main config $config = self::mergeSettings($config); // Instantiate and return $config['class'] = $class; return Craft::createObject($config); } /** * Extracts settings from a given component config, and returns a new config array with the settings merged in. * * @param array $config 9. in /app/vendor/craftcms/cms/src/services/Fields.php at line 580 – craft\helpers\Component::createComponent(['id' => '35', 'dateCreated' => '2021-05-14 13:21:49', 'dateUpdated' => '2021-05-14 13:21:49', 'groupId' => '5', ...], 'craft\base\FieldInterface') 574575576577578579580581582583584585586 if (!empty($config['id']) && empty($config['uid']) && is_numeric($config['id'])) { $uid = Db::uidById(Table::FIELDS, $config['id']); $config['uid'] = $uid; } try { $field = ComponentHelper::createComponent($config, FieldInterface::class); } catch (MissingComponentException $e) { $config['errorMessage'] = $e->getMessage(); $config['expectedType'] = $config['type']; unset($config['type']); $field = new MissingField($config); 10. in /app/vendor/craftcms/cms/src/services/Fields.php at line 605 – craft\services\Fields::createField(['id' => '35', 'dateCreated' => '2021-05-14 13:21:49', 'dateUpdated' => '2021-05-14 13:21:49', 'groupId' => '5', ...]) 599600601602603604605606607608609610611 */ private function _fields($context = null): MemoizableArray { if ($this->_fields === null) { $fields = []; foreach ($this->_createFieldQuery()->all() as $result) { $fields[] = $this->createField($result); } $this->_fields = new MemoizableArray($fields); } if ($context === false) { return $this->_fields; 11. in /app/vendor/craftcms/cms/src/services/Fields.php at line 634 – craft\services\Fields::_fields(null) 628629630631632633634635636637638639640 * @param string|string[]|false|null $context The field context(s) to fetch fields from. Defaults to [[\craft\services\Content::$fieldContext]]. * Set to `false` to get all fields regardless of context. * @return FieldInterface[] The fields */ public function getAllFields($context = null): array { return $this->_fields($context)->all(); } /** * Returns all fields that have a column in the content table. * * @return FieldInterface[] The fields 12. in /app/vendor/craftcms/cms/src/elements/db/ElementQuery.php at line 2089 – craft\services\Fields::getAllFields() 2083208420852086208720882089209020912092209320942095 return []; } $contentService = Craft::$app->getContent(); $originalFieldContext = $contentService->fieldContext; $contentService->fieldContext = 'global'; $fields = Craft::$app->getFields()->getAllFields(); $contentService->fieldContext = $originalFieldContext; return $fields; } /** 13. in /app/vendor/craftcms/cms/src/elements/db/ElementQuery.php at line 1408 – craft\elements\db\ElementQuery::customFields() 1402140314041405140614071408140914101411141214131414 if (Craft::$app->getIsMultiSite(false, true)) { $this->subQuery->andWhere(['elements_sites.siteId' => $this->siteId]); } if ($class::hasContent() && $this->contentTable !== null) { $this->customFields = $this->customFields(); $this->_joinContentTable($class); } else { $this->customFields = null; } if ($this->distinct) { 14. in /app/vendor/yiisoft/yii2/db/QueryBuilder.php at line 227 – craft\elements\db\ElementQuery::prepare(craft\db\mysql\QueryBuilder) 15. in /app/vendor/yiisoft/yii2/db/Query.php at line 157 – yii\db\QueryBuilder::build(craft\elements\db\UserQuery) 16. in /app/vendor/yiisoft/yii2/db/Query.php at line 287 – yii\db\Query::createCommand(craft\db\Connection) 17. in /app/vendor/craftcms/cms/src/db/Query.php at line 168 – yii\db\Query::one(null) 162163164165166167168169170171172173174 */ public function one($db = null) { $limit = $this->limit; $this->limit = 1; try { $result = parent::one($db); // Be more like Yii 2.1 if ($result === false) { $result = null; } } catch (QueryAbortedException $e) { $result = null; 18. in /app/vendor/craftcms/cms/src/elements/db/ElementQuery.php at line 1562 – craft\db\Query::one(null) 1556155715581559156015611562156315641565156615671568 { // 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; } 19. in /app/vendor/craftcms/cms/src/elements/User.php at line 437 – craft\elements\db\ElementQuery::one() 431432433434435436437438439440441442443 public static function findIdentity($id) { $user = static::find() ->addSelect(['users.password']) ->id($id) ->anyStatus() ->one(); if ($user === null) { return null; } /* @var static $user */ 20. in /app/vendor/yiisoft/yii2/web/User.php at line 700 – craft\elements\User::findIdentity(1) 21. in /app/vendor/craftcms/cms/src/web/User.php at line 522 – yii\web\User::renewAuthStatus() 516517518519520521522523524525526527528 } 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 22. in /app/vendor/yiisoft/yii2/web/User.php at line 199 – craft\web\User::renewAuthStatus() 23. in /app/vendor/yiisoft/yii2/base/Component.php at line 140 – yii\web\User::getIdentity() 24. in /app/vendor/danieltott/craft-sidebar-admin-links/src/SidebarAdminLinks.php at line 99 – yii\base\Component::__get('identity') 93949596979899100101102103104105 if (!\Craft::$app->request->getIsConsoleRequest()) { if ( \Craft::$app->request->getIsCpRequest() && \Craft::$app->user && \Craft::$app->user->identity && \Craft::$app->user->identity->admin && Craft::$app->getConfig()->general->allowAdminChanges) { $this->view->registerAssetBundle("danieltott\\sidebaradminlinks\\assetbundles\\sidebaradminlinks\\SidebarAdminLinksAsset"); $cpUrl = UrlHelper::cpUrl(); $this->view->registerJs('sidebarEnhancer.init("' . $cpUrl . '");', View::POS_END); } 25. in /app/vendor/yiisoft/yii2/base/BaseObject.php at line 109 – danieltott\sidebaradminlinks\SidebarAdminLinks::init() 26. in /app/vendor/yiisoft/yii2/base/Module.php at line 158 – yii\base\BaseObject::__construct(['name' => 'Sidebar Admin Links', 'version' => '1.1.0', 'description' => 'Add links from Settings directly...', 'developer' => 'Dan Ott', ...]) 27. in /app/vendor/craftcms/cms/src/base/Plugin.php at line 115 – yii\base\Module::__construct('sidebar-admin-links', craft\web\Application, ['name' => 'Sidebar Admin Links', 'version' => '1.1.0', 'description' => 'Add links from Settings directly...', 'developer' => 'Dan Ott', ...]) 109110111112113114115116117118119120121 $this->controllerNamespace = $namespace . '\\console\\controllers'; } else { $this->controllerNamespace = $namespace . '\\controllers'; } } parent::__construct($id, $parent, $config); } /** * @inheritdoc */ public function getHandle(): string 28. craft\base\Plugin::__construct('sidebar-admin-links', craft\web\Application, ['name' => 'Sidebar Admin Links', 'version' => '1.1.0', 'description' => 'Add links from Settings directly...', 'developer' => 'Dan Ott', ...]) 29. in /app/vendor/yiisoft/yii2/di/Container.php at line 420 – ReflectionClass::newInstanceArgs(['sidebar-admin-links', craft\web\Application, ['basePath' => '/app/vendor/danieltott/craft-sid...', 'name' => 'Sidebar Admin Links', 'version' => '1.1.0', 'description' => 'Add links from Settings directly...', ...]]) 30. in /app/vendor/yiisoft/yii2/di/Container.php at line 171 – yii\di\Container::build('danieltott\sidebaradminlinks\Sid...', ['sidebar-admin-links', craft\web\Application], ['basePath' => '/app/vendor/danieltott/craft-sid...', 'name' => 'Sidebar Admin Links', 'version' => '1.1.0', 'description' => 'Add links from Settings directly...', ...]) 31. in /app/vendor/yiisoft/yii2/BaseYii.php at line 365 – yii\di\Container::get('danieltott\sidebaradminlinks\Sid...', ['sidebar-admin-links', craft\web\Application], ['basePath' => '/app/vendor/danieltott/craft-sid...', 'name' => 'Sidebar Admin Links', 'version' => '1.1.0', 'description' => 'Add links from Settings directly...', ...]) 32. in /app/vendor/craftcms/cms/src/services/Plugins.php at line 942 – yii\BaseYii::createObject(['basePath' => '/app/vendor/danieltott/craft-sid...', 'name' => 'Sidebar Admin Links', 'version' => '1.1.0', 'description' => 'Add links from Settings directly...', ...], ['sidebar-admin-links', craft\web\Application]) 936937938939940941942943944945946947948 if (isset($this->pluginConfigs[$handle])) { $config = ArrayHelper::merge($config, $this->pluginConfigs[$handle]); } } // Create the plugin $plugin = Craft::createObject($config, [$handle, Craft::$app]); $this->_setPluginMigrator($plugin); return $plugin; } /** * Returns info about all of the plugins we can find, whether they’re installed or not. 33. in /app/vendor/craftcms/cms/src/services/Plugins.php at line 233 – craft\services\Plugins::createPlugin('sidebar-admin-links', ['id' => '7', 'handle' => 'sidebar-admin-links', 'version' => '1.1.0', 'schemaVersion' => '1.0.0', ...]) 227228229230231232233234235236237238239 $this->_enabledPluginInfo[$handle] = $row; } foreach ($this->_enabledPluginInfo as $handle => $row) { try { $plugin = $this->createPlugin($handle, $row); } catch (InvalidPluginException $e) { $plugin = null; } if ($plugin !== null) { $hasVersionChanged = $this->hasPluginVersionNumberChanged($plugin); 34. in /app/vendor/craftcms/cms/src/base/ApplicationTrait.php at line 1442 – craft\services\Plugins::loadPlugins() 1436143714381439144014411442144314441445144614471448 $this->_registerFieldLayoutListener(); // Register all the listeners for config items $this->_registerConfigListeners(); // Load the plugins $this->getPlugins()->loadPlugins(); $this->_isInitialized = true; // Fire an 'init' event if ($this->hasEventHandlers(WebApplication::EVENT_INIT)) { $this->trigger(WebApplication::EVENT_INIT); 35. in /app/vendor/craftcms/cms/src/web/Application.php at line 93 – craft\web\Application::_postInit() 87888990919293949596979899 public function init() { $this->state = self::STATE_INIT; $this->_preInit(); parent::init(); $this->ensureResourcePathExists(); $this->_postInit(); $this->authenticate(); $this->debugBootstrap(); } /** * @inheritdoc 36. in /app/vendor/yiisoft/yii2/base/BaseObject.php at line 109 – craft\web\Application::init() 37. in /app/vendor/yiisoft/yii2/base/Application.php at line 212 – yii\base\BaseObject::__construct(['env' => 'dev', 'components' => ['config' => craft\services\Config, 'api' => ['class' => 'craft\services\Api'], 'assets' => ['class' => 'craft\services\Assets'], 'assetIndexer' => ['class' => 'craft\services\AssetIndexer'], ...], 'id' => 'CraftCMS--4f18afa6-9b8b-4452-961...', 'name' => 'Craft CMS', ...]) 38. yii\base\Application::__construct(['env' => 'dev', 'components' => ['config' => craft\services\Config, 'api' => ['class' => 'craft\services\Api'], 'assets' => ['class' => 'craft\services\Assets'], 'assetIndexer' => ['class' => 'craft\services\AssetIndexer'], ...], 'id' => 'CraftCMS--4f18afa6-9b8b-4452-961...', 'name' => 'Craft CMS', ...]) 39. in /app/vendor/yiisoft/yii2/di/Container.php at line 420 – ReflectionClass::newInstanceArgs([['vendorPath' => '/app/vendor', 'env' => 'dev', 'components' => ['config' => craft\services\Config, 'api' => ['class' => 'craft\services\Api'], 'assets' => ['class' => 'craft\services\Assets'], 'assetIndexer' => ['class' => 'craft\services\AssetIndexer'], ...], 'id' => 'CraftCMS--4f18afa6-9b8b-4452-961...', ...]]) 40. in /app/vendor/yiisoft/yii2/di/Container.php at line 171 – yii\di\Container::build('craft\web\Application', [], ['vendorPath' => '/app/vendor', 'env' => 'dev', 'components' => ['config' => craft\services\Config, 'api' => ['class' => 'craft\services\Api'], 'assets' => ['class' => 'craft\services\Assets'], 'assetIndexer' => ['class' => 'craft\services\AssetIndexer'], ...], 'id' => 'CraftCMS--4f18afa6-9b8b-4452-961...', ...]) 41. in /app/vendor/yiisoft/yii2/BaseYii.php at line 365 – yii\di\Container::get('craft\web\Application', [], ['vendorPath' => '/app/vendor', 'env' => 'dev', 'components' => ['config' => craft\services\Config, 'api' => ['class' => 'craft\services\Api'], 'assets' => ['class' => 'craft\services\Assets'], 'assetIndexer' => ['class' => 'craft\services\AssetIndexer'], ...], 'id' => 'CraftCMS--4f18afa6-9b8b-4452-961...', ...]) 42. in /app/vendor/craftcms/cms/bootstrap/bootstrap.php at line 246 – yii\BaseYii::createObject(['vendorPath' => '/app/vendor', 'env' => 'dev', 'components' => ['config' => craft\services\Config, 'api' => ['class' => 'craft\services\Api'], 'assets' => ['class' => 'craft\services\Assets'], 'assetIndexer' => ['class' => 'craft\services\AssetIndexer'], ...], 'id' => 'CraftCMS--4f18afa6-9b8b-4452-961...', ...]) 240241242243244245246247248249250251252 $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']); } 43. in /app/vendor/craftcms/cms/bootstrap/web.php at line 51 – require('/app/vendor/craftcms/cms/bootstr...') 45464748495051 // Load Craft // ----------------------------------------------------------------------------- $appType = 'web'; return require __DIR__ . '/bootstrap.php'; 44. in /app/web/index.php at line 21 – require('/app/vendor/craftcms/cms/bootstr...') 1516171819202122 Dotenv\Dotenv::create(CRAFT_BASE_PATH)->load(); } // Load and run Craft define('CRAFT_ENVIRONMENT', getenv('ENVIRONMENT') ?: 'production'); /** @var craft\web\Application $app */ $app = require CRAFT_VENDOR_PATH.'/craftcms/cms/bootstrap/web.php'; $app->run(); $_COOKIE = [ '8f1505f2ebcbce01d10a4d6b0fee6a74_username' => '84208311681538042c02ea2355d836d08b5d03bfeff542406d16989ca4f8c04fa:2:{i:0;s:41:"8f1505f2ebcbce01d10a4d6b0fee6a74_username";i:1;s:20:"dan@virtualcoffee.io";}', '__stripe_mid' => 'dc856cf9-1f6a-4579-8678-be530e5af4de68f6c5', 'gql_refreshToken' => 'T3m0UtBeorlC0V9QCDVxcxuhzsB4nZn0', '8f1505f2ebcbce01d10a4d6b0fee6a74_identity' => 'ef2ce8492c05ac1c89f876ed074664ac8e1a348979b781ac8ec0ad250341b2f5a:2:{i:0;s:41:"8f1505f2ebcbce01d10a4d6b0fee6a74_identity";i:1;s:212:"[1,"[\\"J6oUvxe-IvJ30Um7lJFMwy826Z8QdPH9r0BfjxS4m2qSjfZFERV5lhFFEfowLFSNsdmkpRWKOo0fyeBwn8sudh85emn3QtFNdxqY\\",null,\\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:89.0) Gecko/20100101 Firefox/89.0\\"]",1209600]";}', 'CRAFT_CSRF_TOKEN' => '35de0b69d0dd3bf0228c070226faa4258c94f085c48429dde508f880e4e6afb5a:2:{i:0;s:16:"CRAFT_CSRF_TOKEN";i:1;s:208:"DRDM0loYRP7Jt4CWc5S16wN38DOwfmXYrxXkal_h|0f35f2fcf0c9fbff450acf1c6f987c9a52398cb5eaff6d30c8c939a36b33d21eDRDM0loYRP7Jt4CWc5S16wN38DOwfmXYrxXkal_h|1|$2y$13$YLl5nuPFap1ZeF1z9g78fOf.d1YUVnuDcPh97fX.r1MYJHVoAjldy";}', 'CraftSessionId' => 'e9ab62b104e9f2ed96693740f3965007', ]; $_SESSION = [ 'd2f6ef72bfdfa3f439d550e144a53c79__flash' => [ 'cp-notice' => -1, ], '8f1505f2ebcbce01d10a4d6b0fee6a74__token' => 'J6oUvxe-IvJ30Um7lJFMwy826Z8QdPH9r0BfjxS4m2qSjfZFERV5lhFFEfowLFSNsdmkpRWKOo0fyeBwn8sudh85emn3QtFNdxqY', '8f1505f2ebcbce01d10a4d6b0fee6a74__id' => 1, '__authKey' => '["J6oUvxe-IvJ30Um7lJFMwy826Z8QdPH9r0BfjxS4m2qSjfZFERV5lhFFEfowLFSNsdmkpRWKOo0fyeBwn8sudh85emn3QtFNdxqY",null,"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:89.0) Gecko/20100101 Firefox/89.0"]', '8f1505f2ebcbce01d10a4d6b0fee6a74__expire' => 1622208108, '__duration' => 1209600, 'd2f6ef72bfdfa3f439d550e144a53c79__auth_access' => [ 'editStructure:31', 'previewElement:85', 'previewElement:72', 'previewDraft:3', 'previewElement:88', 'previewElement:20', 'previewElement:49', 'editStructure:2', 'previewElement:82', 'previewElement:80', ], 'cp-notice' => 'Field saved.', ]; ```

Uninstalling the plugin via console commands removes the error.

MatoTominac commented 3 years ago

Can you please try updating to the version v1.0.4