Hi Steve and everyone,
When using php 8.1.or 8.2 or 8.3 I am getting a fatal php error when trying to add a related record
PHP Fatal error: Uncaught TypeError: count(): Argument #1 ($value)
must be of type Countable|array, string given
Using latest xataface 3.0.2 5002.
It seems to be the case for any related table.
Not sure if this is a bug or something on my end - i recently upgraded my ubuntu server from 20 to 22 to 24, then back to 22 as I kept getting php errors. I thought I already had php 8.1 to begin with, but now I am not sure anymore.
I haven't found this particular error in any of the posts here and once i noticed it was not table specific, i gave up on trying to hunt down what in my site config may cause it and went back to php7.4 - problem gone.
Example relationship for table Computers:
[Conditions]
__sql__ = "SELECT * FROM Conditions WHERE ComputerID='$ComputerID'"
section:limit=100
action:label = "condition"
If I add a record directly to the related tables, itself, it works fine.
Any ideas appreciated!
Ruben
Full error:
PHP Fatal error: Uncaught TypeError: count(): Argument #1 ($value)
must be of type Countable|array, string given in
/var/www/xataface/Dataface/FormTool/select.php:148\nStack trace:\n#0
/var/www/xataface/Dataface/FormTool.php(405):
Dataface_FormTool_select->pushValue()\n#1
/var/www/xataface/Dataface/QuickForm.php(936):
Dataface_FormTool->pushValue()\n#2
/var/www/xataface/Dataface/ShortRelatedRecordForm.php(582):
Dataface_QuickForm->pushValue()\n#3
/var/www/xataface/lib/HTML/QuickForm.php(1635):
Dataface_ShortRelatedRecordForm->save()\n#4
/var/www/xataface/actions/new_related_record.php(93):
HTML_QuickForm->process()\n#5
/var/www/xataface/Dataface/Application.php(3715):
dataface_actions_new_related_record->handle()\n#6
/var/www/xataface/Dataface/Application.php(3857):
Dataface_Application->handleRequest()\n#7
/var/www/xataface/Dataface/Application.php(3743):
Dataface_Application->_display()\n#8
/var/www/masterlist/index.php(19):
Dataface_Application->display()\n#9 {main}\n thrown in
/var/www/xataface/Dataface/FormTool/select.php on line 148
select.php:
137 function pushValue(&$record, &$field, &$form, &$element, &$metaValues){
138 // quickform stores select fields as arrays, and the table schema will only accept
139 // array values if the 'repeat' flag is set.
140 $table =& $record->_table;
141 $formTool =& Dataface_FormTool::getInstance();
142 //$formFieldName =& $element->getName();
143
144 if ( !$field['repeat'] ){
145
146 $val = $element->getValue();
147
148 if ( @count($val)>0 ){
149 return $val[0];
150
151 } else {
152 return null;
153
154 }
155 } else {
156 return $element->getValue();
157 }
158
159
160
161 }
162
163
164 }