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

Error in cron.php since Nextcloud Version 29 #663

Open
mluettermann opened this issue May 3, 2024 · 14 comments · May be fixed by #725
Open

Error in cron.php since Nextcloud Version 29 #663

mluettermann opened this issue May 3, 2024 · 14 comments · May be fixed by #725

Comments

@mluettermann
Copy link

Since the NC 29 update, I've been receiving the following error message with Cron.php:

Error: Class "OC\BackgroundJob\TimedJob" not found in /var/www/html/custom_apps/backup/lib/Cron/Backup.php:48
Stack trace:
#0 /var/www/html/lib/composer/composer/ClassLoader.php(576): include()
#1 /var/www/html/lib/composer/composer/ClassLoader.php(427): Composer\Autoload\{closure}('/var/www/html/c...')
#2 [internal function]: Composer\Autoload\ClassLoader->loadClass('OCA\\Backup\\Cron...')
#3 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(126): ReflectionClass->__construct('OCA\\Backup\\Cron...')
#4 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(146): OC\AppFramework\Utility\SimpleContainer->resolve('OCA\\Backup\\Cron...')
#5 /var/www/html/lib/private/AppFramework/DependencyInjection/DIContainer.php(470): OC\AppFramework\Utility\SimpleContainer->query('OCA\\Backup\\Cron...')
#6 /var/www/html/lib/private/ServerContainer.php(155): OC\AppFramework\DependencyInjection\DIContainer->queryNoFallback('OCA\\Backup\\Cron...')
#7 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(64): OC\ServerContainer->query('OCA\\Backup\\Cron...')
#8 /var/www/html/lib/public/Server.php(55): OC\AppFramework\Utility\SimpleContainer->get('OCA\\Backup\\Cron...')
#9 /var/www/html/lib/private/BackgroundJob/JobList.php(326): OCP\Server::get('OCA\\Backup\\Cron...')
#10 /var/www/html/lib/private/BackgroundJob/JobList.php(235): OC\BackgroundJob\JobList->buildJob(Array)
#11 /var/www/html/cron.php(163): OC\BackgroundJob\JobList->getNext(true)
#12 {main}

I'm using NC in a Docker environment

version: '3.3'

services:
  nextcloud-db:
    image: mariadb
    container_name: nextcloud-mariadb
    command: --transaction-isolation=READ-COMMITTED --innodb_read_only_compressed=OFF
    restart: always
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro
      - ${FILES_LOCATION}/db:/var/lib/mysql
    environment:
        MYSQL_ROOT_PASSWORD: ${root_pwd}
        MYSQL_PASSWORD: ${db_pwd}
        MYSQL_DATABASE: ${db_name}
        MYSQL_USER: ${db_user}
        MYSQL_INITDB_SKIP_TZINFO: ${MYSQL_INITDB_SKIP_TZINFO}
        MARIADB_AUTO_UPGRADE: ${MARIADB_AUTO_UPGRADE}
  
  nextcloud-redis:
    image: redis:alpine
    container_name: nextcloud-redis
    hostname: nextcloud-redis
    networks:
        - default
    restart: unless-stopped
    command: redis-server --requirepass ${db_pwd}
  
  nextcloud-app:
    image: nextcloud
    container_name: nextcloud-app
    depends_on:
      - nextcloud-db
      - nextcloud-redis
    environment:
        MAINTENANCE_WINDOW_START: ${MAINTENANCE_WINDOW_START}
        TRUSTED_PROXIES: ${TRUSTED_PROXIES}
        OVERWRITEPROTOCOL: ${OVERWRITEPROTOCOL}
        OVERWRITECLIURL: ${OVERWRITECLIURL}
        OVERWRITEHOST: ${OVERWRITEHOST}
        REDIS_HOST: ${REDIS_HOST}
        REDIS_HOST_PASSWORD: ${db_pwd}
        PHP_MEMORY_LIMIT: ${PHP_MEMORY_LIMIT}
        PHP_UPLOAD_LIMIT: ${PHP_UPLOAD_LIMIT}
    networks:
      - default
      - traefik_proxy
    volumes:
      - ${FILES_LOCATION}/nextcloud:/var/www/html
    restart: always
    labels:
        traefik.enable: true
        traefik.docker.network: traefik_proxy
        traefik.http.routers.nextcloud.rule: Host(`nextcloud.example.com`)
        traefik.http.routers.nextcloud.entrypoints: websecure
        traefik.http.routers.nextcloud.service: nextcloud
        traefik.http.services.nextcloud.loadbalancer.server.port: 80
        traefik.http.routers.nextcloud.middlewares: nextcloud_header,nextcloud_redirectregex
        traefik.http.middlewares.nextcloud_redirectregex.redirectregex.permanent: true
        traefik.http.middlewares.nextcloud_redirectregex.redirectregex.regex: 'https://(.*)/.well-known/(?:card|cal)dav'
        traefik.http.middlewares.nextcloud_redirectregex.redirectregex.replacement: 'https://$${1}/remote.php/dav'
        traefik.http.middlewares.nextcloud_header.headers.referrerPolicy: no-referrer
        traefik.http.middlewares.nextcloud_header.headers.stsSeconds: 31536000
        traefik.http.middlewares.nextcloud_header.headers.forceSTSHeader: true
        traefik.http.middlewares.nextcloud_header.headers.stsPreload: true
        traefik.http.middlewares.nextcloud_header.headers.stsIncludeSubdomains: true
        traefik.http.middlewares.nextcloud_header.headers.browserXssFilter: true
        traefik.http.middlewares.nextcloud_header.headers.customRequestHeaders.X-Forwarded-Proto: https
  
    
networks:
  traefik_proxy:
    external: true
  default:
    driver: bridge
    enable_ipv6: true
    ipam:
     config:
       - subnet: "10.255.0.48/29"
         gateway: "10.255.0.49"
       - subnet: fd00::255:0:0:30/125
         gateway: fd00::255:0:0:31

After deactivating the backup app, the cron job is running normally again

@polygon242
Copy link

same here. running on a shared host.

@SinisterCrayon
Copy link

SinisterCrayon commented May 15, 2024

Problem is still there. +1

Appears that FullTextSearch 28 is incompatible with NextCloud 29. Store references the 28 download and though a 29 release exists the store app owners apparently haven't udpated it yet.

Temporary fix is to disable FullTextSearch.

@zenhighzer
Copy link

Since I enabled the "fulltext-stack" I got an error running the 5min-php-cron-job:

nextcloud (29.0.0) as container
installed apps:

[...]
 - files_fulltextsearch: 28.0.0
 - files_fulltextsearch_tesseract: 27.0.0
 - fulltextsearch: 28.0.1
 - fulltextsearch_elasticsearch: 29.0.0
[...]

Error while running 'docker exec -u www-data nextcloud php -f /var/www/html/cron.php':

Error: Class "OC\BackgroundJob\TimedJob" not found in /var/www/html/custom_apps/fulltextsearch/lib/Cron/Index.php:51
Stack trace:
#0 /var/www/html/lib/composer/composer/ClassLoader.php(576): include()
#1 /var/www/html/lib/composer/composer/ClassLoader.php(427): Composer\Autoload\{closure}('/var/www/html/c...')
#2 [internal function]: Composer\Autoload\ClassLoader->loadClass('OCA\\FullTextSea...')
#3 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(126): ReflectionClass->__construct('OCA\\FullTextSea...')
#4 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(146): OC\AppFramework\Utility\SimpleContainer->resolve('OCA\\FullTextSea...')
#5 /var/www/html/lib/private/AppFramework/DependencyInjection/DIContainer.php(470): OC\AppFramework\Utility\SimpleContainer->query('OCA\\FullTextSea...')
#6 /var/www/html/lib/private/ServerContainer.php(155): OC\AppFramework\DependencyInjection\DIContainer->queryNoFallback('OCA\\FullTextSea...')
#7 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(64): OC\ServerContainer->query('OCA\\FullTextSea...')
#8 /var/www/html/lib/public/Server.php(55): OC\AppFramework\Utility\SimpleContainer->get('OCA\\FullTextSea...')
#9 /var/www/html/lib/private/BackgroundJob/JobList.php(326): OCP\Server::get('OCA\\FullTextSea...')
#10 /var/www/html/lib/private/BackgroundJob/JobList.php(235): OC\BackgroundJob\JobList->buildJob(Array)
#11 /var/www/html/cron.php(163): OC\BackgroundJob\JobList->getNext(true)
#12 {main}

@zenhighzer
Copy link

Hi, I think there are some new app-realeases, but I still there are issues:

Please see screenshots (app update, app list and php-cron)

grafik

grafik

What can I do?

Thanks and Best Regards
Zen

@zenhighzer
Copy link

Hi again,

nevermind, cron seems to run correctly now. I dont know why its working now, because I didnt change anything since my last post...

BR
Zen

@seko5553
Copy link

I'm no programmer/developper so don't take this as tested. I merely copied together what others wrote in simmilar codes.
I changed Backup.php, Event.php and Manage.php in this manner:

namespace OCA\Backup\Cron;

use OCP\BackgroundJob\TimedJob; /*minor change here*/
use OCP\AppFramework\Utility\ITimeFactory; /*added this*/

use OCA\Backup\Exceptions\JobsTimeSlotException;
use OCA\Backup\Service\ConfigService;
use OCA\Backup\Service\CronService;
use OCA\Backup\Service\PointService;
use OCA\Backup\Tools\Traits\TNCLogger;
use Psr\Log\LoggerInterface;
use Throwable;

class Backup extends TimedJob {
		use TNCLogger;

		private $pointService;
		private $cronService;
		private $configService;
		private $loggerInterface;

		public function __construct(
				ITimeFactory $time, /*added this*/
				PointService $pointService,
				CronService $cronService,
				ConfigService $configService,
				LoggerInterface $loggerInterface
		) {
				parent::__construct($time); /*added this*/
				$this->setInterval(900);
				$this->pointService = $pointService;
				$this->cronService = $cronService;
				$this->configService = $configService;
				$this->loggerInterface = $loggerInterface;
		}

So far, this works for me.

@thomasmerz
Copy link

My NC instance tells me:

This app cannot be installed because the following dependencies are not fulfilled:
Server version 28 or lower is required.
Latest updated: vor 5 Monaten

Is there a version of backup in the NC app store that is "tested" and runs with NC 29?

@nooblag
Copy link

nooblag commented May 29, 2024

Reporting the same, but not on docker. A manual install.

Nextcloud 29.0.1.
Ubuntu 22.04.4 LTS, php 8.2, mariadb Ver 15.1 Distrib 10.6.16-MariaDB, nginx/1.18.0

$ sudo -u www-data php -f /var/www/nextcloud/cron.php
Error: Class "OC\BackgroundJob\TimedJob" not found in /var/www/nextcloud/apps/backup/lib/Cron/Backup.php:48
Stack trace:
#0 /var/www/nextcloud/lib/composer/composer/ClassLoader.php(576): include()
#1 /var/www/nextcloud/lib/composer/composer/ClassLoader.php(427): Composer\Autoload\{closure}()
#2 [internal function]: Composer\Autoload\ClassLoader->loadClass()
#3 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(126): ReflectionClass->__construct()
#4 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(146): OC\AppFramework\Utility\SimpleContainer->resolve()
#5 /var/www/nextcloud/lib/private/AppFramework/DependencyInjection/DIContainer.php(470): OC\AppFramework\Utility\SimpleContainer->query()
#6 /var/www/nextcloud/lib/private/ServerContainer.php(155): OC\AppFramework\DependencyInjection\DIContainer->queryNoFallback()
#7 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(64): OC\ServerContainer->query()
#8 /var/www/nextcloud/lib/public/Server.php(55): OC\AppFramework\Utility\SimpleContainer->get()
#9 /var/www/nextcloud/lib/private/BackgroundJob/JobList.php(326): OCP\Server::get()
#10 /var/www/nextcloud/lib/private/BackgroundJob/JobList.php(235): OC\BackgroundJob\JobList->buildJob()
#11 /var/www/nextcloud/cron.php(163): OC\BackgroundJob\JobList->getNext()
#12 {main}

@cernst72
Copy link

cernst72 commented May 31, 2024

Same here running on docker. I need to disable the Backup app to have cron.php running without error.

@HammyHavoc
Copy link

Same here running on docker. I need to disable the Backup app to have cron.php running without error.

I disabled and removed Backup, but I still get Unable to update background job mode when trying to switch modes, and it doesn't seem to run, period.

@scubamuc
Copy link

Cron not working after upgrade to 29.02.1
same issue in Nextcloud snap after upgrade to 29.02.1: nextcloud-snap/nextcloud-snap#2793

@Lassa333
Copy link

Lassa333 commented Aug 12, 2024

Hi,
i have the same problem: The cron-job, which worked perfectly, stopped after I installed the backup-app and prepared the first backup.

In my logs i found this entry:
"[cron] Fehler: Class "OC\BackgroundJob\TimedJob" not found"

After disabeling the backup-app, the cron-job returned to work normally.

I use Nextcloud Hub 8 (29.0.4) on Dietpi 9.6.1 (https://dietpi.com/)

@scubamuc
Copy link

Yeah, that app is known to have issues with the snap... prefer the snap backup Method. see wiki.

smarinier added a commit to smarinier/nextcloud_backup that referenced this issue Oct 9, 2024
---
- TimedJob is now OCP, and requires a time
- add modern properties assignment in constructors
---

Signed-off-by: Sebastien Marinier <seb@smarinier.net>
@smarinier smarinier linked a pull request Oct 9, 2024 that will close this issue
@smarinier
Copy link

Thanks to @seko5553 for the fix. I did (quite) like you've told.

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

Successfully merging a pull request may close this issue.