Cockpit-HQ / Cockpit

Cockpit Core - Content Platform
https://getcockpit.com
Other
388 stars 47 forks source link

Login: SQLSTATE[HY000]: General error: 1 no such column: criteria667bbee641d33 #194

Closed adiba closed 3 months ago

adiba commented 4 months ago

When trying to log in (with $debug=true), I receive an error toast:

SQLSTATE[HY000]: General error: 1 no such column: criteria667bbee641d33

the HEX string after 'criteria' changes, but always starts with 667.

My cockpit v2.3.0 installation worked fine on the same system for a year until this week. I didn't even change anything in code, data, or configuration.
I also tried to re-install - same problem.

Any ideas how I can debug this further and track down the problem?

aheinze commented 4 months ago

Hey 👋

Hard to tell what is wrong here. Did anything changed with your infra setup (php version etc?)

adiba commented 4 months ago

Hey 👋

Hard to tell what is wrong here. Did anything changed with your infra setup (php version etc?)

Thank you for your reply :)

I did not change anything and apparently my hosting provider did not change anything either.
The PHP version has been 8.1 since day 1.

Orygaw commented 4 months ago

Hello, i have the same error. I am using sqlite 3.46.0. I noticed that when I edit the code, the connections look correct: lib/MongoLite/Cursor.php

$sql[] = 'WHERE document_criteria("'.$this->criteria.'", document)'; Change to:

$sql[] = 'WHERE document_criteria(\''.$this->criteria.'\', document)';

Is it a matter of sqlite itself or Cockpit? The error started appearing recently. I am unable to install the new version of Cockpit.

aheinze commented 4 months ago

Cockpit requires PHP 8.2. Can you confirm that you use PHP >= 8.2?

Munrok commented 3 months ago

This is not a PHP issue. The SQLite developers have been announcing the change for years, but the Cockpit developers missed it. It is explained here: https://sqlite.org/quirks.html#double_quoted_string_literals_are_accepted.

aheinze commented 3 months ago

Thank you for the hint 👍 Fix will be available in the next release!

pshemek commented 2 months ago

Hi @aheinze, it seems that the fix should be applied here as well:

COCKPIT[ERROR]: SQLSTATE[HY000]: General error: 1 no such column: "criteria66d71829062f3" - should this be a string literal in single-quotes? @/lib/MongoLite/Collection.php:146

$sql = 'SELECT id, document FROM'.$this->name.'WHERE document_criteria("'.$this->database->registerCriteriaFunction($criteria).'", document)';

I hope no other places left.

aheinze commented 2 months ago

Hi @aheinze, it seems that the fix should be applied here as well:

COCKPIT[ERROR]: SQLSTATE[HY000]: General error: 1 no such column: "criteria66d71829062f3" - should this be a string literal in single-quotes? @/lib/MongoLite/Collection.php:146

$sql = 'SELECT id, document FROM'.$this->name.'WHERE document_criteria("'.$this->database->registerCriteriaFunction($criteria).'", document)';

I hope no other places left.

Thank you for reporting!

pshemek commented 2 months ago

In @/lib/MongoLite/Cursor.php

$sql[] = 'WHERE document_criteria("'.$this->criteria.'", document)';

into

$sql[] = "WHERE document_criteria('{$this->criteria}', document)";

as well.

aheinze commented 2 months ago

@pshemek this should already be fixed in the current dev codebase