Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP8.2 undefined property fix event summary report #27888

Merged
merged 1 commit into from
Oct 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 22 additions & 24 deletions CRM/Report/Form/Event/Summary.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,50 +132,48 @@ public function select() {
$this->_select = 'SELECT ' . implode(', ', $select);
}

public function from() {
public function from(): void {
$this->_from = " FROM civicrm_event {$this->_aliases['civicrm_event']} ";
}

public function where() {
public function where(): void {
$clauses = [];
$this->_participantWhere = "";
foreach ($this->_columns as $tableName => $table) {
foreach ($this->_columns as $table) {
if (array_key_exists('filters', $table)) {
foreach ($table['filters'] as $fieldName => $field) {
$clause = NULL;
if (($field['type'] ?? 0) & CRM_Utils_Type::T_DATE) {
$relative = $this->_params["{$fieldName}_relative"] ?? NULL;
$from = $this->_params["{$fieldName}_from"] ?? NULL;
$to = $this->_params["{$fieldName}_to"] ?? NULL;

if ($relative || $from || $to) {
$clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type']);
$clauses[] = $this->dateClause($field['name'], $relative, $from, $to, $field['type']);
}
}
else {
$op = $this->_params["{$fieldName}_op"] ?? NULL;
if ($op) {
$clause = $this->whereClause($field,
$clauses[] = $this->whereClause($field,
$op,
CRM_Utils_Array::value("{$fieldName}_value", $this->_params),
CRM_Utils_Array::value("{$fieldName}_min", $this->_params),
CRM_Utils_Array::value("{$fieldName}_max", $this->_params)
$this->_params["{$fieldName}_value"] ?? NULL,
$this->_params["{$fieldName}_min"] ?? NULL,
$this->_params["{$fieldName}_max"] ?? NULL,
Comment on lines +158 to +160
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI this will merge-conflict with #27816

);
}
}
if (!empty($this->_params['id_value'])) {
$idValue = is_array($this->_params['id_value']) ? implode(',', $this->_params['id_value']) : $this->_params['id_value'];
$this->_participantWhere = " AND civicrm_participant.event_id IN ( $idValue ) ";
}

if (!empty($clause)) {
$clauses[] = $clause;
}
}
}
}
$clauses[] = "{$this->_aliases['civicrm_event']}.is_template = 0";
$this->_where = 'WHERE ' . implode(' AND ', $clauses);
$this->_where = 'WHERE ' . implode(' AND ', array_filter($clauses));
}

public function getEventFilter(): string {
$eventID = array_filter((array) $this->_params['id_value']);
if (empty($eventID)) {
return '';
}
return ' AND civicrm_participant.event_id IN ( ' . implode(',', $eventID) . ') ';
}

public function groupBy() {
Expand All @@ -192,7 +190,7 @@ public function participantInfo() {
$statusType1 = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 1');
$statusType2 = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 0');

$sql = "
$sql = '
SELECT civicrm_participant.event_id AS event_id,
civicrm_participant.status_id AS statusId,
COUNT( civicrm_participant.id ) AS participant,
Expand All @@ -202,11 +200,11 @@ public function participantInfo() {
FROM civicrm_participant

WHERE civicrm_participant.is_test = 0
$this->_participantWhere
' . $this->getEventFilter() . '

GROUP BY civicrm_participant.event_id,
civicrm_participant.status_id,
civicrm_participant.fee_currency";
civicrm_participant.fee_currency';

$info = CRM_Core_DAO::executeQuery($sql);
$participant_data = $participant_info = $currency = [];
Expand Down Expand Up @@ -306,8 +304,8 @@ public function postProcess() {
while ($dao->fetch()) {
$row = [];
foreach ($this->_columnHeaders as $key => $value) {
if (($key == 'civicrm_event_start_date') ||
($key == 'civicrm_event_end_date')
if (($key === 'civicrm_event_start_date') ||
($key === 'civicrm_event_end_date')
) {
//get event start date and end date in custom datetime format
$row[$key] = CRM_Utils_Date::customFormat($dao->$key);
Expand Down