Skip to content
This repository was archived by the owner on Oct 29, 2020. It is now read-only.

Commit 6da9e7a

Browse files
committed
Merge pull request #6355 from DoSomething/bulk-exclude
Bulk exclude
2 parents 375eddf + 1832fc5 commit 6da9e7a

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

lib/modules/dosomething/dosomething_reportback/dosomething_reportback.install

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -916,10 +916,10 @@ function dosomething_reportback_update_7033() {
916916
* Updates any fid with a pending status to be marked as excluded if the quantity in the reportback is less than 200.
917917
*/
918918
function dosomething_reportback_update_7034() {
919-
$fids_to_be_marked_as_excluded = db_query("SELECT rb.nid, rb.run_nid, rb.quantity, rbf.status, rbf.fid
919+
$fids_to_be_marked_as_excluded = db_query("SELECT rb.rbid, rb.nid, rb.run_nid, rb.quantity, rbf.status, rbf.fid
920920
FROM dosomething_reportback rb
921921
JOIN dosomething_reportback_file rbf on rb.rbid = rbf.rbid
922-
WHERE rb.nid = '362' AND rb.run_nid = '5439' OR rb.run_nid = '2341' AND rb.quantity < 200 AND rbf.status = 'pending';");
922+
WHERE rb.nid = '362' AND rb.run_nid = '5439' OR rb.run_nid = '2341' AND rb.quantity < 200 AND rbf.status = 'pending';");
923923

924924
foreach ($fids_to_be_marked_as_excluded as $fid) {
925925
db_update('dosomething_reportback_file')
@@ -930,13 +930,19 @@ function dosomething_reportback_update_7034() {
930930
->condition('fid', $fid->fid)
931931
->execute();
932932

933-
$reportback_item = entity_load_single('reportback_item', $fid->fid);
934933
$reportback = reportback_load($fid->rbid);
934+
935+
if (empty($reportback)) {
936+
continue;
937+
}
938+
935939
$items = $reportback->getFids();
940+
$items = entity_load('reportback_item', $items);
936941

937942
foreach ($items as $item) {
943+
$flagged_fids = [];
944+
938945
if ($item->status === 'flagged') {
939-
$flagged_fids = [];
940946
array_push($flagged_fids, $item);
941947
}
942948
}
@@ -945,6 +951,5 @@ function dosomething_reportback_update_7034() {
945951
$reportback->flagged = 0;
946952
entity_save('reportback', $reportback);
947953
}
948-
949954
}
950955
}

0 commit comments

Comments
 (0)