undefined offset bug in BAO/FinancialAccount.php
while dealing with a white screen, I found a suspicious message in php_errorlog. In debugging that, I think I hit a bug.
- civicrm 5.26.2
In the logging, I see this line:
[22-Jun-2020 16:58:39 Europe/Amsterdam] PHP Notice: Undefined offset: 0 in /home/user/public_html/civicrm-nw/wp-content/plugins/civicrm/civicrm/CRM/Financial/BAO/FinancialAccount.php on line 255
This notice is triggered by doing a payment after registering for a paid event.
The line that is mentioned in the notice is in function getFinancialAccountForFinancialTypeByRelationship; I put in some print statements and found out that it gets value 'Income Account is' in parameter $relationshipType. The line of the message uses the hard coded value instead:
$incomeAccountRelationshipID = array_search('Income Account is', $accountRelationships);
which is suspicious in itself. But the array $accountRelationships does not contain that value, which causes the message. The array appears to contain the dutch equivalents of the relationships:
LOC103 Array (  => Inkomsten rekening is  => Credit/Contra Revenue Account is ....more }
I am no php programmer, so I fixed it for my site by changing the hard code value to 'Inkomsten rekening is', making the message disappear. I think the code should be changed to somethink like
$incomeAccountRelationshipID = array_search(translation_of ($relationshipType), $accountRelationships);