matomo-org / matomo

Empowering People Ethically with the leading open source alternative to Google Analytics that gives you full control over your data. Matomo lets you easily collect data from websites & apps and visualise this data and extract insights. Privacy is built-in. Liberating Web Analytics. Star us on Github? +1. And we love Pull Requests!
https://matomo.org/
GNU General Public License v3.0
19.78k stars 2.63k forks source link

[Bug] SQLSTATE[42S22]: Column not found: 1054 Unknown column 'created_time' in 'field list' - in plugin Funnels. #21822

Closed DmitrySadovnikov closed 8 months ago

DmitrySadovnikov commented 8 months ago

What happened?

After update matomo from the v4 to v5 the command ./console core:archive stopped working with the error: Column not found: 1054 Unknown column 'created_time' in 'field list' - in plugin Funnels.

What should happen?

Archiving must be completed

How can this be reproduced?

Download and install the Funnels plugin

curl -o Funnels.zip -f -sS --data "access_token=YOUR_TOKEN_HERE " https://plugins.matomo.org/api/2.0/plugins/Funnels/download/latest?matomo=5.0.1 \
        && unzip Funnels.zip -d ./pluginsToActivate \
        && rm -f Funnels.zip

./console plugin:activate Funnels

./console core:update --yes

Run archiver

./console core:archive --concurrent-archivers 1

Matomo version

5.0.1

PHP version

8.2.14

Server operating system

Debian GNU/Linux 12 (bookworm)

What browsers are you seeing the problem on?

Not applicable (e.g. an API call etc.)

Computer operating system

Debian GNU/Linux 12 (bookworm)

Relevant log output

INFO [22:02:01] 1 Error: Got invalid response from API request: ?module=API&method=CoreAdminHome.archiveReports&idSite=1&period=day&date=2024-01-18&format=json&trigger=archivephp. Response was '{"result":"error","message":"SQLSTATE[42S22]: Column not found: 1054 Unknown column 'created_time' in 'field list' - in plugin Funnels. #0 \/var\/www\/html\/core\/ArchiveProcessor\/Loader.php(309): Piwik\\ArchiveProcessor\\PluginsArchiver->callAggregateAllPlugins(62, '21', false) #1 \/var\/www\/html\/core\/ArchiveProcessor\/Loader.php(185): Piwik\\ArchiveProcessor\\Loader->prepareAllPluginsArchive(62, '21') #2 \/var\/www\/html\/core\/ArchiveProcessor\/Loader.php(164): Piwik\\ArchiveProcessor\\Loader->insertArchiveData(57.0, 21.0, false, NULL) #3 \/var\/www\/html\/core\/ArchiveProcessor\/Loader.php(104): Piwik\\ArchiveProcessor\\Loader->prepareArchiveImpl(false) #4 \/var\/www\/html\/core\/Context.php(75): Piwik\\ArchiveProcessor\\Loader->Piwik\\ArchiveProcessor\\{closure}() #5 \/var\/www\/html\/core\/ArchiveProcessor\/Loader.php(101): Piwik\\Context::changeIdSite(1, Object(Closure)) #6 \/var\/www\/html\/plugins\/CoreAdminHome\/API.php(297): Piwik\\ArchiveProcessor\\Loader->prepareArchive(false) #7 [internal function]: Piwik\\Plugins\\CoreAdminHome\\API->archiveReports('1', Object(Piwik\\Period\\Day), '2024-01-18', false, false, false) #8 \/var\/www\/html\/core\/API\/Proxy.php(255): call_user_func_array(Array, Array) #9 \/var\/www\/html\/core\/Context.php(28): Piwik\\API\\Proxy->Piwik\\API\\{closure}() #10 \/var\/www\/html\/core\/API\/Proxy.php(158): Piwik\\Context::executeWithQueryParameters(Array, Object(Closure)) #11 \/var\/www\/html\/core\/API\/Request.php(272): Piwik\\API\\Proxy->call('\\\\Piwik\\\\Plugins\\\\...', 'archiveReports', Array) #12 \/var\/www\/html\/plugins\/API\/Controller.php(45): Piwik\\API\\Request->process() #13 [internal function]: Piwik\\Plugins\\API\\Controller->index() #14 \/var\/www\/html\/core\/FrontController.php(637): call_user_func_array(Array, Array) #15 \/var\/www\/html\/core\/FrontController.php(169): Piwik\\FrontController->doDispatch('API', false, Array) #16 \/var\/www\/html\/core\/dispatch.php(32): Piwik\\FrontController->dispatch() #17 \/var\/www\/html\/index.php(25): require_once('\/var\/www\/html\/c...') #18 \/var\/www\/html\/core\/CliMulti\/RequestCommand.php(75): require_once('\/var\/www\/html\/i...') #19 \/var\/www\/html\/core\/Plugin\/ConsoleCommand.php(110): Piwik\\CliMulti\\RequestCommand->doExecute() #20 \/var\/www\/html\/vendor\/symfony\/console\/Command\/Command.php(298): Piwik\\Plugin\\ConsoleCommand->execute(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput)) #21 \/var\/www\/html\/core\/Plugin\/ConsoleCommand.php(125): Symfony\\Component\\Console\\Command\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput)) #22 \/var\/www\/html\/vendor\/symfony\/console\/Application.php(1040): Piwik\\Plugin\\ConsoleCommand->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput)) #23 \/var\/www\/html\/vendor\/symfony\/console\/Application.php(301): Symfony\\Component\\Console\\Application->doRunCommand(Object(Piwik\\CliMulti\\RequestCommand), Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput)) #24 \/var\/www\/html\/core\/Console.php(106): Symfony\\Component\\Console\\Application->doRun(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput)) #25 [internal function]: Piwik\\Console->originDoRun(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput)) #26 \/var\/www\/html\/core\/Console.php(145): call_user_func(Array, Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput)) #27 \/var\/www\/html\/core\/Access.php(670): Piwik\\Console->Piwik\\{closure}() #28 \/var\/www\/html\/core\/Console.php(143): Piwik\\Access::doAsSuperUser(Object(Closure)) #29 \/var\/www\/html\/core\/Console.php(85): Piwik\\Console->doRunImpl(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput)) #30 \/var\/www\/html\/vendor\/symfony\/console\/Application.php(171): Piwik\\Console->doRun(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput)) #31 \/var\/www\/html\/console(32): Symfony\\Component\\Console\\Application->run() #32 {main}, caused by: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'created_time' in 'field list' #0 \/var\/www\/html\/libs\/Zend\/Db\/Statement.php(300): Zend_Db_Statement_Pdo->_execute(Array) #1 \/var\/www\/html\/libs\/Zend\/Db\/Adapter\/Abstract.php(479): Zend_Db_Statement->execute(Array) #2 \/var\/www\/html\/libs\/Zend\/Db\/Adapter\/Pdo\/Abstract.php(238): Zend_Db_Adapter_Abstract->query('INSERT IGNORE I...', Array) #3 \/var\/www\/html\/core\/Db\/Adapter\/Pdo\/Mysql.php(332): Zend_Db_Adapter_Pdo_Abstract->query('INSERT IGNORE I...', Array) #4 \/var\/www\/html\/core\/Db.php(281): Piwik\\Db\\Adapter\\Pdo\\Mysql->query('INSERT IGNORE I...', Array) #5 \/var\/www\/html\/core\/Db\/BatchInsert.php(43): Piwik\\Db::query('INSERT IGNORE I...', Array) #6 \/var\/www\/html\/core\/Db\/BatchInsert.php(135): Piwik\\Db\\BatchInsert::tableInsertBatchIterate('dbuser_log_funn...', Array, Array) #7 \/var\/www\/html\/plugins\/Funnels\/Dao\/LogTable.php(191): Piwik\\Db\\BatchInsert::tableInsertBatch('dbuser_log_funn...', Array, Array, false, 'latin1') #8 \/var\/www\/html\/plugins\/Funnels\/Archiver\/Populator.php(290): Piwik\\Plugins\\Funnels\\Dao\\LogTable->bulkInsert(1, 3, 1, A ... )\n#46 \/var\/www\/html\/console(32): Symfony\\Component\\Console\\Application->run()\n#47 {main}"}'


### Validations

- [X] Read our [Contributing Guidelines](https://github.com/matomo-org/matomo/blob/5.x-dev/CONTRIBUTING.md).
- [X] Follow our [Security Policy](https://github.com/matomo-org/matomo/blob/5.x-dev/SECURITY.md).
- [X] Check that there isn't already an issue that reports the same bug to avoid creating duplicates.
- [X] The provided steps to reproduce is a [minimal reproducible](https://stackoverflow.com/help/minimal-reproducible-example) of the Bug.
AltamashShaikh commented 8 months ago

@DmitrySadovnikov Can you run this SQL command ? This was a new column added in Matomo 5 for performance improvement

ALTER TABLE `matomo_log_funnel` ADD `created_time` DATETIME NOT NULL
DmitrySadovnikov commented 8 months ago

@DmitrySadovnikov Can you run this SQL command ? This was a new column added in Matomo 5 for performance improvement

ALTER TABLE `matomo_log_funnel` ADD `created_time` DATETIME NOT NULL

Thank you @AltamashShaikh. This has fixed the error.

michalkleiner commented 8 months ago

@DmitrySadovnikov just putting this info here for a good measure — as Funnels is a premium plugin, don't hesitate to contact the support team at shop@innocraft.com in future should you encounter an issue with it. This repository and the issue tracker is primarily for the core Matomo application, not for premium plugins. Thanks, we do appreciate your understanding!

michalkleiner commented 8 months ago

@AltamashShaikh just checking — is the migration (the column addition) covered in the plugin or do we need something more? Thanks!

AltamashShaikh commented 8 months ago

@michalkleiner Its covered in migration script in the plugin. Screenshot from 2024-01-19 06-41-08