Skip to content

Commit

Permalink
Use entry model to get ID rather than variable
Browse files Browse the repository at this point in the history
This fixes an issue where changing the entryType of an existing entry triggers a 500 error:

PHP Notice 'yii\base\ErrorException' with message 'Undefined index: entryId' 

in /Volumes/Sites/Personal/craft3/vendor/craftcms/cms/src/controllers/EntriesController.php:773

Stack trace:
#0 … vendor/yiisoft/yii2/base/InlineAction.php(57): craft\controllers\EntriesController->actionSwitchEntryType()
#1 … vendor/yiisoft/yii2/base/InlineAction.php(57): ::call_user_func_array:{/Volumes/Sites/Personal/craft3/vendor/yiisoft/yii2/base/InlineAction.php:57}('???', '???')
#2 … vendor/yiisoft/yii2/base/Controller.php(156): yii\base\InlineAction->runWithParams('???')
#3 … vendor/yiisoft/yii2/base/Module.php(523): yii\base\Controller->runAction('???', '???')
#4 … vendor/craftcms/cms/src/web/Application.php(246): yii\base\Module->runAction('???', '???')
#5 … vendor/craftcms/cms/src/web/Application.php(385): craft\web\Application->runAction('???', '???')
#6 … vendor/craftcms/cms/src/web/Application.php(206): craft\web\Application->_processActionRequest('???')
#7 … vendor/yiisoft/yii2/base/Application.php(380): craft\web\Application->handleRequest('???')
#8 … web/index.php(33): yii\base\Application->run()
#9 {main}
  • Loading branch information
leevigraham authored and brandonkelly committed Jun 1, 2017
1 parent 6a9dd06 commit 53c6d6c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/controllers/EntriesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ private function _prepEditEntryVariables(array &$variables)
}

if ($variables['entry']->id) {
$versions = Craft::$app->getEntryRevisions()->getVersionsByEntryId($variables['entryId'], $site->id, 1, true);
$versions = Craft::$app->getEntryRevisions()->getVersionsByEntryId($variables['entry']->id, $site->id, 1, true);
/** @var EntryVersion $currentVersion */
$currentVersion = reset($versions);

Expand Down

0 comments on commit 53c6d6c

Please sign in to comment.