Subject: [Pkg-cacti-maint] Bug#889181: cacti changes for PHP7.2 and dep8 tests

From: Nishanth Aravamudan <[email-masked]>
Date: Fri, 2 Feb 2018 22:25:24 -0800

Package: cacti
Version: 1.1.31+ds1-1
Severity: normal
Tags: patch
User: [email-masked]
Usertags: origin-ubuntu bionic ubuntu-patch

Dear Maintainer,

In Ubuntu, the attached patch was applied to achieve the following:

  * debian/patches/php72_count_bc_changes.patch: PHP7.2 has deprecated
    count() of non-Countable objects.
  * debian/patches/update-cactisql.patch: Update cacti.sql for
    readstring to community change.

Note that even with this change, the DEP8 tests fail on Ubuntu 18.04,
with:

Unexpected output in /var/log/cacti/cacti.log:
02/02/2018 16:40:07 - AUTOM8 ERROR: The Network ID: 1 is disabled. You must use the 'force' option to force it's execution.

Which I think might be because we need to pass force to some URL or
check a network enabled box in the script?

Thanks for considering the patch.

*** /tmp/tmp6E1xYI/cacti_1.1.31+ds1-1ubuntu1.debdiff
diff -Nru cacti-1.1.31+ds1/debian/patches/php72_count_bc_changes.patch cacti-1.1.31+ds1/debian/patches/php72_count_bc_changes.patch
--- cacti-1.1.31+ds1/debian/patches/php72_count_bc_changes.patch	1969-12-31 16:00:00.000000000 -0800
+++ cacti-1.1.31+ds1/debian/patches/php72_count_bc_changes.patch	2018-02-02 08:21:41.000000000 -0800
@@ -0,0 +1,106 @@
+Description: PHP7.2 has deprecated count() of non-Countable objects
+Author: Nishanth Aravamudan <[email-masked]>
+Origin: upstream, https://github.com/Cacti/cacti/commit/202163bf7c8541f1b2827bdd62c584cc4d25124a.patch
+Bug: https://github.com/Cacti/cacti/issues/1040
+Last-Update: 2018-02-02
+
+--- cacti-1.1.31+ds1.orig/graphs_new.php
++++ cacti-1.1.31+ds1/graphs_new.php
+@@ -757,7 +757,7 @@ function graphs() {
+ 				$num_input_fields = 0;
+ 				$num_visible_fields = 0;
+ 
+-				if ($xml_array != false) {
++				if (sizeof($xml_array)) {
+ 					/* loop through once so we can find out how many input fields there are */
+ 					foreach ($xml_array['fields'] as $field_name => $field_array) {
+ 						if ($field_array['direction'] == 'input' || $field_array['direction'] == 'input-output') {
+--- cacti-1.1.31+ds1.orig/lib/api_automation.php
++++ cacti-1.1.31+ds1/lib/api_automation.php
+@@ -760,7 +760,7 @@ function display_new_graphs($rule, $url)
+ 	 * for a dropdown selection
+ 	 */
+ 	$xml_array = get_data_query_array($rule['snmp_query_id']);
+-	if ($xml_array != false) {
++	if (sizeof($xml_array)) {
+ 		/* loop through once so we can find out how many input fields there are */
+ 		foreach ($xml_array['fields'] as $field_name => $field_array) {
+ 			if ($field_array['direction'] == 'input' || $field_array['direction'] == 'input-output') {
+@@ -1898,7 +1898,7 @@ function global_item_edit($rule_id, $rul
+ 		$xml_array = get_data_query_array($automation_rule['snmp_query_id']);
+ 		$fields = array();
+ 
+-		if (sizeof($xml_array['fields'])) {
++		if (sizeof($xml_array) && sizeof($xml_array['fields'])) {
+ 			foreach($xml_array['fields'] as $key => $value) {
+ 				# ... work on all input fields
+ 				if (isset($value['direction']) && ($value['direction'] == 'input' || $value['direction'] == 'input-output')) {
+--- cacti-1.1.31+ds1.orig/lib/data_query.php
++++ cacti-1.1.31+ds1/lib/data_query.php
+@@ -27,7 +27,7 @@ function run_data_query($host_id, $snmp_
+ 
+ 	/* required for upgrading old versions of cacti */
+ 	if (!db_column_exists('host', 'poller_id')) {
+-		return;
++		return false;
+ 	}
+ 
+ 	/* don't run/rerun the query if the host is down, or disabled */
+@@ -205,7 +205,7 @@ function get_data_query_array($snmp_quer
+ 
+ 		if (!file_exists($xml_file_path)) {
+ 			query_debug_timer_offset('data_query', "Could not find data query XML file at '$xml_file_path'");
+-			return false;
++			return array();
+ 		}
+ 
+ 		query_debug_timer_offset('data_query', "Found data query XML file at '$xml_file_path'");
+@@ -1227,7 +1227,7 @@ function get_formatted_data_query_indexe
+ 	/* in case no unique index is available, fallback to first field in XML */
+ 	if ($sort_cache['sort_field'] == ''){
+ 		$snmp_queries = get_data_query_array($data_query_id);
+-		if (isset($snmp_queries['index_order'])){
++		if (sizeof($snmp_queries) && isset($snmp_queries['index_order'])){
+ 			$i = explode(':', $snmp_queries['index_order']);
+ 			if (sizeof($i) > 0){
+ 				$sort_cache['sort_field'] = array_shift($i);
+@@ -1385,7 +1385,7 @@ function update_data_query_sort_cache($h
+ 	}
+ 
+ 	/* substitute variables */
+-	if (isset($raw_xml['index_title_format'])) {
++	if (sizeof($raw_xml) && isset($raw_xml['index_title_format'])) {
+ 		$title_format = str_replace('|chosen_order_field|', "|query_$sort_field|", $raw_xml['index_title_format']);
+ 	} else {
+ 		$title_format = "|query_$sort_field|";
+--- cacti-1.1.31+ds1.orig/lib/functions.php
++++ cacti-1.1.31+ds1/lib/functions.php
+@@ -1691,7 +1691,7 @@ function get_graph_group($graph_template
+ 
+ 	/* a parent must NOT be the following graph item types */
+ 	if (preg_match('/(GPRINT|VRULE|HRULE|COMMENT)/', $graph_item_types[$graph_item['graph_type_id']])) {
+-		return;
++		return array();
+ 	}
+ 
+ 	$graph_item_children_array = array();
+--- cacti-1.1.31+ds1.orig/lib/utility.php
++++ cacti-1.1.31+ds1/lib/utility.php
+@@ -297,7 +297,7 @@ function update_poller_cache($data_sourc
+ 					$host_fields = $data_template_fields;
+ 				}
+ 
+-				if (sizeof($outputs)) {
++				if (sizeof($outputs) && sizeof($snmp_queries)) {
+ 					foreach ($outputs as $output) {
+ 						if (isset($snmp_queries['fields'][$output['snmp_field_name']]['oid'])) {
+ 							$oid = $snmp_queries['fields'][$output['snmp_field_name']]['oid'] . '.' . $data_source['snmp_index'];
+@@ -357,7 +357,7 @@ function update_poller_cache($data_sourc
+ 					$host_fields = $data_template_fields;
+ 				}
+ 
+-				if (sizeof($outputs)) {
++				if (sizeof($outputs) && sizeof($script_queries)) {
+ 					foreach ($outputs as $output) {
+ 						if (isset($script_queries['fields'][$output['snmp_field_name']]['query_name'])) {
+ 							$identifier = $script_queries['fields'][$output['snmp_field_name']]['query_name'];
diff -Nru cacti-1.1.31+ds1/debian/patches/series cacti-1.1.31+ds1/debian/patches/series
--- cacti-1.1.31+ds1/debian/patches/series	2018-01-05 11:28:12.000000000 -0800
+++ cacti-1.1.31+ds1/debian/patches/series	2018-02-02 08:20:22.000000000 -0800
@@ -2,3 +2,5 @@
 enable-system-jqueryui-by-putting-cacti-changes-in-main.css.patch
 updating-main.css-for-jquery-1.12.patch
 remove-global-mysql-command.patch
+update-cactisql.patch
+php72_count_bc_changes.patch
diff -Nru cacti-1.1.31+ds1/debian/patches/update-cactisql.patch cacti-1.1.31+ds1/debian/patches/update-cactisql.patch
--- cacti-1.1.31+ds1/debian/patches/update-cactisql.patch	1969-12-31 16:00:00.000000000 -0800
+++ cacti-1.1.31+ds1/debian/patches/update-cactisql.patch	2018-01-31 15:29:06.000000000 -0800
@@ -0,0 +1,17 @@
+Description: Update cacti.sql for readstring to community change
+Author: Nishanth Aravamudan <[email-masked]>
+Origin: upstream, https://github.com/Cacti/cacti/commit/5ba702f8d302413a581155ec8fe6636ff2674b19
+Forwarded: no
+Last-Update: 2018-01-31
+
+--- a/cacti.sql
++++ b/cacti.sql
+@@ -368,7 +368,7 @@
+   `snmp_id` int(10) unsigned NOT NULL DEFAULT '0',
+   `sequence` int(10) unsigned NOT NULL DEFAULT '0',
+   `snmp_version` varchar(100) NOT NULL DEFAULT '',
+-  `snmp_readstring` varchar(100) NOT NULL,
++  `snmp_community` varchar(100) NOT NULL,
+   `snmp_port` int(10) NOT NULL DEFAULT '161',
+   `snmp_timeout` int(10) unsigned NOT NULL DEFAULT '500',
+   `snmp_retries` tinyint(11) unsigned NOT NULL DEFAULT '3',

-- System Information:
Debian Release: buster/sid
  APT prefers bionic
  APT policy: (500, 'bionic')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.13.0-25-generic (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US:en (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

-- 
Nishanth Aravamudan
Ubuntu Server
Canonical Ltd

---

From: "Debian Bug Tracking System" <[email-masked]>
Date: Sun, 04 Feb 2018 12:42:07 +0000

Processing control commands:

> tags -1 confirmed upstream pending
Bug #889181 [cacti] cacti changes for PHP7.2 and dep8 tests
Added tag(s) pending, confirmed, and upstream.

-- 
889181: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=889181
Debian Bug Tracking System
Contact [email-masked] with problems

---

From: Paul Gevers <[email-masked]>
Date: Sun, 4 Feb 2018 13:38:46 +0100

Control: tags -1 confirmed upstream pending

Hi Nishanth,

Thanks for the report and the work with upstream to get this fixed.

>     readstring to community change.

I'll most likely just wait for the next upstream release, which I expect
to come soon (they release about every other week).

> check a network enabled box in the script?

If I understood upstream correctly about this issue, we should just add
the line to the accepted output.

Paul

---

From: Nish Aravamudan <[email-masked]>
Date: Sun, 4 Feb 2018 09:25:55 -0800

Hi Paul,

On Feb 4, 2018 04:38, "Paul Gevers" <[email-masked]> wrote:

Hi Nishanth,

Sure, I was not aware of cacti's release schedule and we are moving to 7.2
for 18.04, so just wanted you to be aware. I will sync the update once I
see it from Debian.

> 02/02/2018 16:40:07 - AUTOM8 ERROR: The Network ID: 1 is disabled. You
must use the 'force' option to force it's execution.

Yeah, that is what I will do in our delta, and then it should be part of
the sync if you make the same change.

-Nish

Paul

---

From: "Debian Bug Tracking System" <[email-masked]>
Date: Tue, 06 Feb 2018 21:54:04 +0000

Your message dated Tue, 06 Feb 2018 21:50:45 +0000
with message-id <[email-masked]>
and subject line Bug#889181: fixed in cacti 1.1.34+ds1-1
has caused the Debian Bug report #889181,
regarding cacti changes for PHP7.2 and dep8 tests
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email-masked]
immediately.)

Subject: cacti changes for PHP7.2 and dep8 tests
From: Nishanth Aravamudan <[email-masked]>
To: Debian Bug Tracking System <[email-masked]>
Date: Fri, 2 Feb 2018 22:25:24 -0800

Package: cacti
Version: 1.1.31+ds1-1
Severity: normal
Tags: patch

Dear Maintainer,

-- System Information:

-- 
Nishanth Aravamudan
Ubuntu Server
Canonical Ltd

Subject: Bug#889181: fixed in cacti 1.1.34+ds1-1
From: Paul Gevers <[email-masked]>
To: [email-masked]
Date: Tue, 06 Feb 2018 21:50:45 +0000

Source: cacti
Source-Version: 1.1.34+ds1-1

We believe that the bug you reported is fixed in the latest version of
cacti, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to [email-masked],
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Paul Gevers <[email-masked]> (supplier of updated cacti package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing [email-masked])

Format: 1.8
Date: Tue, 06 Feb 2018 22:31:34 +0100
Source: cacti
Binary: cacti
Architecture: source
Version: 1.1.34+ds1-1
Distribution: unstable
Urgency: medium
Maintainer: Cacti Maintainer <[email-masked]>
Changed-By: Paul Gevers <[email-masked]>
Description:
 cacti      - web interface for graphing of monitoring systems
Closes: 889181
Changes:
 cacti (1.1.34+ds1-1) unstable; urgency=medium
 .
   * New upstream version 1.1.34
     - Includes updates for php7.2 (Closes: #889181)
Checksums-Sha1:
 69a571f90eb6bd8e11890db947876b3acaa9fefe 2144 cacti_1.1.34+ds1-1.dsc
 a6b13c3611423cc2e706b60d5bb7cfdb026d00b1 66580 cacti_1.1.34+ds1.orig-docs-source.tar.xz
 df446350a1e7c53db2b94bc7c0d35fa2163ca66d 3824107 cacti_1.1.34+ds1.orig.tar.gz
 44eff5fedf4dd898942b1956b9566a79f44e7a03 51712 cacti_1.1.34+ds1-1.debian.tar.xz
Checksums-Sha256:
 faf9ed2bf37a916c527b3e1a80a4091f26ef48e72b3b86435407b76339e68d4c 2144 cacti_1.1.34+ds1-1.dsc
 4e93415bb3e4d4cb126a8ea027378827214bf93e80e73f8718906a94acc7a318 66580 cacti_1.1.34+ds1.orig-docs-source.tar.xz
 1ff8fc4273b6ff6f167bbb1214dd92a71ecfa3dea8a5085c08ca3bb4ddd3e1a0 3824107 cacti_1.1.34+ds1.orig.tar.gz
 56f7f11a4f2a54479b53dc39553a17b2e94ad44b1226890068b4daed4339cf62 51712 cacti_1.1.34+ds1-1.debian.tar.xz
Files:
 64d7b2736e67c98da799984bf3b4f820 2144 web optional cacti_1.1.34+ds1-1.dsc
 9f41c097f6beab7281874a473bbf3a86 66580 web optional cacti_1.1.34+ds1.orig-docs-source.tar.xz
 56d2d16363ad5f7771edafebc0a49a62 3824107 web optional cacti_1.1.34+ds1.orig.tar.gz
 4a92b0ec3ce56c015797d8db08e474b5 51712 web optional cacti_1.1.34+ds1-1.debian.tar.xz

---

From: Nish Aravamudan <[email-masked]>
Date: Tue, 13 Feb 2018 15:26:40 -0800

While this update did fix the bug in question, it still doesn't pass
DEP8, whereas my backport did :/ Any ideas?

On Tue, Feb 6, 2018 at 1:54 PM, Debian Bug Tracking System
<[email-masked]> wrote:
> This is an automatic notification regarding your Bug report
> which was filed against the cacti package:
>
> #889181: cacti changes for PHP7.2 and dep8 tests
>
> It has been closed by Paul Gevers <[email-masked]>.
>
> Their explanation is attached below along with your original report.
> If this explanation is unsatisfactory and you have not received a
> better one in a separate message then please contact Paul Gevers <[email-masked]> by
> replying to this email.
>
>
> --
> ---------- Forwarded message ----------
> Cc:
> Bcc:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> Format: 1.8
> -----BEGIN PGP SIGNATURE-----
>
> iQEzBAEBCAAdFiEEWLZtSHNr6TsFLeZynFyZ6wW9dQoFAlp6Hz0ACgkQnFyZ6wW9
> dQrp4gf7BNa9muSi3z2zOmzHiwXFnN4lMUybML5PZe6R7kJhVcOwcQOuIJEs06Zf
> wKI9MyB0Lo+n3HvrrRqyIv7woZPHsAkDC1xHmgjfFuqYqWFXAbuxR2NNFG7HLMLz
> T/Xq5mpiG+oVBiHYDBIbbeQPyK0QOr9zZ/bzK8xxQXMlVg7P/FLhCVRExyTLRjBr
> TipNCpDpheD8I87euvdE+ExJ6AtJey1vEtWtm2ka6dav/nm3lxJBGzumOcxn+151
> ZS/7HTOdb5AViU4Bi4IZsCOc0ivFJg7me4VVEinmPkOyt+BylGRm2IjGnXY7ZejN
> 9EsR/qhEVCA4vDIflWFCS1CxpmXd6g==
> =rn75
> -----END PGP SIGNATURE-----
>
> ---------- Forwarded message ----------
> Cc:
> Bcc:

---

From: Nish Aravamudan <[email-masked]>
Date: Tue, 13 Feb 2018 15:47:02 -0800

> DEP8, whereas my backport did :/ Any ideas?

My fault, I see 1.1.35+ds1-1 was uploaded with the fix. I'll sync that
down. Sorry for the noise!

-Nish