Skip to content

Conversation

@JonBendtsen
Copy link
Contributor

@JonBendtsen JonBendtsen commented Nov 23, 2025

Qual Undefined variables in /var/www/html/core/customreports.php on various lines

This PR is a fix of an error message discovered during my exploring of a fix of BI - Custom Reports "Warning: Undefined property: CLeadStatus::$fields in bug nr. 35096

@JonBendtsen
Copy link
Contributor Author

  1. commit fixes
PHP Warning:  Attempt to read property "table_element" on null in /var/www/html/core/customreports.php on line 204
PHP Warning:  Attempt to read property "element" on null in /var/www/html/core/customreports.php on line 312
PHP Warning:  Attempt to read property "element" on null in /var/www/html/core/customreports.php on line 1136
PHP Warning:  Attempt to read property "element" on null in /var/www/html/core/customreports.php on line 1137

if (!empty($object->table_element)) {
$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
} else {
$search_array_options = array();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idea copied from

htdocs/core/lib/company.lib.php:		$search_array_options = array();

$features = $object->element;
} else {
$features = '';
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unsure if the variable should be empty

if (isset($filenamekey) && isset($fileurlkey)) {
$px1->draw($filenamekey, $fileurlkey);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unsure if it is better to assign these $filenamekey and $fileurlkey to an empty string and then draw that

@hregis
Copy link
Contributor

hregis commented Nov 23, 2025

@JonBendtsen object "element" and " table_element" can not be empty ! if empty... buuuugs in class of element !

@JonBendtsen
Copy link
Contributor Author

@JonBendtsen object "element" and " table_element" can not be empty ! if empty... buuuugs in class of element !

Okay, then I don't know how to fix it.

I get those 4 PHP warning lines when switching to Predefined Invoices on this page /core/customreports.php

@hregis
Copy link
Contributor

hregis commented Nov 23, 2025

@JonBendtsen and with this fixx: #36393 ?

@JonBendtsen
Copy link
Contributor Author

eldy's fix here 112028a works fine so I will close this PR

@JonBendtsen JonBendtsen reopened this Nov 24, 2025
@JonBendtsen
Copy link
Contributor Author

damn, tested in the wrong branch

@JonBendtsen
Copy link
Contributor Author

first commit fixes error message like this

192.168.127.1 - - [24/Nov/2025:18:58:14 +0100] "POST /core/ajax/check_notifications.php HTTP/1.1" 200 419 "http://localhost:20080/core/customreports.php?objecttype=proposal" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36"
[Mon Nov 24 18:58:16.685442 2025] [php:warn] [pid 49:tid 49] [client 192.168.127.1:58771] PHP Warning:  Undefined variable $errormessage in /var/www/html/core/customreports.php on line 951, referer: http://localhost:20080/core/customreports.php?objecttype=proposal
192.168.127.1 - - [24/Nov/2025:18:58:16 +0100] "GET /core/customreports.php?objecttype=order HTTP/1.1" 200 23592 "http://localhost:20080/core/customreports.php?objecttype=proposal" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36"
192.168.127.1 - - [24/Nov/2025:18:58:19 +0100] "POST /core/ajax/check_notifications.php HTTP/1.1" 200 419 "http://localhost:20080/core/customreports.php?objecttype=order" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36"
[Mon Nov 24 18:58:20.107309 2025] [php:warn] [pid 49:tid 49] [client 192.168.127.1:58771] PHP Warning:  Undefined variable $errormessage in /var/www/html/core/customreports.php on line 951, referer: http://localhost:20080/core/customreports.php?objecttype=order

@JonBendtsen
Copy link
Contributor Author

if I only use @eldy's fix in 112028a I still get the errors I post in this PR, but with the changes here and @eldy's changes in 112028a both in v20 with commit

commit b9e6243ec8eef181f2d52884817c476514231460 (HEAD -> 20.0, origin/20.0)
Merge: 0e8d4461c4f 9394f24cf7f
Author: Laurent Destailleur <[email protected]>
Date:   Mon Nov 24 16:16:00 2025 +0100

    Merge branch '19.0' of [email protected]:Dolibarr/dolibarr.git into 20.0

I do not get any errors.

@eldy do you want your fix in v22 backported into v20 in this PR?, if not you can just go ahead and merge this

@JonBendtsen JonBendtsen force-pushed the BICustomReportsWarningUndefinedpropertyCLeadStatusfields35096 branch from 6bf7195 to ef70a7a Compare November 24, 2025 18:03
@hregis
Copy link
Contributor

hregis commented Nov 24, 2025

@JonBendtsen #36393

@eldy eldy closed this Nov 24, 2025
@eldy eldy reopened this Nov 24, 2025
@eldy
Copy link
Member

eldy commented Nov 24, 2025

customreports feature seams still in development in v20.
note that warning on $errormesssage was fixed with commit 71dc6dc

@JonBendtsen
Copy link
Contributor Author

@JonBendtsen #36393

that one is closed @hregis ?

@JonBendtsen
Copy link
Contributor Author

customreports feature seams still in development in v20. note that warning on $errormesssage was fixed with commit 71dc6dc

even with fresh pulled v20, and your changes backported from 112028a

I still get these errors when selecting Predefined Invoices in the dropdown.

[Mon Nov 24 19:43:13.921859 2025] [php:warn] [pid 45:tid 45] [client 192.168.127.1:32510] PHP Warning:  Attempt to read property "table_element" on null in /var/www/html/core/customreports.php on line 205, referer: http://localhost:20080/core/customreports.php?objecttype=cotisation
[Mon Nov 24 19:43:13.921989 2025] [php:warn] [pid 45:tid 45] [client 192.168.127.1:32510] PHP Warning:  Attempt to read property "element" on null in /var/www/html/core/customreports.php on line 313, referer: http://localhost:20080/core/customreports.php?objecttype=cotisation
[Mon Nov 24 19:43:13.966225 2025] [php:warn] [pid 45:tid 45] [client 192.168.127.1:32510] PHP Warning:  Attempt to read property "element" on null in /var/www/html/core/customreports.php on line 1137, referer: http://localhost:20080/core/customreports.php?objecttype=cotisation
[Mon Nov 24 19:43:13.966248 2025] [php:warn] [pid 45:tid 45] [client 192.168.127.1:32510] PHP Warning:  Attempt to read property "element" on null in /var/www/html/core/customreports.php on line 1138, referer: http://localhost:20080/core/customreports.php?objecttype=cotisation

@JonBendtsen JonBendtsen force-pushed the BICustomReportsWarningUndefinedpropertyCLeadStatusfields35096 branch from ef70a7a to 6e111fe Compare November 24, 2025 18:46
@JonBendtsen
Copy link
Contributor Author

@eldy after testing with the changes here in this PR I get no errors in Predefined Invoices

@JonBendtsen
Copy link
Contributor Author

@eldy if you want I can easily add you changes backported to v20

JonSweet16:20.0 jonbendtsen$ git add -p
diff --git a/htdocs/core/class/cleadstatus.class.php b/htdocs/core/class/cleadstatus.class.php
index f72f9dddc7d..7f6c0b9d0da 100644
--- a/htdocs/core/class/cleadstatus.class.php
+++ b/htdocs/core/class/cleadstatus.class.php
@@ -57,6 +57,10 @@ class CLeadStatus extends CommonDict
 	 */
 	public $percent;
 
+	public $fields = array(
+		'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'position' => 1, 'notnull' => 1, 'visible' => 0, 'noteditable' => 1, 'index' => 1, 'css' => 'left', 'comment' => "Id"),
+		'label' => array('type' => 'varchar(128)', 'label' => 'Label', 'enabled' => 1, 'position' => 20, 'notnull' => 1, 'visible' => 1, 'index' => 1, 'searchall' => 1, 'showoncombobox' => 1, 'comment' => "Label of status"),
+	);
 
 	/**
 	 *  Constructor
(1/1) Stage this hunk [y,n,q,a,d,e,p,?]? n

@eldy
Copy link
Member

eldy commented Nov 24, 2025

@eldy if you want I can easily add you changes backported to v20

JonSweet16:20.0 jonbendtsen$ git add -p
diff --git a/htdocs/core/class/cleadstatus.class.php b/htdocs/core/class/cleadstatus.class.php
index f72f9dddc7d..7f6c0b9d0da 100644
--- a/htdocs/core/class/cleadstatus.class.php
+++ b/htdocs/core/class/cleadstatus.class.php
@@ -57,6 +57,10 @@ class CLeadStatus extends CommonDict
 	 */
 	public $percent;
 
+	public $fields = array(
+		'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'position' => 1, 'notnull' => 1, 'visible' => 0, 'noteditable' => 1, 'index' => 1, 'css' => 'left', 'comment' => "Id"),
+		'label' => array('type' => 'varchar(128)', 'label' => 'Label', 'enabled' => 1, 'position' => 20, 'notnull' => 1, 'visible' => 1, 'index' => 1, 'searchall' => 1, 'showoncombobox' => 1, 'comment' => "Label of status"),
+	);
 
 	/**
 	 *  Constructor
(1/1) Stage this hunk [y,n,q,a,d,e,p,?]? n

You can. Not required as it is is not supported feature in v20. But you can.

@JonBendtsen JonBendtsen marked this pull request as ready for review November 24, 2025 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants