AndyRussG has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/109439


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(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/EducationProgram 
refs/changes/39/109439/1

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: newchange
Gerrit-Change-Id: I9f4186580f396a135273e189fc88dc38f47a555f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/EducationProgram
Gerrit-Branch: master
Gerrit-Owner: AndyRussG <[email protected]>

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

Reply via email to