presseddigital / linkit

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

Issue with content after upgrading from 1.1.12.1 to 3.0 throwing an error and folder for the content is not accessible #102

Closed Troops994 closed 2 years ago

Troops994 commented 2 years ago

Issue with content after upgrading from 1.1.12.1 to 3.0 throwing an error and folder for the content is not accessible

We have a channel section with 6 entry types in it. One of the types has LinkField attached to it. The field is set to Linkit and used for URL and Entry only.

Since the upgrade we are no longer able to access that in Entries as it comes up with "A server error occurred." If we remove the filed then everything works. Adding it back brings back the same issue. The site is working but via the admin console we face this issue. We are unable to roll back the changes as this causes further page errors.

Logs are as follows with the error.

2022-08-23T08:00:32.933427427Z 169.254.129.1 - - [23/Aug/2022:08:00:32 +0000] "GET /cms/entries HTTP/1.1" 200 26974 "https://www-uat.charles-stanley.co.uk/cms/dashboard" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36" 2022-08-23T08:00:34.068256561Z 169.254.129.1 - - [23/Aug/2022:08:00:33 +0000] "POST / HTTP/1.1" 200 4067 "https://www-uat.charles-stanley.co.uk/cms/entries/sharedContent" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36" 2022-08-23T08:00:34.182258371Z 2022-08-23 09:00:34 [External IP MASK][120059][5489d538010448adc1e803e27564565c][error][Error] Error: Call to a member function getTypeHandle() on string in /var/www/craft/vendor/presseddigital/linkit/src/Linkit.php:128 2022-08-23T08:00:34.182289972Z Stack trace: 2022-08-23T08:00:34.182294772Z #0 [internal function]: presseddigital\linkit\Linkit->presseddigital\linkit{closure}(Object(craft\events\DefineEagerLoadingMapEvent)) 2022-08-23T08:00:34.182299572Z #1 /var/www/craft/vendor/yiisoft/yii2/base/Event.php(312): call_user_func(Object(Closure), Object(craft\events\DefineEagerLoadingMapEvent)) 2022-08-23T08:00:34.182303572Z #2 /var/www/craft/vendor/craftcms/cms/src/base/Element.php(1036): yii\base\Event::trigger('craft\base\Elem...', 'defineEagerLoad...', Object(craft\events\DefineEagerLoadingMapEvent)) 2022-08-23T08:00:34.182307972Z #3 /var/www/craft/vendor/craftcms/cms/src/elements/Entry.php(622): craft\base\Element::eagerLoadingMap(Array, 'linkField.entry') 2022-08-23T08:00:34.182311772Z #4 /var/www/craft/vendor/craftcms/cms/src/services/Elements.php(2277): craft\elements\Entry::eagerLoadingMap(Array, 'linkField.entry') 2022-08-23T08:00:34.182320172Z #5 /var/www/craft/vendor/craftcms/cms/src/services/Elements.php(2244): craft\services\Elements->_eagerLoadElementsInternal('craft\elements\...', Array, Array) 2022-08-23T08:00:34.182324572Z #6 /var/www/craft/vendor/craftcms/cms/src/elements/db/ElementQuery.php(3207): craft\services\Elements->eagerLoadElements('craft\elements\...', Array, Array) 2022-08-23T08:00:34.182328472Z #7 /var/www/craft/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1612): craft\elements\db\ElementQuery->_createElements(Array) 2022-08-23T08:00:34.182332372Z #8 /var/www/craft/vendor/yiisoft/yii2/db/Query.php(251): craft\elements\db\ElementQuery->populate(Array) 2022-08-23T08:00:34.182336172Z #9 /var/www/craft/vendor/craftcms/cms/src/db/Query.php(152): yii\db\Query->all(NULL) 2022-08-23T08:00:34.182350173Z #10 /var/www/craft/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1650): craft\db\Query->all(NULL) 2022-08-23T08:00:34.182354073Z #11 /var/www/craft/vendor/craftcms/cms/src/base/Element.php(873): craft\elements\db\ElementQuery->all() 2022-08-23T08:00:34.182357873Z #12 /var/www/craft/vendor/craftcms/cms/src/controllers/ElementIndexesController.php(542): craft\base\Element::indexHtml(Object(craft\elements\db\EntryQuery), Array, Array, 'section:a080b32...', 'index', true, true) 2022-08-23T08:00:34.182362473Z #13 /var/www/craft/vendor/craftcms/cms/src/controllers/ElementIndexesController.php(139): craft\controllers\ElementIndexesController->elementResponseData(true, true) 2022-08-23T08:00:34.182366573Z #14 [internal function]: craft\controllers\ElementIndexesController->actionGetElements() 2022-08-23T08:00:34.182370273Z #15 /var/www/craft/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array) 2022-08-23T08:00:34.182373773Z #16 /var/www/craft/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array) 2022-08-23T08:00:34.182377473Z #17 /var/www/craft/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction('get-elements', Array) 2022-08-23T08:00:34.182381173Z #18 /var/www/craft/vendor/craftcms/cms/src/web/Application.php(293): yii\base\Module->runAction('element-indexes...', Array) 2022-08-23T08:00:34.182384973Z #19 /var/www/craft/vendor/craftcms/cms/src/web/Application.php(602): craft\web\Application->runAction('element-indexes...', Array) 2022-08-23T08:00:34.182388773Z #20 /var/www/craft/vendor/craftcms/cms/src/web/Application.php(272): craft\web\Application->_processActionRequest(Object(craft\web\Request)) 2022-08-23T08:00:34.182392573Z #21 /var/www/craft/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest(Object(craft\web\Request)) 2022-08-23T08:00:34.182396473Z #22 /var/www/craft/web/index.php(93): yii\base\Application->run() 2022-08-23T08:00:34.182400373Z #23 {main}

samhibberd commented 2 years ago

Looks to be something strange going on with the eager loading, the normalized field value should not be returned as a string here:

https://github.com/presseddigital/linkit/blob/95800c09163b73e2a5fa41cb1b27fde8168a4097/src/Linkit.php#L128

Are you able to send a DB backup, as well as the composer.json + composer.lock over to hi@pressed.digital to assist with debugging?

Troops994 commented 2 years ago

Yes i can send that over shortly

Thank you

darylknight commented 2 years ago

I'm getting this too. Error messsage is:

2022-08-23 15:16:06 [web.ERROR] [Error] Call to a member function getTypeHandle() on string {"trace":["#0 [internal function]: presseddigital\\linkit\\Linkit->presseddigital\\linkit\\{closure}(Object(craft\\events\\DefineEagerLoadingMapEvent))","#1 /srv/users/[removed]]/apps/[removed]]/vendor/yiisoft/yii2/base/Event.php(312): call_user_func(Object(Closure), Object(craft\\events\\DefineEagerLoadingMapEvent))","#2 /srv/users/[removed]]/apps/[removed]]/vendor/craftcms/cms/src/base/Element.php(1219): yii\\base\\Event::trigger('craft\\\\base\\\\Elem...', 'defineEagerLoad...', Object(craft\\events\\DefineEagerLoadingMapEvent))","#3 /srv/users/[removed]]/apps/[removed]]/vendor/craftcms/cms/src/elements/Entry.php(596): craft\\base\\Element::eagerLoadingMap(Array, 'linkTarget.entr...')","#4 /srv/users/[removed]]/apps/[removed]]/vendor/craftcms/cms/src/services/Elements.php(2297): craft\\elements\\Entry::eagerLoadingMap(Array, 'linkTarget.entr...')","#5 /srv/users/[removed]]/apps/[removed]]/vendor/craftcms/cms/src/services/Elements.php(2263): craft\\services\\Elements->_eagerLoadElementsInternal('craft\\\\elements\\\\...', Array, Array)","#6 /srv/users/[removed]]/apps/[removed]]/vendor/craftcms/cms/src/elements/db/ElementQuery.php(2936): craft\\services\\Elements->eagerLoadElements('craft\\\\elements\\\\...', Array, Array)","#7 /srv/users/[removed]]/apps/[removed]]/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1432): craft\\elements\\db\\ElementQuery->_createElements(Array)","#8 /srv/users/[removed]]/apps/[removed]]/vendor/yiisoft/yii2/db/Query.php(251): craft\\elements\\db\\ElementQuery->populate(Array)","#9 /srv/users/[removed]]/apps/[removed]]/vendor/craftcms/cms/src/db/Query.php(247): yii\\db\\Query->all(Object(craft\\db\\Connection))","#10 /srv/users/[removed]]/apps/[removed]]/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1471): craft\\db\\Query->all(Object(craft\\db\\Connection))","#11 /srv/users/[removed]]/apps/[removed]]/vendor/craftcms/cms/src/base/Element.php(1060): craft\\elements\\db\\ElementQuery->all(Object(craft\\db\\Connection))","#12 /srv/users/[removed]]/apps/[removed]]/vendor/craftcms/cms/src/controllers/ElementIndexesController.php(649): craft\\base\\Element::indexHtml(Object(craft\\elements\\db\\EntryQuery), Array, Array, 'section:bd425d8...', 'index', true, true)","#13 /srv/users/[removed]]/apps/[removed]]/vendor/craftcms/cms/src/controllers/ElementIndexesController.php(146): craft\\controllers\\ElementIndexesController->elementResponseData(true, true)","#14 [internal function]: craft\\controllers\\ElementIndexesController->actionGetElements()","#15 /srv/users/[removed]]/apps/[removed]]/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)","#16 /srv/users/[removed]]/apps/[removed]]/vendor/yiisoft/yii2/base/Controller.php(178): yii\\base\\InlineAction->runWithParams(Array)","#17 /srv/users/[removed]]/apps/[removed]]/vendor/yiisoft/yii2/base/Module.php(552): yii\\base\\Controller->runAction('get-elements', Array)","#18 /srv/users/[removed]]/apps/[removed]]/vendor/craftcms/cms/src/web/Application.php(301): yii\\base\\Module->runAction('element-indexes...', Array)","#19 /srv/users/[removed]]/apps/[removed]]/vendor/craftcms/cms/src/web/Application.php(625): craft\\web\\Application->runAction('element-indexes...', Array)","#20 /srv/users/[removed]]/apps/[removed]]/vendor/craftcms/cms/src/web/Application.php(280): craft\\web\\Application->_processActionRequest(Object(craft\\web\\Request))","#21 /srv/users/[removed]]/apps/[removed]]/vendor/yiisoft/yii2/base/Application.php(384): craft\\web\\Application->handleRequest(Object(craft\\web\\Request))","#22 /srv/users/[removed]]/apps/[removed]]/public/index.php(12): yii\\base\\Application->run()","#23 {main}"],"memory":13923072,"exception":"[object] (Error(code: 0): Call to a member function getTypeHandle() on string at /srv/users/[removed]]/apps/[removed]]/vendor/presseddigital/linkit/src/Linkit.php:126)"} 
samhibberd commented 2 years ago

Thanks @darylknight, will get a fix out asap.

darylknight commented 2 years ago

Any news Sam? Sorry to pester you - client is currently unable to access or edit their navigation.

samhibberd commented 2 years ago

@darylknight have recreated and identified the issue, just trying to understand what is going on and get a fix out.

samhibberd commented 2 years ago

@darylknight @Troops994 just a quick note, worked it out and will get a fix out asap.

darylknight commented 2 years ago

Awesome, thanks!

samhibberd commented 2 years ago

Fixed in 3.0.1 and 4.0.1

darylknight commented 2 years ago

Hi Sam,

Thanks for working on this. Unfortunately I'm still getting the same behaviour as before. When I go to the Menu - Main section, it's blank, and I get the server error below:

2022-08-25 08:17:56 [web.ERROR] [Error] Call to a member function getUrl() on null {"trace":["#0 /srv/users/sitename/apps/sitename/vendor/presseddigital/linkit/src/base/Link.php(195): presseddigital\\linkit\\base\\ElementLink->getUrl()","#1 /srv/users/sitename/apps/sitename/vendor/presseddigital/linkit/src/base/Link.php(203): presseddigital\\linkit\\base\\Link->getLink(Array, false, true)","#2 /srv/users/sitename/apps/sitename/vendor/presseddigital/linkit/src/fields/LinkitField.php(263): presseddigital\\linkit\\base\\Link->getLinkPreview()","#3 /srv/users/sitename/apps/sitename/vendor/craftcms/cms/src/base/Element.php(4306): presseddigital\\linkit\\fields\\LinkitField->getTableAttributeHtml(Object(presseddigital\\linkit\\models\\Entry), Object(craft\\elements\\Entry))","#4 /srv/users/sitename/apps/sitename/vendor/craftcms/cms/src/elements/Entry.php(1567): craft\\base\\Element->tableAttributeHtml('field:24d80881-...')","#5 /srv/users/sitename/apps/sitename/vendor/craftcms/cms/src/base/Element.php(4181): craft\\elements\\Entry->tableAttributeHtml('field:24d80881-...')","#6 /srv/users/sitename/apps/sitename/vendor/twig/twig/src/Extension/CoreExtension.php(1607): craft\\base\\Element->getTableAttributeHtml('field:24d80881-...')","#7 /srv/users/sitename/apps/sitename/vendor/craftcms/cms/src/helpers/Template.php(101): twig_get_attribute(Object(craft\\web\\twig\\Environment), Object(Twig\\Source), Object(craft\\elements\\Entry), 'getTableAttribu...', Array, 'method', false, false)","#8 /srv/users/sitename/apps/sitename/storage/runtime/compiled_templates/17/17c24e7f6ef77e4cbb4c7efba52eca2f22aaf8b3f3e3b522324441cc4ef48f54.php(182): craft\\helpers\\Template::attribute(Object(craft\\web\\twig\\Environment), Object(Twig\\Source), Object(craft\\elements\\Entry), 'getTableAttribu...', Array, 'method')","#9 /srv/users/sitename/apps/sitename/vendor/twig/twig/src/Template.php(394): __TwigTemplate_126b64703b7eec5e4b14e3c5981d03e3f5f1a3d827cf6f9baab50162847b5e83->doDisplay(Array, Array)","#10 /srv/users/sitename/apps/sitename/vendor/twig/twig/src/Template.php(367): Twig\\Template->displayWithErrorHandling(Array, Array)","#11 /srv/users/sitename/apps/sitename/storage/runtime/compiled_templates/07/0796aac3010d06725665f0af45b32122dfffd998360f063de4f93fb18ec09c85.php(127): Twig\\Template->display(Array)","#12 /srv/users/sitename/apps/sitename/vendor/twig/twig/src/Template.php(394): __TwigTemplate_ce8400ed3cc1e2500a0abf90829f76d5398ebd5f8c8e408c0af098d71e218618->doDisplay(Array, Array)","#13 /srv/users/sitename/apps/sitename/vendor/twig/twig/src/Template.php(367): Twig\\Template->displayWithErrorHandling(Array, Array)","#14 /srv/users/sitename/apps/sitename/vendor/twig/twig/src/Template.php(379): Twig\\Template->display(Array)","#15 /srv/users/sitename/apps/sitename/vendor/twig/twig/src/TemplateWrapper.php(40): Twig\\Template->render(Array, Array)","#16 /srv/users/sitename/apps/sitename/vendor/twig/twig/src/Environment.php(277): Twig\\TemplateWrapper->render(Array)","#17 /srv/users/sitename/apps/sitename/vendor/craftcms/cms/src/web/View.php(428): Twig\\Environment->render('_elements/table...', Array)","#18 /srv/users/sitename/apps/sitename/vendor/craftcms/cms/src/base/Element.php(1064): craft\\web\\View->renderTemplate('_elements/table...', Array)","#19 /srv/users/sitename/apps/sitename/vendor/craftcms/cms/src/controllers/ElementIndexesController.php(649): craft\\base\\Element::indexHtml(Object(craft\\elements\\db\\EntryQuery), Array, Array, 'section:bd425d8...', 'index', true, true)","#20 /srv/users/sitename/apps/sitename/vendor/craftcms/cms/src/controllers/ElementIndexesController.php(146): craft\\controllers\\ElementIndexesController->elementResponseData(true, true)","#21 [internal function]: craft\\controllers\\ElementIndexesController->actionGetElements()","#22 /srv/users/sitename/apps/sitename/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)","#23 /srv/users/sitename/apps/sitename/vendor/yiisoft/yii2/base/Controller.php(178): yii\\base\\InlineAction->runWithParams(Array)","#24 /srv/users/sitename/apps/sitename/vendor/yiisoft/yii2/base/Module.php(552): yii\\base\\Controller->runAction('get-elements', Array)","#25 /srv/users/sitename/apps/sitename/vendor/craftcms/cms/src/web/Application.php(301): yii\\base\\Module->runAction('element-indexes...', Array)","#26 /srv/users/sitename/apps/sitename/vendor/craftcms/cms/src/web/Application.php(625): craft\\web\\Application->runAction('element-indexes...', Array)","#27 /srv/users/sitename/apps/sitename/vendor/craftcms/cms/src/web/Application.php(280): craft\\web\\Application->_processActionRequest(Object(craft\\web\\Request))","#28 /srv/users/sitename/apps/sitename/vendor/yiisoft/yii2/base/Application.php(384): craft\\web\\Application->handleRequest(Object(craft\\web\\Request))","#29 /srv/users/sitename/apps/sitename/public/index.php(12): yii\\base\\Application->run()","#30 {main}"],"memory":14575424,"exception":"[object] (Error(code: 0): Call to a member function getUrl() on null at /srv/users/sitename/apps/sitename/vendor/presseddigital/linkit/src/base/ElementLink.php:73)"} 
samhibberd commented 2 years ago

@darylknight tracked down another issue related to eager loading disabled elements, will get a fix out.

samhibberd commented 2 years ago

Related issue fixed in 3.0.2 and 4.0.2

darylknight commented 2 years ago

Brilliant, thanks sam! Can confirm this has fixed everything. Really appreciate you getting the update out so quickly.