Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL Error: Column 'navs.propagationMethod' not found in the 'field list' #403

Open
alexanderloewe opened this issue Aug 15, 2024 · 1 comment

Comments

@alexanderloewe
Copy link

Describe the bug

When attempting to load navigation data, the following SQL error occurs due to a missing column, navs.propagationMethod, in the craft_navigation_navs table.

The Site was upgraded from Craft CMS 4.11

Steps to reproduce

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'navs.propagationMethod' in 'field list'
The SQL being executed was: SELECT `navs`.`id`, `navs`.`structureId`, `navs`.`fieldLayoutId`, `navs`.`name`, `navs`.`handle`, `navs`.`instructions`, `navs`.`sortOrder`, `navs`.`maxNodes`, `navs`.`defaultPlacement`, `navs`.`permissions`, `navs`.`uid`, `structures`.`maxLevels`, `navs`.`propagationMethod`, `navs`.`maxNodesSettings`
FROM `craft_navigation_navs` `navs`
LEFT JOIN `craft_structures` `structures` ON (`structures`.`id` = `navs`.`structureId`) AND (`structures`.`dateDeleted` IS NULL)
WHERE `navs`.`dateDeleted` IS NULL
ORDER BY `sortOrder`
Error Info: Array
(
	[0] => 42S22
	[1] => 1054
	[2] => Unknown column 'navs.propagationMethod' in 'field list'
)
↵
Caused by: PDOException
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'navs.propagationMethod' in 'field list'
in /home/mkgarten/public_html/site/v5.0/vendor/yiisoft/yii2/db/Command.php at line 1320

1. in /home/mkgarten/public_html/site/v5.0/vendor/yiisoft/yii2/db/Schema.phpat line 676
667668669670671672673674675676677678679680681682683684685 
		$exceptionClass = '\yii\db\Exception';
		foreach ($this->exceptionMap as $error => $class) {
			if (strpos($e->getMessage(), $error) !== false) {
				$exceptionClass = $class;
			}
		}
		$message = $e->getMessage() . "\nThe SQL being executed was: $rawSql";
		$errorInfo = $e instanceof \PDOException ? $e->errorInfo : null;
		return new $exceptionClass($message, $errorInfo, $e->getCode(), $e);
	}
 
	/**
	 * Returns a value indicating whether a SQL statement is for read purpose.
	 * @param string $sql the SQL statement
	 * @return bool whether a SQL statement is for read purpose.
	 */
	public function isReadQuery($sql)
	{
2. in /home/mkgarten/public_html/site/v5.0/vendor/yiisoft/yii2/db/Command.php at line 1325– yii\db\Schema::convertException(PDOException, 'SELECT `navs`.`id`, `navs`.`stru...')
3. in /home/mkgarten/public_html/site/v5.0/vendor/yiisoft/yii2/db/Command.php at line 1186– yii\db\Command::internalExecute('SELECT `navs`.`id`, `navs`.`stru...')
4. in /home/mkgarten/public_html/site/v5.0/vendor/yiisoft/yii2/db/Command.php at line 417– yii\db\Command::queryInternal('fetchAll', null)
5. in /home/mkgarten/public_html/site/v5.0/vendor/yiisoft/yii2/db/Query.php at line 249– yii\db\Command::queryAll()
6. in /home/mkgarten/public_html/site/v5.0/vendor/craftcms/cms/src/db/Query.php at line 292– yii\db\Query::all(null)
286287288289290291292293294295296297298     * @inheritdoc
	 * @return array<TKey,TValue>
	 */
	public function all($db = null): array
	{
		try {
			return parent::all($db);
		} catch (QueryAbortedException) {
			return [];
		}
	}
 
	/**
7. in /home/mkgarten/public_html/site/v5.0/vendor/verbb/navigation/src/services/Navs.php at line 654– craft\db\Query::all()
648649650651652653654655656657658659660 
	private function _navs(): MemoizableArray
	{
		if (!isset($this->_navs)) {
			$navs = [];
 
			foreach ($this->_createNavQuery()->all() as $result) {
				$navs[] = new NavModel($result);
			}
 
			$this->_navs = new MemoizableArray($navs);
 
			if (!empty($navs) && Craft::$app->getRequest()->getIsCpRequest()) {
8. in /home/mkgarten/public_html/site/v5.0/vendor/verbb/navigation/src/services/Navs.php at line 64– verbb\navigation\services\Navs::_navs()
58596061626364656667686970 
	// Public Methods
	// =========================================================================
 
	public function getAllNavs(): array
	{
		return $this->_navs()->all();
	}
 
	public function getEditableNavs(): array
	{
		if (Craft::$app->getRequest()->getIsConsoleRequest()) {
			return $this->getAllNavs();
9. in /home/mkgarten/public_html/site/v5.0/vendor/verbb/navigation/src/services/Navs.php at line 96– verbb\navigation\services\Navs::getAllNavs()
90919293949596979899100101102        $user = Craft::$app->getUser()->getIdentity();
 
		if (!$user) {
			return [];
		}
 
		return ArrayHelper::where($this->getAllNavs(), function(NavModel $nav) use ($user, $site) {
			return $user->can("navigation-manageNav:$nav->uid") && in_array($site->id, $nav->getSiteIds());
		}, true, true, false);
	}
 
	public function getEditableNavIds(): array
	{
10. in /home/mkgarten/public_html/site/v5.0/vendor/verbb/navigation/src/controllers/NavsController.php at line 41– verbb\navigation\services\Navs::getEditableNavsForSite(craft\models\Site)
35363738394041424344454647        $settings = Navigation::$plugin->getSettings();
 
		// Get the current site from the global query param
		$siteHandle = Craft::$app->getRequest()->getParam('site', Craft::$app->getSites()->getPrimarySite()->handle);
		$site = Craft::$app->getSites()->getSiteByHandle($siteHandle);
 
		$navigations = Navigation::$plugin->getNavs()->getEditableNavsForSite($site);
 
		$editable = $settings->bypassProjectConfig || Craft::$app->getConfig()->getGeneral()->allowAdminChanges;
 
		return $this->renderTemplate('navigation/navs/index', [
			'navigations' => $navigations,
			'editable' => $editable,
11. verbb\navigation\controllers\NavsController::actionIndex()
12. in /home/mkgarten/public_html/site/v5.0/vendor/yiisoft/yii2/base/InlineAction.php at line 57– call_user_func_array([verbb\navigation\controllers\NavsController, 'actionIndex'], [])
13. in /home/mkgarten/public_html/site/v5.0/vendor/yiisoft/yii2/base/Controller.php at line 178– yii\base\InlineAction::runWithParams(['p' => 'admin/navigation'])
14. in /home/mkgarten/public_html/site/v5.0/vendor/yiisoft/yii2/base/Module.php at line 552– yii\base\Controller::runAction('index', ['p' => 'admin/navigation'])
15. in /home/mkgarten/public_html/site/v5.0/vendor/craftcms/cms/src/web/Application.php at line 349– yii\base\Module::runAction('navigation/navs/index', ['p' => 'admin/navigation'])
343344345346347348349350351352353354355     * @param string $route
	 * @param array $params
	 * @return BaseResponse|null The result of the action, normalized into a Response object
	 */
	public function runAction($route, $params = []): ?BaseResponse
	{
		$result = parent::runAction($route, $params);
 
		if ($result === null || $result instanceof BaseResponse) {
			return $result;
		}
 
		$response = $this->getResponse();
16. in /home/mkgarten/public_html/site/v5.0/vendor/yiisoft/yii2/web/Application.php at line 103– craft\web\Application::runAction('navigation/navs/index', ['p' => 'admin/navigation'])
17. in /home/mkgarten/public_html/site/v5.0/vendor/craftcms/cms/src/web/Application.php at line 317– yii\web\Application::handleRequest(craft\web\Request)
311312313314315316317318319320321322323        if (($response = $this->_processActionRequest($request)) !== null) {
			return $response;
		}
 
		// If we’re still here, finally let Yii do its thing.
		try {
			return parent::handleRequest($request);
		} catch (Throwable $e) {
			$this->_unregisterDebugModule();
			throw $e;
		}
	}
 
18. in /home/mkgarten/public_html/site/v5.0/vendor/yiisoft/yii2/base/Application.php at line 384– craft\web\Application::handleRequest(craft\web\Request)
19. in /home/mkgarten/public_html/site/v5.0/web/index.php at line 23– yii\base\Application::run()
17181920212223    Dotenv\Dotenv::createUnsafeMutable(CRAFT_BASE_PATH)->safeLoad();
}
 
// Load and run Craft
define('CRAFT_ENVIRONMENT', getenv('ENVIRONMENT') ?: 'production');
$app = require CRAFT_VENDOR_PATH.'/craftcms/cms/bootstrap/web.php';
$app->run();
$_GET = [
	'p' => 'admin/navigation',
];

$_COOKIE = [
	'CraftSessionId' => '3a074a17ccee167e4b881d865b7bbbc5',
	'1031b8c41dfff97a311a7ac99863bdc5_identity' => 'abe67ab6379cf199e4639b87c3d53b02803df173ba51925c55b014469ade103fa:2:{i:0;s:41:"1031b8c41dfff97a311a7ac99863bdc5_identity";i:1;s:162:"[1161,"[\\"B7z0ohxk3i5Gpau9-i2HgJYrLDuYSC_9sjU4AuJfR7hw7a9_0N593Q44bMTpiDL8hiGsTPJWJQHOvBfZRlz7q3P6uUA00Wp06GSY\\",null,\\"61d1e8e770df13ac11f11fd5073b61d6\\"]",3600]";}',
	'CSRF' => '4c08b682e06b64413ef494e44e0dfb93297c2679c3de129f4bfcd6e27810e45ea:2:{i:0;s:4:"CSRF";i:1;s:150:"ixF__wa70xSTpz6mUK0lN-kjqyLgv2W662051AJm|ad5e0cbbcc04e8796da84c3cc11048020953009e79c492b6b3cb73484d237387ixF__wa70xSTpz6mUK0lN-kjqyLgv2W662051AJm|1161";}',
	'1031b8c41dfff97a311a7ac99863bdc5_username' => '381614e45ff8daa3dfee7fe4381f0a66cdf328e262fd0736dc7a6df8dff3dea3a:2:{i:0;s:41:"1031b8c41dfff97a311a7ac99863bdc5_username";i:1;s:9:"Alexander";}',
	'Craft-25a41936-8e00-4adf-a503-694599c4b55f:sidebar' => 'expanded',
];

$_SESSION = [
	'bd62416aa8538ede709019a5e113eea5__flash' => [],
	'1031b8c41dfff97a311a7ac99863bdc5__token' => 'B7z0ohxk3i5Gpau9-i2HgJYrLDuYSC_9sjU4AuJfR7hw7a9_0N593Q44bMTpiDL8hiGsTPJWJQHOvBfZRlz7q3P6uUA00Wp06GSY',
	'1031b8c41dfff97a311a7ac99863bdc5__id' => 1161,
	'__authKey' => '["B7z0ohxk3i5Gpau9-i2HgJYrLDuYSC_9sjU4AuJfR7hw7a9_0N593Q44bMTpiDL8hiGsTPJWJQHOvBfZRlz7q3P6uUA00Wp06GSY",null,"61d1e8e770df13ac11f11fd5073b61d6"]',
	'1031b8c41dfff97a311a7ac99863bdc5__expire' => 1723713378,
	'__duration' => 3600,
	'bd62416aa8538ede709019a5e113eea5__auth_access' => [
		'editStructure:12',
		'previewElement:1101',
		'saveAssets:3c2eaad5-c05f-4e0f-bc27-b10ef6bbad02',
		'previewDraft:187',
		'previewDraft:188',
		'previewDraft:189',
	],
];

Craft CMS version

5.3.4

Plugin version

3.0.3

Multi-site?

No response

Additional context

No response

@engram-design
Copy link
Member

It almost sounds like this was upgraded from an older version of Navigation on Craft 4 before going to Craft 5.

There was a migration in 2.0.9 that added the functionality of "Propagation Method" and added that column to the database.

I know it might be too late now, but can you confirm what Navigation version you were on before upgrading to Craft 5?

The resolution here might be to uninstall and reinstall the plugin on Craft 5 if you're unable to go back to Craft 4. You would need to re-build your navigations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants