Seite 1 von 1

PHP Warning: count(): Parameter must be ...

Verfasst: Mi 16. Dez 2020, 16:01
von Faar
Hab da was gefunden:
  • PHP Warning: count(): Parameter must be an array or an object that implements Countable in /html/contenido/includes/include.con_translate.php on line 600
  • PHP Warning: count(): Parameter must be an array or an object that implements Countable in /html/contenido/plugins/linkchecker/includes/include.linkchecker.php on line 438
  • PHP Warning: count(): Parameter must be an array or an object that implements Countable in /html/contenido/plugins/linkchecker/includes/include.linkchecker.php on line 441
  • PHP Warning: Invalid argument supplied for foreach() in /html/contenido/classes/versioning/class.contentversioning.php on line 830

Re: PHP Warning: count(): Parameter must be ...

Verfasst: Mi 16. Dez 2020, 16:30
von Faar
Ich habe das in include_translate.php ab Zeile 600 so gelöst, da ich erst PHP 7.2.x laufen habe und is_countable() erst ab PHP 7.3 gibt.

Code: Alles auswählen

	if (! function_exists('is_countable')) {
		/**
		  * @param mixed $value The value to check
		  * @return bool
		  */
		function is_countable($value): bool
		{
			return is_array($value) || (is_object($value) && $value instanceof Countable);
		}
	}
	if(is_countable($modulesInUse[$translationArray['idmod']])) {
		$countCurrentModuleInUse = count($modulesInUse[$translationArray['idmod']]);
	} else { $countCurrentModuleInUse = 0; }
Natürlich sollte die Funktion an zentrale Stelle, dass sie dort nur einmal eingebaut wird.

Beim Linkchecker wird es analog aufgebaut.
Beim Versioning ist es ein anderer Fehler, die Foreach-Schleife kann nicht durchlaufen werden, weil das Argument kein Array oder Objekt ist.
Daher bei Zeile 830 erstmal folgender Notbehelf:

Code: Alles auswählen

if (is_array($artLang) || is_object($artLang)) {
Kann sein, dass es in der Entwicklungsversion bereits behoben ist.
Weiß ich jetzt nicht.

Re: PHP Warning: count(): Parameter must be ...

Verfasst: Mi 16. Dez 2020, 21:20
von xmurrix
Hallo Frank,

danke dir für die Hinweise.

Das Problem mit include.con_translate.php in Zeile 600 ist in der Entwicklerbranch gefixt, der Rest nicht.

Ich habe ein Ticket dazu erstellt:
https://github.com/CONTENIDO/CONTENIDO/issues/164

Grüße
Murat