1 2 Previous Next 22 Replies Latest reply on Nov 20, 2014 9:48 AM by TSGal

    PHP Edit command fails if "Not Empty" validation set

    DanielKaan

      Summary

      PHP Edit command fails if "Not Empty" validation set

      Product

      FileMaker Server

      Version

      14.0.1.224

      Operating system version

      Mac OS X 10.8.5

      Description of the issue

      When using either of the 2 methods of editing an existing record in PHP, if there is any field on the layout referenced by the edit that has the validation "Not Empty" set, the edit fails without reporting any error message.

      This is regardless whether the field in the field in question has data or not, whether it is that field that is being edited or not, or whether the "Always" or "Allow user to override during data entry" Validation flags are set.

      Also, whether or not the field is being edited is irrelevant. That is the edit command may be modifying a totally different field and the edit still fails.

      Steps to reproduce the problem

      Set one or more fields on the layout referenced in a PHP edit command to have the validation "Not Empty" and then attempt to edit any record in that table using PHP.

      Expected result

      The record is appropriately edited by PHP regardless of the "Not Empty" Validation settings of fields on the PHP Edit layout (unless the validation genuinely fails).

      Actual result

      Interestingly "FileMaker::IsError($result)" does capture that an error occurred, but the "$result->getMessage()" is uninformatively blank.

      Exact text of any error message(s) that appear

      none

      Configuration information

      The problem is at the server end.  All client device types and browsers reported the same issue.

      Workaround

      Turn off "Not empty" validation on all fields on the PHP edit layout OR remove fields with the "Not Empty" validation flag set from the layout.  Of course this means it is not possible edit such fields.

      Screen_Shot_2014-01-08_at_1.12.37_PM.jpg

        • 1. Re: PHP Edit command fails if "Not Empty" validation set
          TSGal

               Daniel Kaan:

               Thank you for your post.

               If you pre-validate the field, does it return an error?  For more information , see pages 40-43 of the Custom Web Publishing with PHP Guide:

          https://fmhelp.filemaker.com/docs/13/en/fms13_cwp_php.pdf

               Regardless, I have forwarded your post to our Development and Testing departments for review.  When I receive any feedback, I will let you know.

               TSGal
               FileMaker, Inc.

          • 2. Re: PHP Edit command fails if "Not Empty" validation set
            DanielKaan

                 Thanks for your response TS.

                 Pre-validation does NOT catch the error.

                 In order to replicate the error (and the validation passing) I have included the script below which operates on the FMServer_Sample file.

                 To  prove the script works, place it on the server and call it from the browser. You should get a result like:

                 internal record id: 345

                Validation passed

                           The field was successfully modified

                 Open the sample file in FileMaker and go to the layout "PHP Technology Test". The first record should have "PHP Test Data" in the "Task Name Sample" field.

                 To reproduce the error:

                 1. clear this field (and click out of the record). 

                 2. In FileMaker turn on the "Not Empty" validation for the field "LANGUAGE MATCH FIELD" in the "Translator" table. Note: this is not the field that is being modified by the script, but it does appear on that layout. Note also that every record in the table passes that validation; they all have data.

                 3. Run the script again from the browser.  The record is not modified and the script returns the following to the browser.

                     internal record id: 345

                Validation passed

                     Error Method 1:

                     Error Method 2:

                 Hope this makes it clear.

                 Kind regards

                 Daniel

                 ------ script -----

                 <?php
                  
                 session_start();
                 require_once ('FileMaker.php');
                 $fm = new FileMaker();
                 $fm->setProperty('database', 'FMServer_Sample');
                 $fm->setProperty('hostspec', 'http://localhost');
                 $fm->setProperty('username', 'Admin');
                 $fm->setProperty('password', '');
                  
                 $layout = 'PHP Technology Test';
                 $modifyfieldname = 'Task Name Sample';
                 $modifyfieldvalue = 'PHP Test Data';
                  
                  
                     //on for debugging only.  Turn off before going live.
                     ini_set("display_errors","On");
                  
                     #Find record.
                 $findCommand = $fm->newFindAllCommand($layout);
                 $result = $findCommand->execute();
                  
                     //Check for an error
                     if (FileMaker::isError($result)) {
                         echo '<p>Error: NewFindAllCommand did not work.</p>';
                         echo '<p>Error: ' . $result->getMessage() . '</p>';
                         die;
                     }
                  
                     //Store the matching records
                     $records = $result->getRecords(); 
                  
                     //grab the first record
                     $record = $records[0];
                  
                 //grab FileMaker's internal id for that record
                     $interal_rec_id = $record->getRecordId() ;
                     echo '<p>internal record id: ' . $interal_rec_id . '</p>';
                  
                    
                     // edit this first record: Method 1
                     $rec = $fm->getRecordByID($layout,$interal_rec_id);
                     $rec->setField($modifyfieldname, $modifyfieldvalue);
                  
                 //Pre-validate
                 $result = $rec->validate();
                  
                 //If the validate() method returned any errors, print the name of the field, the error number, and the value that failed.
                 if(FileMaker::isError($result)){
                 echo 'Validation failed:'. "\n"; $validationErrors= $result->getErrors();
                 foreach ($validationErrors as $error) {
                         $field =  $error[0];
                         echo 'Field Name: ' .  $field->getName(). "\n";
                         echo 'Error Code: ' .  $error[1] . "\n";
                         echo 'Value: ' .  $error[2] . "\n";
                         }
                         die;
                     } else {
                     echo 'Validation passed';
                     }
                     
                     //Perform the edit using Method 1
                     $result = $rec->commit();
                     
                     if (FileMaker::isError($result)) {
                         echo '<p>Error Method 1: ' . $result->getMessage() . '</p>';
                  
                 // Method 1 failed: try edit Method 2
                 $recorddata[$modifyfieldname] = $modifyfieldvalue ;
                     $newEdit =& $fm->newEditCommand($layout, $interal_rec_id , $recorddata);
                     $result = $newEdit->execute();
                  
                     if (FileMaker::isError($result)) {
                         echo '<p>Error Method 2: ' . $result->getMessage() . '</p>';
                     }
                    
                     die;
                     }
                  
                 // If it gets here, all has gone well. Report success to the user.
                 echo '<p>The field was successfully modified</p>';
                  
                 ?>
            • 3. Re: PHP Edit command fails if "Not Empty" validation set
              TSGal

                   Daniel Kaan:

                   I have attached your additional comments to the original report.  When I receive any feedback, I will let you know.

                   TSGal
                   FileMaker, Inc.

              • 4. Re: PHP Edit command fails if "Not Empty" validation set
                TSGal

                     Daniel Kaan:

                     Our Testing department was unable to replicate the issue.  Using the FMServer_Sample.fmp12 with layout "PHP Technology Test" and "Not Empty" validation for the field "LANGUAGE MATCH FIELD" in the "Translator" table, here is the PHP script that the Tester would like you to try:

                     <?php
                     session_start();
                      require_once 'FileMaker.php';
                     $fm = new FileMaker();
                     $fm->setProperty('database', 'FMServer_Sample');
                     $fm->setProperty('hostspec', 'http://localhost');
                     $fm->setProperty('username', 'Admin');
                     $fm->setProperty('password', '');
                     $layout = 'PHP Technology Test';
                     $modifyfieldname = 'Task Name Sample';
                     $modifyfieldvalue = 'PHP Test Data1';
                      
                     $findCommand = $fm->newFindAllCommand($layout);
                     $result = $findCommand->execute();
                      
                     if (FileMaker::isError($result)) {
                         echo "Error: {$result->getMessage()}\n";
                         exit;
                     }
                     $records = $result->getRecords();
                     $record = $records[0];
                      
                     $interal_rec_id = $record->getRecordId() ;
                     echo 'Internal Record ID is:' .$interal_rec_id .'<br>';
                     $rec = $fm->getRecordByID($layout,$interal_rec_id);
                      
                     $rec->setField($modifyfieldname, $modifyfieldvalue);  
                     //$result = $rec->commit();  //commit before validate
                     $result = $rec->validate();  
                         if (FileMaker::isError($result)) {
                              echo 'Validation failed:'. "\n"; 
                              $validationErrors= $result->getErrors();
                               foreach ($validationErrors as $error) {
                                $field = $error[0];
                                echo 'Field Name: ' . $field->getName(). '<br>';
                                echo 'Error Code: ' . $error[1] . '<br>';
                                echo 'Value: ' . $error[2] . '<br>';
                                }//End of foreach
                                die;
                              } else{
                     echo "Validation Pass";}
                     $result = $rec->commit(); 
                      
                     ?>

                     -----

                     Please test this out and see if this works for you.

                     TSGal
                     FileMaker, Inc.

                • 5. Re: PHP Edit command fails if "Not Empty" validation set
                  DanielKaan

                       I tried your script as is, firstly without the "Not empty" flag set.  The script worked correctly and the data was updated. The browser returned:

                     Internal Record ID is:345
                     Validation Pass

                       Then I set the flag and the browser returned the same:

                     Internal Record ID is:345
                     Validation Pass

                       but the data was NOT updated.

                       I noted that you did not have an error trap after the final commit(), so I added one:

                          if (FileMaker::isError($result)) {
                              echo "Error on commit: {$result->getMessage()}";
                          } else {
                             echo "Commit successful";
                          }

                       Now the browser returned:

                     Internal Record ID is:345
                     Validation Pass
                     Error on commit:

                       In other words, like my initial script, validation passed but the commit failed.

                       Please note I have tried this (your script) on two different servers, both with the same result.

                       Kind regards

                       Daniel

                  • 6. Re: PHP Edit command fails if "Not Empty" validation set
                    TSGal

                         Daniel Kaan:

                         We're still unable to replicate.  Here are some things to try:

                         In order to help debug, check the log files under FileMaker Server -> HTTPS -> logs

                         From the Admin Console -> Web Publishing node, set logging level to Error and Info.  Save, and run the PHP script via a browser.  It will log equivalent XML calls.  You can then view them under Log Viewer -> Modules -> Select Web Publishing Core, or under WPE log file which can be run via browser and see the results.

                         Check to make sure the Privileges on the FileMaker Pro file are set properly.

                         If the problem persists, then we need to see the log files (FileMaker Server -> HTTPS -> logs and equivalent XML calls in order to debug the issue, e.g., wpe.log file when error level is set to Error and Info).

                         Also, the result of the following XML query when run locally on the server:

                         http://localhost/fmi/xml/fmresultset.xml?-db=FMServer_Sample&-lay=PHP Technology Test&-edit&Task Name Sample(1)=PHP Test Data&-recid=345

                         If you need to send in files, check your Inbox at the top of this page for instructions.

                         TSGal
                         FileMaker, Inc.

                    • 7. Re: PHP Edit command fails if "Not Empty" validation set
                      DanielKaan
                           WPE loging was set to info and error
                            
                           running the script with the "Not empty" flag off caused no error log entries:
                              2014-01-16 22:40:59 +1100 192.168.1.111 127.0.0.1:59504 Admin - INFO 0 72936 "/fmi/xml/fmresultset.xml?-db=FMServer_Sample&-lay=PHP Technology Test&-findall"
                              2014-01-16 22:40:59 +1100 192.168.1.111 127.0.0.1:59506 Admin - INFO 0 1747 "/fmi/xml/fmresultset.xml?-db=FMServer_Sample&-lay=PHP Technology Test&-find&-recid=345"
                              2014-01-16 22:40:59 +1100 192.168.1.111 127.0.0.1:59508 Admin - INFO 0 1473 "/fmi/xml/fmresultset.xml?-db=FMServer_Sample&-lay=PHP Technology Test&-view"
                              2014-01-16 22:40:59 +1100 192.168.1.111 127.0.0.1:59510 Admin - INFO 0 1761 "/fmi/xml/fmresultset.xml?-db=FMServer_Sample&-lay=PHP Technology Test&-edit&Task Name Sample(1)=PHP Test Data1&-recid=345"
                            
                           running the script with the "Not empty" flag on caused no error log entries, but only produced 3 instead of 4 lines:
                              2014-01-16 22:44:14 +1100 192.168.1.111 127.0.0.1:59551 Admin - INFO 0 72937 "/fmi/xml/fmresultset.xml?-db=FMServer_Sample&-lay=PHP Technology Test&-findall"
                              2014-01-16 22:44:14 +1100 192.168.1.111 127.0.0.1:59553 Admin - INFO 0 1748 "/fmi/xml/fmresultset.xml?-db=FMServer_Sample&-lay=PHP Technology Test&-find&-recid=345"
                              2014-01-16 22:44:14 +1100 192.168.1.111 127.0.0.1:59555 Admin - INFO 0 1474 "/fmi/xml/fmresultset.xml?-db=FMServer_Sample&-lay=PHP Technology Test&-view"
                            
                           The file access privs are set correctly on the server. "fmserver" has Read & Write privileges. Nothing has changed here since a fresh install of the server.  Furthermore, when the "Not empty" validation is unchecked, the data is updated correctly.  This would not be the case if the file privileges or account privileges were not correct.  These have not been modified. The "Admin" account has no password and File Options are set to Log in using Admin.  The Admin account for the Sample file has Go/Pro, WebDirect, XLM, PHP and ODBC access enabled.  In fact the only modification that has been made to the file since it was installed is the checking of "Not Empty" validation box on the Translator::LANGUAGE MATCH FIELD for the sake of demonstrating this bug. The bug was actually first encountered and diagnosed on a different file and then replicated in the FMServer_Sample file on two different servers.
                            
                           Both the PHP and WebDirect technology tests on the FileMaker Technology Test page worked correctly.
                            
                           The  XML you asked me to run:
                           Regardless of whether the "Not empty" validation flag was off or on returned error 200 "Record access is denied":
                            
                           <fmresultset version="1.0">
                              <error code="200"/>
                              <product build="10/22/2013" name="FileMaker Web Publishing Engine" version="13.0.1.216"/>
                              <datasource database="" date-format="" layout="" table="" time-format="" timestamp-format="" total-count="0"/>
                              <metadata/>
                              <resultset count="0" fetch-size="0"/>
                           </fmresultset>
                            
                           and the following was entered into the logs:
                              2014-01-16 22:36:09 +1100 192.168.1.111 127.0.0.1:59446 - XML ERROR 200 566 "/fmi/xml/fmresultset.xml?-db=FMServer_Sample&-lay=PHP Technology Test&-edit&Task Name Sample(1)=PHP Test Data&-recid=345"
                            
                            
                           I tried the corresponding find:
                           returned the correct data (regardless of the flag setting):
                            
                           <fmresultset xmlns="http://www.filemaker.com/xml/fmresultset" version="1.0">
                              <error code="0"/>
                              <product build="10/22/2013" name="FileMaker Web Publishing Engine" version="13.0.1.216"/>
                              <datasource database="FMServer_Sample" date-format="MM/dd/yyyy" layout="PHP Technology Test" table="Translator" time-format="HH:mm:ss" timestamp-format="MM/dd/yyyy HH:mm:ss" total-count="227"/>
                              <metadata>
                                 <field-definition auto-enter="no" four-digit-year="no" global="no" max-repeat="1" name="LANGUAGE MATCH FIELD" not-empty="yes" numeric-only="no" result="text" time-of-day="no" type="normal"/>
                                 <field-definition auto-enter="no" four-digit-year="no" global="no" max-repeat="1" name="Task Name Sample" not-empty="no" numeric-only="no" result="text" time-of-day="no" type="normal"/>
                                 <field-definition auto-enter="no" four-digit-year="no" global="no" max-repeat="1" name="Task Start Date Sample" not-empty="no" numeric-only="no" result="date" time-of-day="no" type="normal"/>
                                 <field-definition auto-enter="no" four-digit-year="no" global="no" max-repeat="1" name="Task Due Date Sample" not-empty="no" numeric-only="no" result="date" time-of-day="no" type="normal"/>
                              </metadata>
                              <resultset count="1" fetch-size="1">
                                 <record mod-id="31" record-id="345">
                                    <field name="LANGUAGE MATCH FIELD">
                                       <data>English</data>
                                    </field>
                                    <field name="Task Name Sample">
                                       <data/>
                                    </field>
                                    <field name="Task Start Date Sample">
                                       <data/>
                                    </field>
                                    <field name="Task Due Date Sample">
                                       <data/>
                                    </field>
                                 </record>
                              </resultset>
                           </fmresultset>
                            
                           and the following was entered into the logs:
                              2014-01-16 22:34:34 +1100 192.168.1.111 127.0.0.1:59422 - XML INFO 0 1748 "/fmi/xml/fmresultset.xml?-db=FMServer_Sample&-lay=PHP Technology Test&-recid=345&-find"
                            
                            
                           Note that the xml -edit failed on both settings of the "Not empty" flag, which is strange, because the php script correctly edits the records when the flag is off.  This might be a clue of sorts...
                      • 8. Re: PHP Edit command fails if "Not Empty" validation set
                        TSGal

                             Daniel Kaan:

                             Thank you for the information.  I have forwarded this to the tester.

                             TSGal
                             FileMaker, Inc.

                        • 9. Re: PHP Edit command fails if "Not Empty" validation set
                          TSGal

                               Daniel Kaan:

                               Per the log files, the field is not edited because there is no -edit call after running the PHP script.  Try calling commit() before validate().  For example:

                               $rec->setField($modifyfieldname, $modifyfieldvalue);
                               $result = $rec->commit(); //commit before validate()
                               $result = $rec->validate();

                               xml -edit failed on both settings of the "not empty" flag, because user access XML via browser by default logs in with Guest account, and Guest account on FMServer_Sample file does not have access to edit the records.  Give the Guest account [Full Access} privileges and try edit XML query again.

                               TSGal
                               FileMaker, Inc.

                          • 10. Re: PHP Edit command fails if "Not Empty" validation set
                            DanielKaan

                                 Thanks TSGal

                                 I should have picked up myself that the XLM needed Guest access.  Thanks for pointing that out. Once the Guest account was set to [Full Access] the XML performed as expected regardless of whether the "not empty" flag was set and returned the following:

                            <fmresultset xmlns="http://www.filemaker.com/xml/fmresultset" version="1.0">
                            <error code="0"/>
                            <product build="10/22/2013" name="FileMaker Web Publishing Engine" version="13.0.1.216"/>
                            <datasource database="FMServer_Sample" date-format="MM/dd/yyyy" layout="PHP Technology Test" table="Translator" time-format="HH:mm:ss"timestamp-format="MM/dd/yyyy HH:mm:ss" total-count="227"/>
                            <metadata>
                            <field-definition auto-enter="no" four-digit-year="no" global="no" max-repeat="1" name="LANGUAGE MATCH FIELD" not-empty="yes" numeric-only="no" result="text" time-of-day="no" type="normal"/>
                            <field-definition auto-enter="no" four-digit-year="no" global="no" max-repeat="1" name="Task Name Sample" not-empty="no" numeric-only="no" result="text" time-of-day="no" type="normal"/>
                            <field-definition auto-enter="no" four-digit-year="no" global="no" max-repeat="1" name="Task Start Date Sample" not-empty="no" numeric-only="no" result="date" time-of-day="no" type="normal"/>
                            <field-definition auto-enter="no" four-digit-year="no" global="no" max-repeat="1" name="Task Due Date Sample" not-empty="no" numeric-only="no" result="date" time-of-day="no" type="normal"/>
                            </metadata>
                            <resultset count="1" fetch-size="1">
                            <record mod-id="38" record-id="345">
                            <field name="LANGUAGE MATCH FIELD">
                            <data>English</data>
                            </field>
                            <field name="Task Name Sample">
                            <data>PHP Test Data</data>
                            </field>
                            <field name="Task Start Date Sample">
                            <data/>
                            </field>
                            <field name="Task Due Date Sample">
                            <data/>
                            </field>
                            </record>
                            </resultset>
                            </fmresultset>
                                  
                            In both cases the log showed:
                                  

                                       

                                           2014-01-22 08:34:15 +1100 192.168.1.111 192.168.1.2:51228 - XML INFO 0 1765 "/fmi/xml/fmresultset.xml?-db=FMServer_Sample&-lay=PHP Technology Test&-edit&Task Name Sample(1)=PHP Test Data&-recid=345"
                                            
                                           So far so good.
                                            
                                           Regarding the commit before the validate in php, there was no improvement when the "not empty" flag is set.  The commit prior to the validate of course fails ("FileMaker::isError($result)" is TRUE), but the subsequent validate still passes.  Here is the log entry when running the script:
                                            
                                                2014-01-22 08:46:18 +1100 192.168.1.111 ::57529 Admin - INFO 0 72937 "/fmi/xml/fmresultset.xml?-db=FMServer_Sample&-lay=PHP Technology Test&-findall"
                                                2014-01-22 08:46:18 +1100 192.168.1.111 ::57531 Admin - INFO 0 1748 "/fmi/xml/fmresultset.xml?-db=FMServer_Sample&-lay=PHP Technology Test&-find&-recid=345"
                                                2014-01-22 08:46:18 +1100 192.168.1.111 ::57533 Admin - INFO 0 1474 "/fmi/xml/fmresultset.xml?-db=FMServer_Sample&-lay=PHP Technology Test&-view"
                                                 
                                                With the "not empty" flag off, again the data is updated in the database and logs return:
                                                 
                                                     2014-01-22 08:53:34 +1100 192.168.1.111 ::57545 Admin - INFO 0 72936 "/fmi/xml/fmresultset.xml?-db=FMServer_Sample&-lay=PHP Technology Test&-findall"
                                                     2014-01-22 08:53:34 +1100 192.168.1.111 ::57548 Admin - INFO 0 1747 "/fmi/xml/fmresultset.xml?-db=FMServer_Sample&-lay=PHP Technology Test&-find&-recid=345"
                                                     2014-01-22 08:53:34 +1100 192.168.1.111 ::57550 Admin - INFO 0 1473 "/fmi/xml/fmresultset.xml?-db=FMServer_Sample&-lay=PHP Technology Test&-view"
                                                     2014-01-22 08:53:34 +1100 192.168.1.111 ::57552 Admin - INFO 0 1761 "/fmi/xml/fmresultset.xml?-db=FMServer_Sample&-lay=PHP Technology Test&-edit&Task Name Sample(1)=PHP Test Data1&-recid=345"
                                                      
                                                     We are still stuck with the following issues when the flag is set:
                                                     1. The validation passes, but the commit fails.
                                                     2. No sensible error is returned by FileMaker ("$result->getMessage()" returns nothing)
                                                      
                                                     I have added the following error reporting after the commit():
                                                      
                                                          if (FileMaker::isError($result)) {
                                                              echo "Error on commit: {$result->getCode()}\n";
                                                              $validationErrors= $result->getErrors();
                                                              foreach ($validationErrors as $error) {
                                                                  $field = $error[0];
                                                                  echo 'Field Name: ' . $field->getName(). '<br>';
                                                                  echo 'Error Code: ' . $error[1] . '<br>';
                                                                  echo 'Value: ' . $error[2] . '<br>';
                                                              }//End of foreach
                                                           
                                                          } else {
                                                            echo "Commit successful";
                                                          }
                                                           
                                                          This returned the following to the browser:
                                                           
                               Error on commit: Field Name: LANGUAGE MATCH FIELD
                               Error Code: 1
                                                      
                                                     I have included the full value of $validationErrors below in case that is any help to you. It is all a bit impenetrable to me.
                                                      
                                                     Thanks again for your continued engagement with this problem; it is much appreciated.
                                                      
                                                     Kind regards
                                                     Daniel
                                                      
                                                     ------- var_dump($validationErrors) -------
                                                      

                                                               array(1) {

                                                                 [0]=>

                                                                 array(3) {

                                                                   [0]=>

                                                                   object(FileMaker_Field_Implementation)#489 (12) {

                                                                     ["_layout"]=>

                                                                     &object(FileMaker_Layout)#472 (1) {

                                                                       ["_impl"]=>

                                                                       object(FileMaker_Layout_Implementation)#473 (8) {

                                                                         ["_fm"]=>

                                                                         object(FileMaker_Implementation)#2 (3) {

                                                                           ["V73ee434e"]=>

                                                                           array(9) {

                                                                             ["charset"]=>

                                                                             string(5) "UTF-8"

                                                                             ["locale"]=>

                                                                             string(2) "en"

                                                                             ["logLevel"]=>

                                                                             int(3)

                                                                             ["hostspec"]=>

                                                                             string(16) "http://localhost"

                                                                             ["recordClass"]=>

                                                                             string(16) "FileMaker_Record"

                                                                             ["prevalidate"]=>

                                                                             bool(true)

                                                                             ["database"]=>

                                                                             string(15) "FMServer_Sample"

                                                                             ["username"]=>

                                                                             string(5) "Admin"

                                                                             ["password"]=>

                                                                             string(0) ""

                                                                           }

                                                                           ["Vea4b3413"]=>

                                                                           NULL

                                                                           ["V9a3dcbce"]=>

                                                                           NULL

                                                                         }

                                                                         ["_name"]=>

                                                                         string(19) "PHP Technology Test"

                                                                         ["_fields"]=>

                                                                         array(4) {

                                                                           ["LANGUAGE MATCH FIELD"]=>

                                                                           object(FileMaker_Field)#488 (1) {

                                                                             ["_impl"]=>

                                                                             *RECURSION*

                                                                           }

                                                                           ["Task Name Sample"]=>

                                                                           object(FileMaker_Field)#490 (1) {

                                                                             ["_impl"]=>

                                                                             object(FileMaker_Field_Implementation)#491 (12) {

                                                                               ["_layout"]=>

                                                                               *RECURSION*

                                                                               ["_name"]=>

                                                                               string(16) "Task Name Sample"

                                                                               ["_autoEntered"]=>

                                                                               bool(false)

                                                                               ["_global"]=>

                                                                               bool(false)

                                                                               ["_maxRepeat"]=>

                                                                               int(1)

                                                                               ["_validationMask"]=>

                                                                               int(0)

                                                                               ["_validationRules"]=>

                                                                               array(0) {

                                                                               }

                                                                               ["_result"]=>

                                                                               string(4) "text"

                                                                               ["_type"]=>

                                                                               string(6) "normal"

                                                                               ["_valueList"]=>

                                                                               NULL

                                                                               ["_styleType"]=>

                                                                               NULL

                                                                               ["_maxCharacters"]=>

                                                                               int(0)

                                                                             }

                                                                           }

                                                                           ["Task Start Date Sample"]=>

                                                                           object(FileMaker_Field)#492 (1) {

                                                                             ["_impl"]=>

                                                                             object(FileMaker_Field_Implementation)#493 (12) {

                                                                               ["_layout"]=>

                                                                               *RECURSION*

                                                                               ["_name"]=>

                                                                               string(22) "Task Start Date Sample"

                                                                               ["_autoEntered"]=>

                                                                               bool(false)

                                                                               ["_global"]=>

                                                                               bool(false)

                                                                               ["_maxRepeat"]=>

                                                                               int(1)

                                                                               ["_validationMask"]=>

                                                                               int(7)

                                                                               ["_validationRules"]=>

                                                                               array(1) {

                                                                                 [7]=>

                                                                                 bool(true)

                                                                               }

                                                                               ["_result"]=>

                                                                               string(4) "date"

                                                                               ["_type"]=>

                                                                               string(6) "normal"

                                                                               ["_valueList"]=>

                                                                               NULL

                                                                               ["_styleType"]=>

                                                                               NULL

                                                                               ["_maxCharacters"]=>

                                                                               int(0)

                                                                             }

                                                                           }

                                                                           ["Task Due Date Sample"]=>

                                                                           object(FileMaker_Field)#494 (1) {

                                                                             ["_impl"]=>

                                                                             object(FileMaker_Field_Implementation)#495 (12) {

                                                                               ["_layout"]=>

                                                                               *RECURSION*

                                                                               ["_name"]=>

                                                                               string(20) "Task Due Date Sample"

                                                                               ["_autoEntered"]=>

                                                                               bool(false)

                                                                               ["_global"]=>

                                                                               bool(false)

                                                                               ["_maxRepeat"]=>

                                                                               int(1)

                                                                               ["_validationMask"]=>

                                                                               int(7)

                                                                               ["_validationRules"]=>

                                                                               array(1) {

                                                                                 [7]=>

                                                                                 bool(true)

                                                                               }

                                                                               ["_result"]=>

                                                                               string(4) "date"

                                                                               ["_type"]=>

                                                                               string(6) "normal"

                                                                               ["_valueList"]=>

                                                                               NULL

                                                                               ["_styleType"]=>

                                                                               NULL

                                                                               ["_maxCharacters"]=>

                                                                               int(0)

                                                                             }

                                                                           }

                                                                         }

                                                                         ["_relatedSets"]=>

                                                                         array(0) {

                                                                         }

                                                                         ["_valueLists"]=>

                                                                         array(0) {

                                                                         }

                                                                         ["Vab234ad8"]=>

                                                                         array(0) {

                                                                         }

                                                                         ["_database"]=>

                                                                         string(15) "FMServer_Sample"

                                                                         ["_extended"]=>

                                                                         bool(false)

                                                                       }

                                                                     }

                                                                     ["_name"]=>

                                                                     string(20) "LANGUAGE MATCH FIELD"

                                                                     ["_autoEntered"]=>

                                                                     bool(false)

                                                                     ["_global"]=>

                                                                     bool(false)

                                                                     ["_maxRepeat"]=>

                                                                     int(1)

                                                                     ["_validationMask"]=>

                                                                     int(1)

                                                                     ["_validationRules"]=>

                                                                     array(1) {

                                                                       [1]=>

                                                                       bool(true)

                                                                     }

                                                                     ["_result"]=>

                                                                     string(4) "text"

                                                                     ["_type"]=>

                                                                     string(6) "normal"

                                                                     ["_valueList"]=>

                                                                     NULL

                                                                     ["_styleType"]=>

                                                                     NULL

                                                                     ["_maxCharacters"]=>

                                                                     int(0)

                                                                   }

                                                                   [1]=>

                                                                   int(1)

                                                                   [2]=>

                                                                   NULL

                                                                 }

                                                               }

                                                                

                                  

                            • 11. Re: PHP Edit command fails if "Not Empty" validation set
                              DanielKaan

                                   Slight addendum:  the output of the error trap I added to the commit statement was

                                 Error on commit: Field Name: LANGUAGE MATCH FIELD
                                 Error Code: 1
                                 Value:

                                   The "Value" ("$error[2]") parameter was blank.

                              • 12. Re: PHP Edit command fails if "Not Empty" validation set
                                TSGal

                                     Daniel Kaan:

                                     Thank you for the additional information.  All of it has been sent to the tester for review.

                                     TSGal
                                     FileMaker, Inc.

                                • 13. Re: PHP Edit command fails if "Not Empty" validation set
                                  TSGal

                                       Daniel Kaan:

                                       These are the validation results.  When validation fails, FileMaker returns three pieces of information: the field object that failed pre-validation, a validation constant value that indicates the validation rule that failed, and the actual value entered for the field that failed pre-validation.

                                       For more information, see "Processing the validation errors" on page 42 of the "Custom Web Publishing with PHP" guide at:

                                  https://fmhelp.filemaker.com/docs/13/en/fms13_cwp_php.pdf

                                       According to the results:

                                       NOT EMPTY Validation on LANGUAGE MATCH FIELD Failed with Value=empty

                                       From FileMaker Pro, open the sample file (using Open Remote from the hosting server) and verify the value inside "LANGUAGE MATCH FIELD" and any other field that has NOT EMPTY validation.  Also, make sure the PHP script is NOT trying to edit a field with NOT Empty validation with an empty string.  Try replicating in FileMaker Pro what your PHP script is doing (edit first record on PHP Technology Test) and see if that returns with success.  If it fails in FileMaker Pro, then it is also going to fail with PHP.

                                       TSGal
                                       FileMaker, Inc.

                                  • 14. Re: PHP Edit command fails if "Not Empty" validation set
                                    DanielKaan

                                         Thanks for your response

                                         Regarding the validation in FileMaker Pro, the LANGUAGE MATCH FIELD does contain data in the record I am trying to modify and in every other record.

                                         Regarding replicating it in FileMaker Pro, that is going in and modifying the "Task Name Sample" field on that record, works as expected. The fact that XML edited the record correctly too, confirms this.

                                         Regarding when the PHP not attempting to set an empty value into the LANGAUGE MATCH FIELD, this is clearly not the case.  I have included below a var_dump of the $rec variable just prior to the "$result = $rec->validate();" request (which passes) and the "$result = $rec->commit();" which fails. Clearly $rec has the data "English" in the LANGUAGE MATCH FIELD which it read from the original record; there is not an error in the data that should cause the commit to fail.

                                         These questions, while I understand that you are trying to eliminate possibilities, tent to imply that it is not a bug, but that I am doing something wrong. This original problem occurred in a script for a client solution which was working perfectly in version 11 and then 12, but then stopped working in version 13. The only reason I have focused on the FMServer_Sample and written an "as simple as possible" script is to demonstrate the problem. I believe there is nothing wrong with my PHP or the data.

                                         This is bug. And it seem to me a pretty fundamental one as BOTH edit methods as outlined on pages 29 and 30 of the https://fmhelp.filemaker.com/docs/13/en/fms13_cwp_php.pdf fail. I have replicated the problem on 2 different servers and in 3 databases. It is a bug.

                                         Since you are unable to replicate the error at your end, I am happy to give your testers VNC Admin access to my test server if that will help.

                                         Thanks for your continued engagement.

                                         Kind regards

                                         Daniel Kaan.

                                         ------ var_dump($rec) -------

                                         object(FileMaker_Record)#486 (1) {
                                           ["_impl"]=>
                                           object(FileMaker_Record_Implementation)#487 (8) {
                                             ["_fields"]=>
                                             array(4) {
                                               ["LANGUAGE MATCH FIELD"]=>
                                               array(1) {
                                                 [0]=>
                                                 string(7) "English"
                                               }
                                               ["Task Name Sample"]=>
                                               array(1) {
                                                 [0]=>
                                                 string(14) "PHP Test Data1"
                                               }
                                               ["Task Start Date Sample"]=>
                                               array(1) {
                                                 [0]=>
                                                 string(0) ""
                                               }
                                               ["Task Due Date Sample"]=>
                                               array(1) {
                                                 [0]=>
                                                 string(0) ""
                                               }
                                             }
                                             ["V5e7ec2d5"]=>
                                             array(1) {
                                               ["Task Name Sample"]=>
                                               array(1) {
                                                 [0]=>
                                                 bool(true)
                                               }
                                             }
                                             ["_recordId"]=>
                                             string(3) "345"
                                             ["_modificationId"]=>
                                             string(2) "50"
                                             ["_layout"]=>
                                             &object(FileMaker_Layout)#476 (1) {
                                               ["_impl"]=>
                                               object(FileMaker_Layout_Implementation)#477 (8) {
                                                 ["_fm"]=>
                                                 &object(FileMaker_Implementation)#2 (3) {
                                                   ["V73ee434e"]=>
                                                   array(9) {
                                                     ["charset"]=>
                                                     string(5) "UTF-8"
                                                     ["locale"]=>
                                                     string(2) "en"
                                                     ["logLevel"]=>
                                                     int(3)
                                                     ["hostspec"]=>
                                                     string(16) "http://localhost"
                                                     ["recordClass"]=>
                                                     string(16) "FileMaker_Record"
                                                     ["prevalidate"]=>
                                                     bool(true)
                                                     ["database"]=>
                                                     string(15) "FMServer_Sample"
                                                     ["username"]=>
                                                     string(5) "Admin"
                                                     ["password"]=>
                                                     string(0) ""
                                                   }
                                                   ["Vea4b3413"]=>
                                                   NULL
                                                   ["V9a3dcbce"]=>
                                                   NULL
                                                 }
                                                 ["_name"]=>
                                                 string(19) "PHP Technology Test"
                                                 ["_fields"]=>
                                                 array(4) {
                                                   ["LANGUAGE MATCH FIELD"]=>
                                                   object(FileMaker_Field)#478 (1) {
                                                     ["_impl"]=>
                                                     object(FileMaker_Field_Implementation)#479 (12) {
                                                       ["_layout"]=>
                                                       *RECURSION*
                                                       ["_name"]=>
                                                       string(20) "LANGUAGE MATCH FIELD"
                                                       ["_autoEntered"]=>
                                                       bool(false)
                                                       ["_global"]=>
                                                       bool(false)
                                                       ["_maxRepeat"]=>
                                                       int(1)
                                                       ["_validationMask"]=>
                                                       int(1)
                                                       ["_validationRules"]=>
                                                       array(1) {
                                                         [1]=>
                                                         bool(true)
                                                       }
                                                       ["_result"]=>
                                                       string(4) "text"
                                                       ["_type"]=>
                                                       string(6) "normal"
                                                       ["_valueList"]=>
                                                       NULL
                                                       ["_styleType"]=>
                                                       NULL
                                                       ["_maxCharacters"]=>
                                                       int(0)
                                                     }
                                                   }
                                                   ["Task Name Sample"]=>
                                                   object(FileMaker_Field)#480 (1) {
                                                     ["_impl"]=>
                                                     object(FileMaker_Field_Implementation)#481 (12) {
                                                       ["_layout"]=>
                                                       *RECURSION*
                                                       ["_name"]=>
                                                       string(16) "Task Name Sample"
                                                       ["_autoEntered"]=>
                                                       bool(false)
                                                       ["_global"]=>
                                                       bool(false)
                                                       ["_maxRepeat"]=>
                                                       int(1)
                                                       ["_validationMask"]=>
                                                       int(0)
                                                       ["_validationRules"]=>
                                                       array(0) {
                                                       }
                                                       ["_result"]=>
                                                       string(4) "text"
                                                       ["_type"]=>
                                                       string(6) "normal"
                                                       ["_valueList"]=>
                                                       NULL
                                                       ["_styleType"]=>
                                                       NULL
                                                       ["_maxCharacters"]=>
                                                       int(0)
                                                     }
                                                   }
                                                   ["Task Start Date Sample"]=>
                                                   object(FileMaker_Field)#482 (1) {
                                                     ["_impl"]=>
                                                     object(FileMaker_Field_Implementation)#483 (12) {
                                                       ["_layout"]=>
                                                       *RECURSION*
                                                       ["_name"]=>
                                                       string(22) "Task Start Date Sample"
                                                       ["_autoEntered"]=>
                                                       bool(false)
                                                       ["_global"]=>
                                                       bool(false)
                                                       ["_maxRepeat"]=>
                                                       int(1)
                                                       ["_validationMask"]=>
                                                       int(7)
                                                       ["_validationRules"]=>
                                                       array(1) {
                                                         [7]=>
                                                         bool(true)
                                                       }
                                                       ["_result"]=>
                                                       string(4) "date"
                                                       ["_type"]=>
                                                       string(6) "normal"
                                                       ["_valueList"]=>
                                                       NULL
                                                       ["_styleType"]=>
                                                       NULL
                                                       ["_maxCharacters"]=>
                                                       int(0)
                                                     }
                                                   }
                                                   ["Task Due Date Sample"]=>
                                                   object(FileMaker_Field)#484 (1) {
                                                     ["_impl"]=>
                                                     object(FileMaker_Field_Implementation)#485 (12) {
                                                       ["_layout"]=>
                                                       *RECURSION*
                                                       ["_name"]=>
                                                       string(20) "Task Due Date Sample"
                                                       ["_autoEntered"]=>
                                                       bool(false)
                                                       ["_global"]=>
                                                       bool(false)
                                                       ["_maxRepeat"]=>
                                                       int(1)
                                                       ["_validationMask"]=>
                                                       int(7)
                                                       ["_validationRules"]=>
                                                       array(1) {
                                                         [7]=>
                                                         bool(true)
                                                       }
                                                       ["_result"]=>
                                                       string(4) "date"
                                                       ["_type"]=>
                                                       string(6) "normal"
                                                       ["_valueList"]=>
                                                       NULL
                                                       ["_styleType"]=>
                                                       NULL
                                                       ["_maxCharacters"]=>
                                                       int(0)
                                                     }
                                                   }
                                                 }
                                                 ["_relatedSets"]=>
                                                 array(0) {
                                                 }
                                                 ["_valueLists"]=>
                                                 array(0) {
                                                 }
                                                 ["Vab234ad8"]=>
                                                 array(0) {
                                                 }
                                                 ["_database"]=>
                                                 string(15) "FMServer_Sample"
                                                 ["_extended"]=>
                                                 bool(false)
                                               }
                                             }
                                             ["_fm"]=>
                                             &object(FileMaker_Implementation)#2 (3) {
                                               ["V73ee434e"]=>
                                               array(9) {
                                                 ["charset"]=>
                                                 string(5) "UTF-8"
                                                 ["locale"]=>
                                                 string(2) "en"
                                                 ["logLevel"]=>
                                                 int(3)
                                                 ["hostspec"]=>
                                                 string(16) "http://localhost"
                                                 ["recordClass"]=>
                                                 string(16) "FileMaker_Record"
                                                 ["prevalidate"]=>
                                                 bool(true)
                                                 ["database"]=>
                                                 string(15) "FMServer_Sample"
                                                 ["username"]=>
                                                 string(5) "Admin"
                                                 ["password"]=>
                                                 string(0) ""
                                               }
                                               ["Vea4b3413"]=>
                                               NULL
                                               ["V9a3dcbce"]=>
                                               NULL
                                             }
                                             ["_relatedSets"]=>
                                             array(0) {
                                             }
                                             ["_parent"]=>
                                             NULL
                                           }
                                         }
                                          
                                    1 2 Previous Next