Hannes Magnusson <notifications@github.com> wrote:

> > @@ -909,13 +929,31 @@ int mongo_cursor__do_query(zval *this_ptr,
> zval *return_value TSRMLS_DC) {
> >  		mongo_deregister_callback_from_connection(cursor->connection,
> cursor);
> >  	}
> >  
> > +	/* If the static property "slaveOkay" is set, we need to switch to
> a
> > +	 * MONGO_RP_SECONDARY_PREFERRED as well, but only if read
> preferences
> > +	 * aren't already set. */
> > +	if (cursor->read_pref.type == MONGO_RP_PRIMARY) {
> > +		zslaveokay = zend_read_static_property(mongo_ce_Cursor,
> "slaveOkay", strlen("slaveOkay"), NOISY TSRMLS_CC);
> > +		cursor->read_pref.type = Z_BVAL_P(zslaveokay) ?
> MONGO_RP_SECONDARY_PREFERRED : MONGO_RP_PRIMARY;
> > +	}
> 
> So the property is silently ignored when read preferences are set?
> That doesn't sound like a good idea to me.

All of the other modes allow for slaves to be read from anyway, so why warn when it works?

> Some sort of warning should be issued either at this stage, or when
> trying to set the property.

Can't do it when setting the property, as that happens on the class way before we even have an object to do that test against.