protected function resetOriginalReadPreference(){

        /** @var ReadPreference $dbReadPref */
        $dbReadPref = $this->db->__debugInfo()['readPreference'];
        if($this->originalDbReadPreference !== $dbReadPref->getMode())
        {
            $pref = (isset($this->originalDbReadPreference)
                ? $this->originalDbReadPreference
                : $this->readPreference
            );
            $dbTagsets = $dbReadPref->getTagsets();

            $this->db = $this->db->withOptions(array(
                'readPreference' => new ReadPreference($pref, $dbTagsets)
            ));
        }

        // Reset collection object
        /** @var ReadPreference $collReadPref */
        $collReadPref = $this->getCollection()->__debugInfo()['readPreference'];
        if($this->originalCollectionReadPreference !== $collReadPref->getMode()){
            $pref = (isset($this->originalCollectionReadPreference)
                ? $this->originalCollectionReadPreference
                : $this->readPreference
            );
            $collTagsets = $collReadPref->getTagsets();
            $this->collection = $this->collection->withOptions(array(
                'readPreference' => new ReadPreference($pref, $collTagsets)
            ));
        }
    }
protected function resetOriginalReadPreference(){

        /** @var ReadPreference $dbReadPref */
        $dbReadPref = $this->db->__debugInfo()['readPreference'];
        if($this->originalDbReadPreference !== $dbReadPref->getMode())
        {
            $pref = (isset($this->originalDbReadPreference)
                ? $this->originalDbReadPreference
                : $this->readPreference
            );
            $dbTagsets = $dbReadPref->getTagsets();

            $this->db = $this->db->withOptions(array(
                'readPreference' => new ReadPreference($pref, $dbTagsets)
            ));
        }

        // Reset collection object
        /** @var ReadPreference $collReadPref */
        $collReadPref = $this->getCollection()->__debugInfo()['readPreference'];
        if($this->originalCollectionReadPreference !== $collReadPref->getMode()){
            $pref = (isset($this->originalCollectionReadPreference)
                ? $this->originalCollectionReadPreference
                : $this->readPreference
            );
            $collTagsets = $collReadPref->getTagsets();
            $this->collection = $this->collection->withOptions(array(
                'readPreference' => new ReadPreference($pref, $collTagsets)
            ));
        }
    }
protected function resetOriginalReadPreference ( ) { /** @var ReadPreference $dbReadPref */ $ dbReadPref = $ this -> db -> __debugInfo ( ) [ 'readPreference' ] ; if ( $ this -> originalDbReadPreference !== $ dbReadPref -> getMode ( ) ) { $ pref = ( isset ( $ this -> originalDbReadPreference ) ? $ this -> originalDbReadPreference : $ this -> readPreference ) ; $ dbTagsets = $ dbReadPref -> getTagsets ( ) ; $ this -> db = $ this -> db -> withOptions ( array ( 'readPreference' => new ReadPreference ( $ pref , $ dbTagsets ) ) ) ; } // Reset collection object /** @var ReadPreference $collReadPref */ $ collReadPref = $ this -> getCollection ( ) -> __debugInfo ( ) [ 'readPreference' ] ; if ( $ this -> originalCollectionReadPreference !== $ collReadPref -> getMode ( ) ) { $ pref = ( isset ( $ this -> originalCollectionReadPreference ) ? $ this -> originalCollectionReadPreference : $ this -> readPreference ) ; $ collTagsets = $ collReadPref -> getTagsets ( ) ; $ this -> collection = $ this -> collection -> withOptions ( array ( 'readPreference' => new ReadPreference ( $ pref , $ collTagsets ) ) ) ; } }
Reset the original read preference after changing with setReadPreferenceToPrimary
Reset the original read preference after changing with setReadPreferenceToPrimary