Adamw has submitted this change and it was merged.

Change subject: Fix summary info for institutions
......................................................................


Fix summary info for institutions

The summary info for institutions (number of courses and students, and
whether the institution is active or not) is often incorrect due to
race conditions. This path fixes the issue by obtaining the summary
info for institutions from DB_MASTER.

Bug: 40433
Change-Id: I9f4186580f396a135273e189fc88dc38f47a555f
---
M includes/rows/Org.php
1 file changed, 7 insertions(+), 0 deletions(-)

Approvals:
  Adamw: Verified; Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/rows/Org.php b/includes/rows/Org.php
index c867987..0a0dd6e 100644
--- a/includes/rows/Org.php
+++ b/includes/rows/Org.php
@@ -35,6 +35,10 @@
 
                $fields = array();
 
+               // make sure we're getting up-to-date info about courses
+               $origCourseReadDB = Courses::singleton()->getReadDb();
+               Courses::singleton()->setReadDb( DB_MASTER );
+
                if ( in_array( 'course_count', $summaryFields ) || in_array( 
'courses', $summaryFields ) ) {
                        $fields['courses'] = 
Courses::singleton()->selectFields( 'id', array( 'org_id' => $this->getId() ) );
                        $fields['course_count'] = count( $fields['courses'] );
@@ -59,6 +63,9 @@
                        )->sum;
                }
 
+               // switch the readDB for courses back to whatever it was before
+               Courses::singleton()->setReadDb( $origCourseReadDB );
+
                $this->setFields( $fields );
        }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/109439
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I9f4186580f396a135273e189fc88dc38f47a555f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/EducationProgram
Gerrit-Branch: master
Gerrit-Owner: AndyRussG <[email protected]>
Gerrit-Reviewer: Adamw <[email protected]>
Gerrit-Reviewer: Ragesoss <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to