[DCOM-249] Criteria are unable to locate getters for properties with an underscore prefix Created: 30/Jul/14  Updated: 30/Jul/14

Status: Open
Project: Doctrine Common
Component/s: Collections
Affects Version/s: 2.4.2
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Zach Garwood Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: collection, criteria, getter


 Description   

There are two related entities:
1) Inquiry:

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Criteria;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="inquiries")
 */
class Inquiry
{
    /**
     * @ORM\OneToMany(targetEntity="Field", mappedBy="_inquiry")
     */
    protected $_fields;

    public function __construct()
    {
        $this->_fields = new ArrayCollection();
    }

    // ...

    public function getFields()
    {
        $criteria = Criteria::create()->orderBy(['index' => Criteria::ASC]);

        return $this->_fields->matching($criteria);
    }
}

2) Field:

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="fields")
 */
class Field
{
    /**
     * @ORM\ManyToOne(targetEntity="Inquiry", inversedBy="_fields")
     * @ORM\JoinColumn(
     *      name="inquiry_id",
     *      referencedColumnName="id",
     *      nullable=false
     * )
     */
    protected $_inquiry;

    /**
     * @ORM\Column(name="index", type="integer", nullable=false)
     */
    protected $_index;

    // ...

    public function setIndex($index)
    {
        $this->_index = $index;

        return $this;
    }

    public function getIndex()
    {
        return $this->_index;
    }
}

Obviously, the underscore-prefixed property names are not ideal, but I didn't get to set the coding standard, I just have to follow it.

When trying to filter an ArrayCollection of Field entities in the Inquiry entity with an ordering criteria, I receive an ORMException with the message "Unrecognized field: index". If I alter the criteria to the following, I receive a PHP error with the message "PHP Fatal error: Cannot access protected property Field::$_index":

$criteria = Criteria::create()->orderBy(['_index' => Criteria::ASC]);

For whatever reason, Criteria::orderBy() is not finding the Field::getIndex() getter.

There are two workarounds that I've discovered for this issue:
The first is to make Field::$_index a public property:

    /**
     * @ORM\Column(name="index", type="integer", nullable=false)
     */
    public $_index;

The second, and the method that I've used, is to make an additional getter:

    public function get_index()
    {
        return $this->getIndex();
    }

I'm not sure why Criteria::orderBy() is unable to locate the Field::getIndex() getter but is able to locate Field::get_index(). And I'm sure that this is only an issue for people with ahem outdated coding standards. But it seems there is a bug with the way that the criteria are accessing getters and properties.






[DCOM-248] [GH-332] 0.25 second wait for file caching Created: 28/Jul/14  Updated: 28/Jul/14  Resolved: 28/Jul/14

Status: Resolved
Project: Doctrine Common
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Invalid Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of furison:

Url: https://github.com/doctrine/common/pull/332

Message:

To deal with the issue of windows caching files when you wirte to them then close the handle I have added a 0.25 second pause between closing and moving the file. This is so that windows finishes handling writting to the file before trying to move it



 Comments   
Comment by Doctrine Bot [ 28/Jul/14 ]

A related Github Pull-Request [GH-332] was closed:
https://github.com/doctrine/common/pull/332





[DCOM-246] [GH-328] Optimized imports Created: 27/Jul/14  Updated: 27/Jul/14  Resolved: 27/Jul/14

Status: Resolved
Project: Doctrine Common
Component/s: None
Affects Version/s: None
Fix Version/s: 2.5.0

Type: Improvement Priority: Major
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of JeroenDeDauw:

Url: https://github.com/doctrine/common/pull/328

Message:



 Comments   
Comment by Doctrine Bot [ 27/Jul/14 ]

A related Github Pull-Request [GH-328] was closed:
https://github.com/doctrine/common/pull/328





[DCOM-247] [GH-329] Remove dead config Created: 27/Jul/14  Updated: 27/Jul/14  Resolved: 27/Jul/14

Status: Resolved
Project: Doctrine Common
Component/s: None
Affects Version/s: None
Fix Version/s: 2.5.0

Type: Improvement Priority: Major
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of JeroenDeDauw:

Url: https://github.com/doctrine/common/pull/329

Message:



 Comments   
Comment by Doctrine Bot [ 27/Jul/14 ]

A related Github Pull-Request [GH-329] was closed:
https://github.com/doctrine/common/pull/329





Generated at Thu Jul 31 05:20:35 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.