News: Undefined class constant 'NAME'

Created on 2 Oct 2020  路  19Comments  路  Source: nextcloud/news

IMPORTANT

Read and tick the following checkbox after you have created the issue or place an x inside the brackets ;)

Explain the Problem

While updating the news app from 14.2.2 to 15.0.0 an error occured and it stuck in maintenance mode.
After manually running the upgrade and disabling the maintenance mode it worked fine.

It seems to be the following line
https://github.com/nextcloud/news/blob/9e84bf054e63af3844c39919f3185c19c26ed014/lib/Config/LegacyConfig.php#L53

Steps to Reproduce

Explain what you did to encounter the issue

  1. upgrade from 14.2.2 to 15.0.0

System Information

  • News app version: now 15.0.0
  • Nextcloud version: 20.0.0 RC2
  • Cron type: System-Cron
  • PHP version: 7.3.18
  • Database and version: mysql 10.1.45

Contents of nextcloud/data/nextcloud.log


{"reqId":"MceMNKghWPrsr1XGmMIG","level":3,"time":"2020-10-01T16:41:14+00:00","remoteAddr":"127.0.0.1","user":"anoymouserver","app":"index","method":"GET","url":"/settings/apps/update/news","message":{"Exception":"Exception","Message":"Undefined class constant 'NAME'","Code":0,"Trace":[{"file":"/var/www/cloud/lib/private/AppFramework/App.php","line":152,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\Settings\\Controller\\AppSettingsController"},"updateApp"]},{"file":"/var/www/cloud/lib/private/Route/Router.php","line":308,"function":"main","class":"OC\\AppFramework\\App","type":"::","args":["OCA\\Settings\\Controller\\AppSettingsController","updateApp",{"__class__":"OC\\AppFramework\\DependencyInjection\\DIContainer"},{"action":null,"appId":"news","_route":"settings.AppSettings.updateApp"}]},{"file":"/var/www/cloud/lib/base.php","line":1009,"function":"match","class":"OC\\Route\\Router","type":"->","args":["/settings/apps/update/news"]},{"file":"/var/www/cloud/index.php","line":37,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"/var/www/cloud/lib/private/AppFramework/Http/Dispatcher.php","Line":110,"Previous":{"Exception":"Error","Message":"Undefined class constant 'NAME'","Code":0,"Trace":[{"function":"__construct","class":"OCA\\News\\Config\\LegacyConfig","type":"->","args":[{"__class__":"OC\\Files\\Node\\Folder"},{"__class__":"OC\\AppFramework\\ScopedPsrLogger"}]},{"file":"/var/www/cloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":101,"function":"newInstanceArgs","class":"ReflectionClass","type":"->","args":[[{"__class__":"OC\\Files\\Node\\Folder"},{"__class__":"OC\\AppFramework\\ScopedPsrLogger"}]]},{"file":"/var/www/cloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":109,"function":"buildClass","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->","args":[{"name":"OCA\\News\\Config\\LegacyConfig","__class__":"ReflectionClass"}]},{"file":"/var/www/cloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":126,"function":"resolve","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->","args":["OCA\\News\\Config\\LegacyConfig"]},{"file":"/var/www/cloud/lib/private/AppFramework/DependencyInjection/DIContainer.php","line":455,"function":"query","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->","args":["OCA\\News\\Config\\LegacyConfig"]},{"file":"/var/www/cloud/lib/private/AppFramework/DependencyInjection/DIContainer.php","line":427,"function":"queryNoFallback","class":"OC\\AppFramework\\DependencyInjection\\DIContainer","type":"->","args":["OCA\\News\\Config\\LegacyConfig"]},{"file":"/var/www/cloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":87,"function":"query","class":"OC\\AppFramework\\DependencyInjection\\DIContainer","type":"->","args":["OCA\\News\\Config\\LegacyConfig",true]},{"function":"OC\\AppFramework\\Utility\\{closure}","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/cloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":101,"function":"array_map","args":[{"__class__":"Closure"},["*** sensitive parameter replaced ***",{"name":"iConfig","__class__":"ReflectionParameter"}]]},{"file":"/var/www/cloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":109,"function":"buildClass","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->","args":[{"name":"OCA\\News\\Migration\\MigrateConfig","__class__":"ReflectionClass"}]},{"file":"/var/www/cloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":126,"function":"resolve","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->","args":["OCA\\News\\Migration\\MigrateConfig"]},{"file":"/var/www/cloud/lib/private/AppFramework/DependencyInjection/DIContainer.php","line":455,"function":"query","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->","args":["OCA\\News\\Migration\\MigrateConfig"]},{"file":"/var/www/cloud/lib/private/ServerContainer.php","line":140,"function":"queryNoFallback","class":"OC\\AppFramework\\DependencyInjection\\DIContainer","type":"->","args":["OCA\\News\\Migration\\MigrateConfig"]},{"file":"/var/www/cloud/lib/private/Repair.php","line":119,"function":"query","class":"OC\\ServerContainer","type":"->","args":["OCA\\News\\Migration\\MigrateConfig"]},{"file":"/var/www/cloud/lib/private/legacy/OC_App.php","line":1035,"function":"addStep","class":"OC\\Repair","type":"->","args":["OCA\\News\\Migration\\MigrateConfig"]},{"file":"/var/www/cloud/lib/private/legacy/OC_App.php","line":979,"function":"executeRepairSteps","class":"OC_App","type":"::","args":["*** sensitive parameter replaced ***",["OCA\\News\\Migration\\MigrateStatusFlags","OCA\\News\\Migration\\MigrateConfig"]]},{"file":"/var/www/cloud/lib/private/Installer.php","line":206,"function":"updateApp","class":"OC_App","type":"::","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/cloud/apps/settings/lib/Controller/AppSettingsController.php","line":532,"function":"updateAppstoreApp","class":"OC\\Installer","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/cloud/lib/private/AppFramework/Http/Dispatcher.php","line":169,"function":"updateApp","class":"OCA\\Settings\\Controller\\AppSettingsController","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/cloud/lib/private/AppFramework/Http/Dispatcher.php","line":100,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\Settings\\Controller\\AppSettingsController"},"updateApp"]},{"file":"/var/www/cloud/lib/private/AppFramework/App.php","line":152,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\Settings\\Controller\\AppSettingsController"},"updateApp"]},{"file":"/var/www/cloud/lib/private/Route/Router.php","line":308,"function":"main","class":"OC\\AppFramework\\App","type":"::","args":["OCA\\Settings\\Controller\\AppSettingsController","updateApp",{"__class__":"OC\\AppFramework\\DependencyInjection\\DIContainer"},{"action":null,"appId":"*** sensitive parameter replaced ***","_route":"settings.AppSettings.updateApp"}]},{"file":"/var/www/cloud/lib/base.php","line":1009,"function":"match","class":"OC\\Route\\Router","type":"->","args":["/settings/apps/update/news"]},{"file":"/var/www/cloud/index.php","line":37,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"/var/www/cloud/apps/news/lib/Config/LegacyConfig.php","Line":53},"CustomMessage":"--"},"userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0","version":"20.0.0.8","id":"5f76ccb69d13b"}

bug

All 19 comments

Happened again, this time while upgrading from 14.2.2 to 15.0.1.

This time the following line is marked
https://github.com/nextcloud/news/blob/2f9fbf9491db09395481626487f018d927339972/lib/Migration/MigrateConfig.php#L55

{"reqId":"wq8QK6fQNfV4Sx89TpuG","level":3,"time":"2020-10-03T14:18:13+00:00","remoteAddr":"127.0.0.1","user":"anoymouserver","app":"index","method":"GET","url":"/settings/apps/update/news","message":{"Exception":"Exception","Message":"Undefined class constant 'NAME'","Code":0,"Trace":[{"file":"/var/www/cloud/lib/private/AppFramework/App.php","line":152,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\Settings\\Controller\\AppSettingsController"},"updateApp"]},{"file":"/var/www/cloud/lib/private/Route/Router.php","line":308,"function":"main","class":"OC\\AppFramework\\App","type":"::","args":["OCA\\Settings\\Controller\\AppSettingsController","updateApp",{"__class__":"OC\\AppFramework\\DependencyInjection\\DIContainer"},{"action":null,"appId":"news","_route":"settings.AppSettings.updateApp"}]},{"file":"/var/www/cloud/lib/base.php","line":1009,"function":"match","class":"OC\\Route\\Router","type":"->","args":["/settings/apps/update/news"]},{"file":"/var/www/cloud/index.php","line":37,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"/var/www/cloud/lib/private/AppFramework/Http/Dispatcher.php","Line":110,"Previous":{"Exception":"Error","Message":"Undefined class constant 'NAME'","Code":0,"Trace":[{"file":"/var/www/cloud/lib/private/Repair.php","line":106,"function":"run","class":"OCA\\News\\Migration\\MigrateConfig","type":"->","args":[{"__class__":"OC\\Repair"}]},{"file":"/var/www/cloud/lib/private/legacy/OC_App.php","line":1042,"function":"run","class":"OC\\Repair","type":"->","args":[]},{"file":"/var/www/cloud/lib/private/legacy/OC_App.php","line":979,"function":"executeRepairSteps","class":"OC_App","type":"::","args":["*** sensitive parameter replaced ***",["OCA\\News\\Migration\\MigrateStatusFlags","OCA\\News\\Migration\\MigrateConfig"]]},{"file":"/var/www/cloud/lib/private/Installer.php","line":206,"function":"updateApp","class":"OC_App","type":"::","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/cloud/apps/settings/lib/Controller/AppSettingsController.php","line":532,"function":"updateAppstoreApp","class":"OC\\Installer","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/cloud/lib/private/AppFramework/Http/Dispatcher.php","line":169,"function":"updateApp","class":"OCA\\Settings\\Controller\\AppSettingsController","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/cloud/lib/private/AppFramework/Http/Dispatcher.php","line":100,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\Settings\\Controller\\AppSettingsController"},"updateApp"]},{"file":"/var/www/cloud/lib/private/AppFramework/App.php","line":152,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\Settings\\Controller\\AppSettingsController"},"updateApp"]},{"file":"/var/www/cloud/lib/private/Route/Router.php","line":308,"function":"main","class":"OC\\AppFramework\\App","type":"::","args":["OCA\\Settings\\Controller\\AppSettingsController","updateApp",{"__class__":"OC\\AppFramework\\DependencyInjection\\DIContainer"},{"action":null,"appId":"*** sensitive parameter replaced ***","_route":"settings.AppSettings.updateApp"}]},{"file":"/var/www/cloud/lib/base.php","line":1009,"function":"match","class":"OC\\Route\\Router","type":"->","args":["/settings/apps/update/news"]},{"file":"/var/www/cloud/index.php","line":37,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"/var/www/cloud/apps/news/lib/Migration/MigrateConfig.php","Line":55},"CustomMessage":"--"},"userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0","version":"20.0.0.8","id":"5f788876378f4"}

I wonder why I didn't get these issues while updating, maybe because I ran into other issues and therefore did the migration in multiple steps ...

I tried to reproduce this locally
PHP 7.4.10

  1. NC-Server git v20.0.0 (add viewer repo and build v20.0.0)
  2. do maintenance install with sqlite.db
  3. install news 14.2.2 from git
  4. switch to 15.0.1 from git
  5. run occ upgrade and occ maintenance:repair

But no issue

mh strange, maybe it's something in my installation.

I had a similar issue, I think this is valid

I had the same issue and could fix it by removing the first ->execute() in file lib/Db/NewsMapperV2.php line 76 like it was done in latest commit https://github.com/nextcloud/news/commit/d1b0e299f1df0c94e5cc63afcd03f0bc42c6430d.
After removal, I could finish the upgrade with ./occ upgrade.

@Killerjoe it's very unlikely that these two issues are connected, since I could resume the upgrade manually using occ, but found the other issue over an hour later. Also the MigrateConfig.php only moves the config entries to the database but the NewsMapperV2.php is used to update/purge/.. actual feed data.

@anoymouserver I can only tell what happend to me.
I have started the upgrade from 19.0.40RC1 to 20.0.0 with the Web Upgrade.
In the end the upgrade was not completed and it only told me about an failure.
I then started to use ./occ upgrade in the console and I saw a failure in line 55 in the file MigrateConfig.php like you pointed out in your post https://github.com/nextcloud/news/issues/820#issuecomment-703112061.
I have then removed the duplicate entry execute() in line 76 of the news app file lib/Db/NewsMapperV2.php and restarted the upgrade with ./ooc upgrade and this time the upgrade was successful for me.
Afterwards I had issues with the default encryption app and the passwords app but these issues came after the upgrade was finished.

Is #833 related to this issue or maybe even a fix?

It should fix it, but no release yet.

Is #833 related to this issue or maybe even a fix?

I had this issue, and made the change manually as per #833, and upgrade completed successfully.

I'm seeing this error and it appears #833 was in my copy.

Update app news from appstore
An unhandled exception has been thrown:
Error: Undefined class constant 'NAME' in /usr/share/webapps/nextcloud/apps2/news/lib/Migration/MigrateConfig.php:56
Stack trace:
#0 /usr/share/webapps/nextcloud/lib/private/Repair.php(106): OCA\News\Migration\MigrateConfig->run()
#1 /usr/share/webapps/nextcloud/lib/private/legacy/OC_App.php(1042): OC\Repair->run()
#2 /usr/share/webapps/nextcloud/lib/private/legacy/OC_App.php(979): OC_App::executeRepairSteps()
#3 /usr/share/webapps/nextcloud/lib/private/Installer.php(206): OC_App::updateApp()
#4 /usr/share/webapps/nextcloud/lib/private/Updater.php(452): OC\Installer->updateAppstoreApp()
#5 /usr/share/webapps/nextcloud/lib/private/Updater.php(260): OC\Updater->upgradeAppStoreApps()
#6 /usr/share/webapps/nextcloud/lib/private/Updater.php(130): OC\Updater->doUpgrade()
#7 /usr/share/webapps/nextcloud/core/Command/Upgrade.php(255): OC\Updater->upgrade()
#8 /usr/share/webapps/nextcloud/3rdparty/symfony/console/Command/Command.php(255): OC\Core\Command\Upgrade->execute()
#9 /usr/share/webapps/nextcloud/3rdparty/symfony/console/Application.php(1000): Symfony\Component\Console\Command\Command->run()
#10 /usr/share/webapps/nextcloud/3rdparty/symfony/console/Application.php(271): Symfony\Component\Console\Application->doRunCommand()
#11 /usr/share/webapps/nextcloud/3rdparty/symfony/console/Application.php(147): Symfony\Component\Console\Application->doRun()
#12 /usr/share/webapps/nextcloud/lib/private/Console/Application.php(215): Symfony\Component\Console\Application->run()
#13 /usr/share/webapps/nextcloud/console.php(100): OC\Console\Application->run()
#14 /usr/share/webapps/nextcloud/occ(11): require_once('/usr/share/weba...')
#15 {main}

Anyone still experiencing this in 15.0.4?

Hi, thanks for this fix.

Can we cherry-pick this fix for NC19? Maybe create a "News 14.2.3 hotfix" release?

The reason is that I cannot push the update to NC20 for NextCloudPi users because this bug prevents the updater to do NC19->NC20.

https://github.com/nextcloud/nextcloudpi/issues/1177#issuecomment-733473341

A Backport won't help, if you upgrade nextcloud the normal way via the integrated updater it will first update itself so NC 20
Then it will run the upgrade, in that progress it will pull the new news from the AppStore and run the migrations and repairs.

So if this still fails my guess is that there is still s bug in the new version 15.0.6 or that we can't fix it.

Would be nice to have some help regarding testing this, clean nextcloud 19 install, install news from the store, run into automatic update.

I see, we don't use the NC updater, it has been very buggy in the past. Instead we use our own, but I guess I can try to replicate that behavior if it's the correct one.

Thanks

Well it has to be the same 15.0.6 won't activate on NC19 unless you force it somehow.

Great, that seems to do it. Thanks!

Was this page helpful?
0 / 5 - 0 ratings