verbb / zen

A Craft CMS plugin to manage content across multiple environments with ease.
Other
3 stars 0 forks source link

Support of Hyper fields #7

Closed gglnx closed 6 months ago

gglnx commented 6 months ago

What are you trying to do?

Export and importing of Hyper fields. Especially links to entries.

What's your proposed solution?

SCR-20240305-ryyp

Use UID instead of IDs.

Additional context

No response

engram-design commented 6 months ago

Added for the next release. To get this early, run composer require verbb/zen:"dev-craft-4 as 1.0.1".

gglnx commented 6 months ago

I tried it, but I get the following error:

craft\helpers\Db::uidById(): Argument #2 ($id) must be of type int, null given, called in /vendor/verbb/zen/src/fields/Hyper.php on line 33
/vendor/craftcms/cms/src/helpers/Db.php:1376
/vendor/verbb/zen/src/fields/Hyper.php:33
engram-design commented 6 months ago

Right, looks like that might be a link with no value set. Just pushed a fix for that if you can run composer require verbb/zen:"dev-craft-4 as 1.0.1".

gglnx commented 6 months ago

Exporting works, while importing I'm getting this:

Call to undefined method craft\helpers\Db::idByUd()
/vendor/verbb/zen/src/fields/Hyper.php:51
/vendor/verbb/zen/src/services/Fields.php:200
engram-design commented 6 months ago

Sorry, that's my fault with a typo... Run that again

gglnx commented 6 months ago

I'm getting stuck at the »Run Import« step with the following error: foreach() argument must be of type array|object, null given. From the queue.log:

2024-03-14 12:08:55 [queue.ERROR] [craft\queue\QueueLogBehavior::afterError]  [71540] t9n:["zen","Importing content via Zen."] (attempt: 1, pid: 28097) - Error (time: 4.272s): foreach() argument must be of type array|object, null given {"memory":108997840}
2024-03-14 12:08:55 [queue.ERROR] [yii\base\ErrorException:2] yii\base\ErrorException: foreach() argument must be of type array|object, null given in /vendor/verbb/zen/src/fields/Hyper.php:45
Stack trace:
#0 /vendor/craftcms/cms/src/web/ErrorHandler.php(79): yii\base\ErrorHandler->handleError(2, 'foreach() argum...', '/Users/dennis/P...', 45)
#1 /vendor/verbb/zen/src/fields/Hyper.php(45): craft\web\ErrorHandler->handleError(2, 'foreach() argum...', '/Users/dennis/P...', 45)
#2 /vendor/verbb/zen/src/services/Fields.php(200): verbb\zen\fields\Hyper::normalizeValue(Object(verbb\hyper\fields\HyperField), Object(craft\elements\MatrixBlock), NULL)
#3 /vendor/verbb/zen/src/fields/Matrix.php(95): verbb\zen\services\Fields->normalizeValue(Object(verbb\hyper\fields\HyperField), Object(craft\elements\MatrixBlock), NULL)
#4 /vendor/verbb/zen/src/services/Fields.php(200): verbb\zen\fields\Matrix::normalizeValue(Object(craft\fields\Matrix), Object(craft\elements\Entry), Array)
#5 /vendor/verbb/zen/src/base/Element.php(383): verbb\zen\services\Fields->normalizeValue(Object(craft\fields\Matrix), Object(craft\elements\Entry), Array)
#6 /vendor/verbb/zen/src/base/Element.php(347): verbb\zen\base\Element::getNormalizedElementFields(Object(craft\elements\Entry), Array)
#7 /vendor/verbb/zen/src/services/Import.php(185): verbb\zen\base\Element::getNormalizedElement(Array, true)
#8 /vendor/verbb/zen/src/services/Import.php(493): verbb\zen\services\Import->getImportConfiguration(Array, true)
#9 /vendor/verbb/zen/src/queue/jobs/RunImport.php(39): verbb\zen\services\Import->getElementsToImport('zen-import-2403...', Array)
#10 /vendor/yiisoft/yii2-queue/src/Queue.php(243): verbb\zen\queue\jobs\RunImport->execute(Object(craft\queue\Queue))
#11 /vendor/yiisoft/yii2-queue/src/cli/Queue.php(147): yii\queue\Queue->handleMessage(71540, 'O:30:"verbb\\zen...', 600, 1)
#12 /vendor/craftcms/cms/src/queue/Queue.php(191): yii\queue\cli\Queue->handleMessage(71540, 'O:30:"verbb\\zen...', 600, 1)
#13 /vendor/craftcms/cms/src/queue/Queue.php(166): craft\queue\Queue->executeJob()
#14 [internal function]: craft\queue\Queue->craft\queue\{closure}(Object(Closure))
#15 /vendor/yiisoft/yii2-queue/src/cli/Queue.php(117): call_user_func(Object(Closure), Object(Closure))
#16 /vendor/craftcms/cms/src/queue/Queue.php(174): yii\queue\cli\Queue->runWorker(Object(Closure))
#17 /vendor/craftcms/cms/src/controllers/QueueController.php(82): craft\queue\Queue->run()
#18 [internal function]: craft\controllers\QueueController->actionRun()
#19 /vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#20 /vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#21 /vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction('run', Array)
#22 /vendor/craftcms/cms/src/web/Application.php(341): yii\base\Module->runAction('queue/run', Array)
#23 /vendor/craftcms/cms/src/web/Application.php(642): craft\web\Application->runAction('queue/run', Array)
#24 /vendor/craftcms/cms/src/web/Application.php(303): craft\web\Application->_processActionRequest(Object(craft\web\Request))
#25 /vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest(Object(craft\web\Request))
#26 /web/index.php(14): yii\base\Application->run()
#27 {main} {"memory":108998592,"exception":"[object] (yii\\base\\ErrorException(code: 2): foreach() argument must be of type array|object, null given at /vendor/verbb/zen/src/fields/Hyper.php:45)"}

This could be more an issue with Hyper itself (no static version of the field), but no preview is rendered:

SCR-20240314-kyit

If you are interested, I can send you the Zen export via mail.

engram-design commented 6 months ago

An export would be great to support@verbb.io - I think something else might be going on in this case. This Hyper field also seems to be in a Matrix field?

gglnx commented 6 months ago

I send it :)

Some Hyper fields are inside Matrix and Neo fields, some are not. In the screenshot for the missing preview the field is not inside a Matrix or Neo field.

engram-design commented 6 months ago

Just pushed up another fix for that

gglnx commented 6 months ago

Works and looks great. Thank you! <3