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

Nextcloud Log: ArgumentCountError: Too few arguments #643

Closed
onkeljuergen opened this issue Mar 5, 2020 · 18 comments
Closed

Nextcloud Log: ArgumentCountError: Too few arguments #643

onkeljuergen opened this issue Mar 5, 2020 · 18 comments

Comments

@onkeljuergen
Copy link

onkeljuergen commented Mar 5, 2020

IMPORTANT

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

Explain the Problem

I see the following in the Nextcloud Log: ArgumentCountError: Too few arguments to function

Steps to Reproduce

Explain what you did to encounter the issue

  1. Just in the Nextcloud log after fresh reset of app

System Information

  • News app version: 14.1.3
  • Nextcloud version: 18.0.1.3
  • Cron type: linux cron job
  • PHP version: 7.4
  • Database and version: MariaDB 10.3
  • Browser and version: Firefox 73.0.1
  • Distribution and version: Ubuntu 19.10

Contents of nextcloud/data/nextcloud.log

{ "Exception": "ArgumentCountError",
  "Message": "Too few arguments to function OCA\\News\\Cron\\Updater::run(), 0 passed and exactly 1 expected",
  "Code": 0, 
  "Trace":
  	[
		{ "function": "run",
		  "class": "OCA\\News\\Cron\\Updater",
		  "type": "::",
		  "args":[]
		},
		{ "file": "/srv/nextcloud/lib/private/BackgroundJob/Legacy/RegularJob.php",
		  "line": 32,
		  "function": "call_user_func",
		  "args": [
		  	[ "OCA\\News\\Cron\\Updater","run"]
			]
		 },
		 { "file": "/srv/nextcloud/lib/private/BackgroundJob/Job.php",
		   "line": 61,
		   "function": "run",
		   "class": "OC\\BackgroundJob\\Legacy\\RegularJob",
		   "type": "->",
		   "args": [
		   	 [ "OCA\\News\\Cron\\Updater","run"]
			 ]
		  },
		  { "file": "/srv/nextcloud/cron.php",
		    "line": 125,
			"function": "execute",
			"class": "OC\\BackgroundJob\\Job",
			"type": "->",
			"args": [
				{ "__class__": "OC\\BackgroundJob\\JobList" },
				{ "__class__": "OC\\Log" }
			  ]
		   }
	],
  "File": "/srv/nextcloud/apps/news/lib/Cron/Updater.php",
  "Line": 46,
  "CustomMessage": "Error while running background job (class: OC\\BackgroundJob\\Legacy\\RegularJob, arguments: Array\n(\n    [0] => OCA\\News\\Cron\\Updater\n    [1] => run\n)\n)"
  },
  "userAgent":"--",
  "version":"18.0.1.3"}

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@onkeljuergen
Copy link
Author

Could anyone please post what the following statement outputs for a working News instance?

select * from oc_jobs where class like '%News%';

@stale
Copy link

stale bot commented Mar 31, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the stale label Mar 31, 2020
@pstast
Copy link

pstast commented Apr 7, 2020

@onkeljuergen I have the same problem after upgrading NextCloud and News to the newest stable version today. News stopped downloading.

MariaDB [owncloud]> select * from oc_jobs where class like '%News%';
+-------+-----------------------+----------+------------+--------------+-------------+--------------------+
| id    | class                 | argument | last_run   | last_checked | reserved_at | execution_duration |
+-------+-----------------------+----------+------------+--------------+-------------+--------------------+
| 30017 | OCA\News\Cron\Updater | null     | 1586189702 |   1586233801 |           0 |                 38 |
+-------+-----------------------+----------+------------+--------------+-------------+--------------------+

@stale stale bot removed the stale label Apr 7, 2020
@onkeljuergen
Copy link
Author

Hi,
yes it looks the same for me. So I could not find out what the actual problem was.
News works reasonably ok at the moment. But still I hope this will get fixed soon :-(

@sokai
Copy link

sokai commented Apr 10, 2020

FYI: This is my complete log message(s) from the current cron job (linux cron job every 5 mins; Debian Stretch; PHP 7.4.4).

{
  "reqId": "4CRzolL7zAp39dWvkuvG",
  "level": 3,
  "time": "2020-04-10T12:45:01+02:00",
  "remoteAddr": "",
  "user": "--",
  "app": "PHP",
  "method": "",
  "url": "--",
  "message": "call_user_func() expects parameter 1 to be a valid callback, non-static method OCA\\News\\Cron\\Updater::run() should not be called statically at /lib/private/BackgroundJob/Legacy/RegularJob.php#32",
  "userAgent": "--",
  "version": "18.0.3.0"
}
{
  "reqId": "4CRzolL7zAp39dWvkuvG",
  "level": 3,
  "time": "2020-04-10T12:45:01+02:00",
  "remoteAddr": "",
  "user": "--",
  "app": "core",
  "method": "",
  "url": "--",
  "message": {
    "Exception": "ArgumentCountError",
    "Message": "Too few arguments to function OCA\\News\\Cron\\Updater::run(), 0 passed and exactly 1 expected",
    "Code": 0,
    "Trace": [
      {
        "function": "run",
        "class": "OCA\\News\\Cron\\Updater",
        "type": "::"
      },
      {
        "file": "/lib/private/BackgroundJob/Legacy/RegularJob.php",
        "line": 32,
        "function": "call_user_func"
      },
      {
        "file": "/lib/private/BackgroundJob/Job.php",
        "line": 61,
        "function": "run",
        "class": "OC\\BackgroundJob\\Legacy\\RegularJob",
        "type": "->"
      },
      {
        "file": "/cron.php",
        "line": 125,
        "function": "execute",
        "class": "OC\\BackgroundJob\\Job",
        "type": "->"
      }
    ],
    "File": "/apps/news/lib/Cron/Updater.php",
    "Line": 46,
    "CustomMessage": "Error while running background job (class: OC\\BackgroundJob\\Legacy\\RegularJob, arguments: Array\n(\n    [0] => OCA\\News\\Cron\\Updater\n    [1] => run\n)\n)"
  },
  "userAgent": "--",
  "version": "18.0.3.0"
}

#thx4fixing

@stale
Copy link

stale bot commented May 1, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the stale label May 1, 2020
@stale stale bot closed this as completed May 9, 2020
@Grotax Grotax reopened this May 11, 2020
@stale stale bot removed the stale label May 11, 2020
@Grotax
Copy link
Member

Grotax commented May 11, 2020

I checked the log of my instance today and saw the same error, it doesn't seem to have any effect on news.

@Grotax
Copy link
Member

Grotax commented May 11, 2020

So I checked https://docs.nextcloud.com/server/18/developer_manual/app/backgroundjobs.html
and compared it to
lib/Cron/Updater.php
seems to me that there is no change but maybe my PHP is not good enough

Then in the info.xml is a job definition without an argument which will then pass an empty array according to the docs

@Grotax
Copy link
Member

Grotax commented Aug 30, 2020

This should be fixed in 14.2.0+

@Grotax
Copy link
Member

Grotax commented Sep 1, 2020

Error still occurs, in 14.2.0 I think after we are now using exactly what I could find in the documentation, it could be an issue in the server itself or we are doing something wrong.

@SMillerDev
Copy link
Contributor

I think the issue is with dependency injection failing sometimes. That would also explain some of the issues I've been having with the service migration.

@jknockaert
Copy link
Contributor

Am seeing this error after upgrading php to 7.4.

@adi2k5
Copy link

adi2k5 commented Sep 25, 2020

Same for me, just updated php to 7.4 and got hit by that same issue, news is currently unusable for me as it's not updating any feeds from cron. It works though if I'll run '/usr/bin/php -f /var/www/nextcloud/cron.php' manually on server, then feeds are being updated. With php 7.3 there were no issues with that.
I'm not sure if this can have anything to do with that problem (not a php programmer), but I've found this, maybe it'll help somehow here:
https://www.php.net/manual/en/migration74.deprecated.php

Unbinding $this when $this is used
Unbinding $this of a non-static closure that uses $this is deprecated.

@rabauke
Copy link

rabauke commented Oct 13, 2020

Same issue here with Nextcloud 19.0.4, news 14.2.2 and php 7.4.

Bildschirmfoto

@chriswells0
Copy link

chriswells0 commented Nov 1, 2020

In lib/private/BackgroundJob/Legacy/RegularJob.php, I have added the missing null argument:

// This "if" was added:
if (count($argument) == 2) {
    array_push($argument, null);
}
// This is the existing code:
if (is_callable($argument)) {
    call_user_func($argument);
}

That appears to resolve the issue. I can submit a PR to the NC server project, but I'd like confirmation from someone familiar with the server and/or News app that it is the correct resolution. I also noticed in the README that argument is sometimes (?) not null in the DB, which makes me wonder if I should simply update my DB record.

@SMillerDev
Copy link
Contributor

You can make a PR to the server, but I'm not sure if they'll accept changes to legacy components. In the meantime news switched away from the legacy job for the version that supports NC 20, so this issue should resolve itself eventually.

@chriswells0
Copy link

Fair enough. I won't bother to submit it then. Anyone who stumbles across this issue can make the change manually if they're not ready/able to upgrade to NC 20.

@SMillerDev
Copy link
Contributor

There's now an update of the app and @chriswells0 has a fix for people who can't update, closing

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

No branches or pull requests

9 participants