AG 23.11 rev 1365: datalist.php in PHP 8 throws Warning

Please report bugs and any annoyances here. Kindly include all possible details: steps to reproduce, expected result, actual result, screenshots, ... etc.
Post Reply
User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1156
Joined: 2019-05-21 22:42
Location: Germany
Contact:

AG 23.11 rev 1365: datalist.php in PHP 8 throws Warning

Post by onoehring » 2023-05-05 14:46

Hi,

earliert I posted a question about warnings in PHP 8.
PHP 8 seems to throw a warning, when one tries to use an uninitialized variable.
I notice, that the file \datalist.php which is generated by AppGini produces this error:

Here are some positions:

Code: Select all

function validate_filters($req, $FiltersPerGroup = 4, $is_gpc = true) {
...
			for($j = $i; $j < ($i + $FiltersPerGroup); $j++) {
				if($ffield[$j]) $empty_group = false;                     <--------------- this line
			}
...
here

Code: Select all

function Render() {
...
		if($dvShown && $tvShown) $this->ContentType = 'tableview+detailview';            <--------------- this line
...		
and here

Code: Select all

	private function isValidFilter($index) {
		return (
			($this->FilterAnd[$index] != '' || $index == 1)                      <--------------- this line
			&& $this->FilterField[$index] != ''                                         <--------------- this line
			&& $this->FilterOperator[$index] != ''                                   <--------------- probably this line too
			&& (
				strlen($this->FilterValue[$index])                                              <--------------- probably this line too
				|| strpos($this->FilterOperator[$index], 'empty') !== false          <--------------- probably this line too
			)
		);     
	}
The error should be avoidable when the existence of the variable is checked first and then like this (example only - for function IsValidFilter):

Code: Select all

		if (isset(FilterAnd[$index])) { 
		   // here the regular code
		}
I know, PHP throws a Warning only - but .... a page looks quite messy if we turn on debugging.

Olaf

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1156
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: AG 23.11 rev 1365: datalist.php in PHP 8 throws Warning

Post by onoehring » 2023-05-05 15:29

Hi,

just to add: same problem in \incCommon.php
function: getTablePermissions
end of function:

Code: Select all

return $table_permissions[$tn];
and \admin\incFunctions.php
function: getTableList
line (pretty much in the end):

Code: Select all

if($arrPerm['access']) $arrAccessTables[$tn] = $tc;
quick solution:

Code: Select all

if(isset($arrPerm['access'])) $arrAccessTables[$tn] = $tc;
Olaf

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1156
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: AG 23.11 rev 1365: datalist.php in PHP 8 throws Warning

Post by onoehring » 2023-05-05 15:56

Hi again,

also in incFunctions.php
function: get_tables_info
End of function:

Code: Select all

return $accessible_tables;
Quick solution:
Add this before return statement in the end of function

Code: Select all

		if (isset($accessible_tables)) {
			return $accessible_tables;
	} else {
		return;
	}
also in the same function

Code: Select all

if($arrPerm['access']) $accessible_tables[$tn] = $ti;
replace with

Code: Select all

if(isset($arrPerm['access'])) $accessible_tables[$tn] = $ti;

same quick solution for incCommon -> getTablePermissions.
Add this before return statement in the end of function

Code: Select all

		
if (isset($table_permissions[$tn])) {
		return $table_permissions[$tn];
} else {
	return;
}
also in \resources\lib\RememberMe around line 47:

Code: Select all

if(!self::_active_user($session['user'])) return false;
Olaf

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1156
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: AG 23.11 rev 1365: datalist.php in PHP 8 throws Warning

Post by onoehring » 2023-05-05 16:17

Hi,

also in datalist.php
function validate_filter

Code: Select all

for($j = $i; $j < ($i + $FiltersPerGroup); $j++) {
				if($ffield[$j]) $empty_group = false;
			}
quick solution:

Code: Select all

for($j = $i; $j < ($i + $FiltersPerGroup); $j++) {
				if(isset($ffield[$j])) $empty_group = false;
			}
I suppose there are many more places ... which should be checked soon, as PHP 8 is here today and the warnings ... well ... :-(

Olaf

Post Reply