Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.0] Remove slaveOkay remainders #1716

Merged
merged 1 commit into from
Jan 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/en/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ Working with Objects
:doc:`Query Builder API <reference/query-builder-api>` |
:doc:`Aggregation Pipeline queries <reference/aggregation-builder>` |
:doc:`Geo Spatial Queries <reference/geospatial-queries>` |
:doc:`Slave Okay Queries <reference/slave-okay-queries>` |
:doc:`Find and Update <reference/find-and-update>` |
:doc:`Filters <reference/filters>` |
:doc:`Priming References <reference/priming-references>` |
Expand Down
5 changes: 0 additions & 5 deletions docs/en/reference/annotations-reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -812,11 +812,6 @@ that will be applied when querying for the annotated document.
{
}

.. note::

This annotation can not be combined with ``slaveOkay``, such combination will
produce a ``MappingException`` error.

.. _annotations_reference_reference_many:

@ReferenceMany
Expand Down
4 changes: 0 additions & 4 deletions docs/en/reference/priming-references.rst
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,6 @@ As an example, we can look at the default callable, which is found in the
$qb = $dm->createQueryBuilder($class->name)
->field($class->identifier)->in($ids);

if ( ! empty($hints[Query::HINT_SLAVE_OKAY])) {
$qb->slaveOkay(true);
}

if ( ! empty($hints[Query::HINT_READ_PREFERENCE])) {
$qb->setReadPreference(
$hints[Query::HINT_READ_PREFERENCE],
Expand Down
71 changes: 0 additions & 71 deletions docs/en/reference/slave-okay-queries.rst

This file was deleted.

1 change: 0 additions & 1 deletion doctrine-mongo-mapping.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
<xs:attribute name="repository-class" type="xs:string"/>
<xs:attribute name="inheritance-type" type="odm:inheritance-type"/>
<xs:attribute name="change-tracking-policy" type="odm:change-tracking-policy" />
<xs:attribute name="slave-okay" type="xs:boolean" />
<xs:attribute name="read-only" type="xs:boolean" />
</xs:complexType>

Expand Down
2 changes: 0 additions & 2 deletions lib/Doctrine/ODM/MongoDB/Mapping/Annotations/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,5 @@ final class Document extends AbstractDocument
public $indexes = array();
public $readOnly = false;
public $shardKey;
/** @deprecated */
public $slaveOkay;
public $writeConcern;
}
4 changes: 0 additions & 4 deletions lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,6 @@ public function __sleep()
$serialized[] = 'lifecycleCallbacks';
}

if ($this->slaveOkay) {
$serialized[] = 'slaveOkay';
}

if ($this->collectionCapped) {
$serialized[] = 'collectionCapped';
$serialized[] = 'collectionSize';
Expand Down
36 changes: 0 additions & 36 deletions lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadataInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,6 @@ class ClassMetadataInfo implements \Doctrine\Common\Persistence\Mapping\ClassMet
*/
public $identifier;

/**
* READ-ONLY: Whether or not reads for this class are okay to read from a slave.
*
* @deprecated in version 1.2 and will be removed in 2.0.
*/
public $slaveOkay;

/**
* READ-ONLY: The array of indexes for the document collection.
*/
Expand Down Expand Up @@ -802,30 +795,6 @@ public function setDiscriminatorValue($value)
$this->discriminatorValue = $value;
}

/**
* Sets the slaveOkay option applied to collections for this class.
*
* @param boolean|null $slaveOkay
*
* @deprecated in version 1.2 and will be removed in 2.0.
*
* @throws MappingException
*/
public function setSlaveOkay($slaveOkay)
{
if ($slaveOkay) {
@trigger_error(
sprintf('%s was deprecated in version 1.2 and will be removed in 2.0.', __METHOD__),
E_USER_DEPRECATED
);
}

if ($this->readPreference) {
throw MappingException::canNotCombineReadPreferenceAndSlaveOkay($this->getName());
}
$this->slaveOkay = $slaveOkay === null ? null : (boolean) $slaveOkay;
}

/**
* Add a index for this Document.
*
Expand Down Expand Up @@ -947,14 +916,9 @@ public function isSharded()
*
* @param string $readPreference
* @param array|null $tags
*
* @throws MappingException
*/
public function setReadPreference($readPreference, $tags)
{
if ($this->slaveOkay) {
throw MappingException::canNotCombineReadPreferenceAndSlaveOkay($this->getName());
}
$this->readPreference = $readPreference;
$this->readPreferenceTags = $tags;
}
Expand Down
3 changes: 0 additions & 3 deletions lib/Doctrine/ODM/MongoDB/Mapping/Driver/AnnotationDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,6 @@ public function loadMetadataForClass($className, ClassMetadata $class)
$this->addIndex($class, $index);
}
}
if (isset($documentAnnot->slaveOkay)) {
$class->setSlaveOkay($documentAnnot->slaveOkay);
}
if (! empty($documentAnnot->readOnly)) {
$class->markReadOnly();
}
Expand Down
3 changes: 0 additions & 3 deletions lib/Doctrine/ODM/MongoDB/Mapping/Driver/XmlDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,6 @@ public function loadMetadataForClass($className, ClassMetadata $class)
if (isset($xmlRoot->{'shard-key'})) {
$this->setShardKey($class, $xmlRoot->{'shard-key'}[0]);
}
if (isset($xmlRoot['slave-okay'])) {
$class->setSlaveOkay('true' === (string) $xmlRoot['slave-okay']);
}
if (isset($xmlRoot['read-only']) && 'true' === (string) $xmlRoot['read-only']) {
$class->markReadOnly();
}
Expand Down
3 changes: 0 additions & 3 deletions lib/Doctrine/ODM/MongoDB/Mapping/Driver/YamlDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,6 @@ public function loadMetadataForClass($className, ClassMetadata $class)
if (isset($element['changeTrackingPolicy'])) {
$class->setChangeTrackingPolicy(constant(MappingClassMetadata::class . '::CHANGETRACKING_' . strtoupper($element['changeTrackingPolicy'])));
}
if (isset($element['slaveOkay'])) {
$class->setSlaveOkay($element['slaveOkay']);
}
if (! empty($element['readOnly'])) {
$class->markReadOnly();
}
Expand Down
10 changes: 0 additions & 10 deletions lib/Doctrine/ODM/MongoDB/Mapping/MappingException.php
Original file line number Diff line number Diff line change
Expand Up @@ -389,16 +389,6 @@ public static function referencePrimersOnlySupportedForInverseReferenceMany($cla
return new self("Cannot use reference priming on '$fieldName' in class '$className'. Reference priming is only supported for inverse references");
}

/**
* @param string $className
* @return MappingException
* @deprecated Method will be removed along with slaveOkay in version 2.0.
*/
public static function canNotCombineReadPreferenceAndSlaveOkay($className)
{
return new self("Cannot use ReadPreference and SlaveOkay at the same time in class '$className'.");
}

public static function connectFromFieldMustReferenceSameDocument($fieldName)
{
return new self("Cannot use field '$fieldName' as connectFromField in a \$graphLookup stage. Reference must target the document itself.");
Expand Down
4 changes: 0 additions & 4 deletions lib/Doctrine/ODM/MongoDB/Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -773,10 +773,6 @@ public function getQuery(array $options = array())
$query['sort'] = $documentPersister->prepareSort($query['sort']);
}

if ($this->class->slaveOkay) {
$query['slaveOkay'] = $this->class->slaveOkay;
}

if ($this->class->readPreference && ! array_key_exists('readPreference', $query)) {
$query['readPreference'] = new ReadPreference($this->class->readPreference, $this->class->readPreferenceTags);
}
Expand Down
7 changes: 1 addition & 6 deletions lib/Doctrine/ODM/MongoDB/Query/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ class Query implements \IteratorAggregate
const TYPE_GEO_LOCATION = 10;

const HINT_REFRESH = 1;
/** @deprecated */
const HINT_SLAVE_OKAY = 2;
// 2 was used for HINT_SLAVE_OKAY, which was removed in 2.0
const HINT_READ_PREFERENCE = 3;
const HINT_READ_ONLY = 5;

Expand Down Expand Up @@ -159,10 +158,6 @@ public function __construct(DocumentManager $dm, ClassMetadata $class, Collectio
$this->setReadOnly($readOnly);
$this->setRefresh($refresh);

if (isset($query['slaveOkay'])) {
$this->unitOfWorkHints[self::HINT_SLAVE_OKAY] = $query['slaveOkay'];
}

if (isset($query['readPreference'])) {
$this->unitOfWorkHints[self::HINT_READ_PREFERENCE] = $query['readPreference'];
}
Expand Down
4 changes: 0 additions & 4 deletions lib/Doctrine/ODM/MongoDB/Query/ReferencePrimer.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ public function __construct(DocumentManager $dm, UnitOfWork $uow)
$qb = $dm->createQueryBuilder($class->name)
->field($class->identifier)->in($ids);

if ( ! empty($hints[Query::HINT_SLAVE_OKAY])) {
$qb->slaveOkay(true);
}

if ( ! empty($hints[Query::HINT_READ_PREFERENCE])) {
$qb->setReadPreference($hints[Query::HINT_READ_PREFERENCE]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,6 @@

class ClassMetadataInfoTest extends \Doctrine\ODM\MongoDB\Tests\BaseTest
{
public function testSlaveOkayDefault()
{
$cm = new ClassMetadataInfo('stdClass');

$this->assertNull($cm->slaveOkay);
}

public function testDefaultDiscriminatorField()
{
$cm = new ClassMetadataInfo('stdClass');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public function testClassMetadataInstanceSerialization()
$cm->setCustomRepositoryClass("UserRepository");
$cm->setDiscriminatorField('disc');
$cm->mapOneEmbedded(array('fieldName' => 'phonenumbers', 'targetDocument' => 'Bar'));
$cm->setSlaveOkay(true);
$cm->setShardKey(array('_id' => '1'));
$cm->setCollectionCapped(true);
$cm->setCollectionMax(1000);
Expand All @@ -53,7 +52,6 @@ public function testClassMetadataInstanceSerialization()
$this->assertInternalType('array', $cm->getFieldMapping('phonenumbers'));
$this->assertCount(1, $cm->fieldMappings);
$this->assertCount(1, $cm->associationMappings);
$this->assertTrue($cm->slaveOkay);
$this->assertEquals(array('keys' => array('_id' => 1), 'options' => array()), $cm->getShardKey());
$mapping = $cm->getFieldMapping('phonenumbers');
$this->assertEquals('Documents\Bar', $mapping['targetDocument']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ public function testDriverShouldParseNonStringAttributes()
$classMetadata = new ClassMetadata('TestDocuments\UserNonStringOptions');
$this->driver->loadMetadataForClass('TestDocuments\UserNonStringOptions', $classMetadata);

$this->assertFalse($classMetadata->slaveOkay);

$profileMapping = $classMetadata->fieldMappings['profile'];
$this->assertSame(ClassMetadataInfo::REFERENCE_STORE_AS_ID, $profileMapping['storeAs']);
$this->assertTrue($profileMapping['orphanRemoval']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xsi:schemaLocation="http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping
http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping.xsd">

<document name="TestDocuments\UserNonStringOptions" slave-okay="false">
<document name="TestDocuments\UserNonStringOptions">
<field name="id" id="true" />
<reference-one target-document="Documents\Profile" field="profile" store-as="id" orphan-removal="true" />
<reference-many target-document="Documents\Group" field="groups" orphan-removal="" limit="0" skip="2" />
Expand Down