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('???')
craftcms#3 … vendor/yiisoft/yii2/base/Module.php(523): yii\base\Controller->runAction('???', '???')
craftcms#4 … vendor/craftcms/cms/src/web/Application.php(246): yii\base\Module->runAction('???', '???')
craftcms#5 … vendor/craftcms/cms/src/web/Application.php(385): craft\web\Application->runAction('???', '???')
craftcms#6 … vendor/craftcms/cms/src/web/Application.php(206): craft\web\Application->_processActionRequest('???')
craftcms#7 … vendor/yiisoft/yii2/base/Application.php(380): craft\web\Application->handleRequest('???')
craftcms#8 … web/index.php(33): yii\base\Application->run()
craftcms#9 {main}
  • Loading branch information
leevigraham committed Jun 1, 2017
1 parent 6a9dd06 commit 2ad1e23
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 2ad1e23

Please sign in to comment.