"Relate" fields disappearing from views

Have encountered this strange problem when moving an instance of Suite 7.4.3 from one server to another (yes, I know it is an oldish version of Suite, but it has many customisations to the views and theme which will not survive an upgrade without much tweaking, so, although I will work through an upgrade in the long term, I need a working version on the new server in the meantime).

The problem is this - I added a couple of modules, and set up a relationship whereby a “Referral” (child) contains a link to a “School” (parent). This works just fine - on the Referral edit view I have a “school name” (relate) field with the usual lookup button which loads a pop-up “Schools” view and returns the selected name into the “school name” field. When the record is saved, the school name is displayed in the detail view. All working fine.

But when I copied the application to the new server, something happened to this relationship (I have painstaking repeated the process several times of copying the files, changing db and site_url settings, updating .htaccess, dumping and reloading the database etc., all of which I have successfully done several times before).

Now the school name no longer appears on the detail and edit views. On the edit view you can still load the popup, return the value, and save the record just as before (I have checked via SQL that the link id is actually stored), but on loading the detail view, or returning to the edit view, the school name is no longer displayed. An odd thing happens if I try to save a record which I know has a school link, but which is not displaying the school name - I get the warning flash on the “school name” field and the message “No match for field:Referral no” (Referral no is the label for the Referral.name field, which is situated elsewhere on the view)

The difference between the servers is that the original one is running mysql 5.1.73 and php 5.3.3, and the new one is running mariadb 10.2.9 and php 7.1.13 (this was the reason for moving the application, for compatibility with current SuiteCRM versions). So I am wondering if perhaps there is something in the code which is no longer valid in php7:

This is the code I used to implement the link


(SA_Referrals/vardef.php)

$dictionary['SA_Referrals'] = array(
	'table'=>'sa_referrals',
	'audited'=>true,
	'inline_edit'=>true,
	'duplicate_merge'=>true,
	'fields'=>array (

      ..........


  	'sa_schools' => array (
  		'name' => 'sa_schools',
    	'type' => 'link',
    	'relationship' => 'school_referrals',
			'link_type'=>'one',
			'side'=>'right',
    	'source'=>'non-db',
			'vname'=>'LBL_SCHOOLS',
  	),

   'school_name' => array (
    	'name' => 'school_name',
    	'rname' => 'name',
    	'id_name' => 'school_id',
    	'vname' => 'LBL_NAME',
    	'type' => 'relate',
    	'link'=>'sa_schools',
    	'table' => 'sa_schools',
    	'join_name'=>'sa_schools',
    	'isnull' => 'true',
    	'module' => 'SA_Schools',
    	'dbType' => 'varchar',
    	'len' => 100,
    	'source'=>'non-db',
    	'unified_search' => true,
    	'comment' => 'The name of the school represented by the school_id field',
    	// 'required' => true,
    	// 'importable' => 'required',
  	),

    'school_id'=> array(
  		'name'=>'school_id',
  		'type' => 'relate',
  		'dbType' => 'id',
  		'rname' => 'id',
    	'module' => 'SA_Schools',
    	'id_name' => 'school_id',
    	'reportable'=>false,
  		'vname'=>'LBL_ID',
  		'audited'=>true,
  		'massupdate' => false,
  		'comment' => 'The school with which the referral is associated'
  	),

   ..........

);

(SA_Schools/vardef.php)

$dictionary['SA_Schools'] = array(
	'table'=>'sa_schools',
	'audited'=>true,
	'inline_edit'=>true,
	'duplicate_merge'=>true,
	'fields' => array (
	),

   .....

	'relationships' => array (
		'school_referrals' => array(
			'lhs_module'        => 'SA_Schools',
			'lhs_table'         => 'sa_schools',
			'lhs_key'           => 'id',
			'rhs_module'        => 'SA_Referrals',
			'rhs_table'         => 'sa_referrals',
			'rhs_key'           => 'school_id',
			'relationship_type' =>'one-to-many'
		)
	),
);

and this is an attempt to find something that might be meaningful among the log files


suitecrm.log
============
Thu Feb  1 14:23:03 2018 [19521][b42d01df-5e77-7c88-3ccf-59e6022ff83e][DEBUG] SugarBean[SA_Referrals].load_relationships, Loading relationship (school_id).
Thu Feb  1 14:23:03 2018 [19521][b42d01df-5e77-7c88-3ccf-59e6022ff83e][DEBUG] SugarBean.load_relationships, Error Loading relationship (school_id)
Thu Feb  1 14:23:03 2018 [19521][b42d01df-5e77-7c88-3ccf-59e6022ff83e][DEBUG] SugarBean[SA_Referrals].load_relationships, Loading relationship (school_id).

/var/log/php-fpm/www-error.log
==============================
[31-Jan-2018 10:50:08 Europe/London] PHP Warning:  Declaration of SugarDateTime::setTime($hour, $minute, $sec = 0) should be compatible with DateTime::setTime($hour, $minute, $second = NULL, $microseconds = NULL) in /ylem/www/html/slideaway/include/SugarDateTime.php on line 0

[31-Jan-2018 12:17:02 Europe/London] PHP Notice:  Array to string conversion in /ylem/www/html/slideaway/data/SugarBean.php on line 2349
[31-Jan-2018 12:17:02 Europe/London] PHP Notice:  Array to string conversion in /ylem/www/html/slideaway/data/SugarBean.php on line 3382
[31-Jan-2018 12:17:02 Europe/London] PHP Notice:  Array to string conversion in /ylem/www/html/slideaway/data/SugarBean.php on line 4492
[31-Jan-2018 12:17:02 Europe/London] PHP Notice:  Undefined property: Contact::$Array in /ylem/www/html/slideaway/data/SugarBean.php on line 4492

Any advice greatly appreciated!

A few ideas for your explorations:

  1. When you do a Quick Repair and Rebuild, scroll down to the bottom to check if there is a button there to sync vardefs with database. If there is, press it.

  2. When moving things around, people often forget the existence of a table in the database called fields_meta_data. This can cause confusion on two ways: you copy it along with the database, when you shouldn’t; or you don’t copy it when you should. I’m not sure if this might be involved, but letting you know about this might help you reach conclusions.

  3. Try a few more Repairs from Admin / Repair. Javascript stuff, Relationships, etc.

No - none of the above suggestions got me anywhere. So in the end I bit the bullet and applied the upgrade to SuiteCRM 7.6.10 - lo and behold; it is all working again. So I can only think that the upgrade must have fixed some code that had been valid under php5, but is no longer valid under php7, because I can not see anything else that has changed. Will attempt further upgrade at some point - a previous upgrade to 7.8.8 had played havoc with our custom theme, which was why I had been wary of upgrading, but 7.6.10 seems fine, so will live with that for the time being.