Details
-
Type: Bug
-
Status: Done/Fixed
-
Priority: Major
-
Resolution: Fixed/Completed
-
Affects Version/s: 4.7
-
Fix Version/s: 4.7.12
-
Component/s: CiviCRM Search
-
Labels:
-
Documentation Required?:None
-
Funding Source:Contributed Code
Description
When error reporting is not turned off and no sort order is specified in an advanced contact search export, a PHP Warning is thrown:
Warning: strpos() [function.strpos]: Empty needle in .../wp-content/plugins/civicrm/civicrm/CRM/Export/BAO/Export.php on line 709
This then triggers multiple "headers already sent" error messages and the CSV file is not served.
The original warning message is due to the variable $order being passed as the second parameter in strpos(). In CRM_Export_BAO_Export::exportComponents(), $order defaults to NULL. By the time the code gets to the aforementioned strpos() function, $order is unchanged and hence is an empty string for strpos() if a string wasn't passed to the function.
If we simply wrap the conflicting code in an if($order) statement, the issue should be resolved. Fortunately, such an if statement is directly afterwards, so I would recommend just moving the strpos() code block into the following if($order) statement. I've checked this and it fixes the issue on my setup.