[DCOM-234] Cache file fails on Windows - name too long Created: 19/Feb/14  Updated: 19/Feb/14

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

Type: Bug Priority: Critical
Reporter: Matt Durak Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Windows 8.1 x64
Symfony CMF with Doctrine caching



 Description   

The filename component of the FileCache is unbounded. It is possible to attempt to create files that are too long for the Windows filesystem. This causes an exception.

Example from a Symfony CMF/PHPCR project:

file_put_contents(D:\web_workspace\study\app\cache\dev\doctrine\cache\71d059fe39968db8\3e485dbb27419897\dfb24337887ff42c\a7b85c70bfefa781\nodes[nodes weak references cmsprogrampagesThe Summer ProgramThe Calendar 5 weeks for all Europe, routeContent, default][49].doctrinecache.data): failed to open stream: Invalid argument in D:\web_workspace\study\vendor\doctrine\cache\lib\Doctrine\Common\Cache\FilesystemCache.php line 111

In this case, the ID was
"nodes[nodes weak references cmsprogrampagesThe Summer ProgramThe Calendar 5 weeks for all Europe, routeContent, default][49].doctrinecache.data"

That refers to a phpcr node:
cms/program/pages/The Summer Program/The Calendar 5 weeks for all Europe

Attempting to manually create that file in windows explorer shows that it is trunacted to
"nodes[nodes weak references cmsprogrampagesThe Summer ProgramThe Calendar 5 weeks for all Europe, routeContent, default][49].do" (128 characters)

Shouldn't the ID be truncated so this doesn't happen? Should this be fixed here or in the phpcr that is creating the long ID to begin with?






[DCOM-239] [GH-319] Add last modified time for metadata Created: 22/Mar/14  Updated: 22/Mar/14

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

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

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

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

Message:

This PR is part 1 of 2. Part 1 is for the doctrine/doctrine2 repository.

Read more in https://github.com/doctrine/doctrine2/pull/986






[DCOM-232] [GH-315] Ability to use alternate dump functions Created: 04/Feb/14  Updated: 04/Feb/14

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

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

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

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

Message:

In most cases functions such as print_r provide much more readable output than var_dump. Some might also want to use var_export or write their own dump function. This should be a simple change that does not cause any BC breaks.






Proxies return private properties in __sleep, which is not supported by PHP. (DCOM-175)

[DCOM-221] Merge DCOM-175 into 2.4 Created: 01/Dec/13  Updated: 03/Dec/13

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

Type: Sub-task Priority: Major
Reporter: Marco Pivetta Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 1
Labels: proxy


 Description   

DCOM-175 is scheduled for 2.5, but I think it should be merged back in 2.4.x






[GH-298] Silence E_NOTICE warning: "Undefined index". (DCOM-216)

[DCOM-217] Merge DCOM-216 into 2.4.x Created: 16/Sep/13  Updated: 16/Sep/13

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

Type: Sub-task Priority: Major
Reporter: Marco Pivetta Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Commit https://github.com/doctrine/common/commit/d9dea98243c733ff589aab10e321de4f14a63ab4 should be merged back into 2.4.x






[GH-296] Proxies shouldn't serialize static properties in __sleep() (DCOM-212)

[DCOM-213] Merge DCOM-212 back into 2.4.x Created: 11/Sep/13  Updated: 11/Sep/13

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

Type: Sub-task Priority: Major
Reporter: Marco Pivetta Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: proxy


 Description   

Commit https://github.com/doctrine/doctrine2/commit/bb7f18ced76a553b00be563bed934c86d99afb73 should be backported into Doctrine 2.4.2






[DCOM-203] Ability to set defaultManager on ManagerRegistry Created: 21/Jun/13  Updated: 21/Jun/13

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

Type: Improvement Priority: Major
Reporter: Daniel Leech Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

We (in the CMF) need to be able to change the "default manager" name at runtime, to enable switching, for example, between Production and Staging workspaces.

This is currently not possible because defaultManager is private and there is no setter.

See: https://github.com/doctrine/DoctrinePHPCRBundle/issues/73






[DCOM-184] [GH-266] Add a new method to use a filter before extracting the metadata Created: 12/Mar/13  Updated: 23/Dec/13

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

Type: Bug Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 1
Labels: None


 Description   

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

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

Message:

Hi

I have notice that, when you use the doctrine:mapping:convert and doctrine:mapping:import command in symfony, the filter is added after all the metadata are extracting from the database.
In this case, when you have a table with no primary key for example, you cannot extract the mapping for only one entity.

I have also made a pull-request into the doctrineBundle and doctrine2 to fix this issue.
https://github.com/doctrine/DoctrineBundle/pull/161
https://github.com/doctrine/doctrine2/pull/603

What are your thought about my issue?



 Comments   
Comment by Doctrine Bot [ 23/Dec/13 ]

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





[DCOM-161] [GH-243] Update composer.json Created: 11/Jan/13  Updated: 23/Dec/13

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

Type: Bug Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

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

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

Message:

Add `provide` part as `doctrine/common` >=2.2,<2.4 has cache in it.



 Comments   
Comment by Doctrine Bot [ 23/Dec/13 ]

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





[DCOM-160] [GH-242] adds a simple manager registry Created: 10/Jan/13  Updated: 10/Jan/13

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

Type: Bug Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

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

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

Message:

This registry adds some sane defaults and just requires a simple callable to be fully functional.






[DCOM-152] [GH-234] Criteria filtering doesn't work with DateTime instance Created: 17/Dec/12  Updated: 03/Feb/14

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

Type: Bug Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

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

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

Message:

Filtering associations doesn't work with DateTime instance as a comparison value because filtering uses === operator. It works with SQL backed filtering, but not on PHP collection level.

```php
$criteria = Criteria::create()
>where(Criteria::expr()>eq("birthday", new \DateTime("1982-02-17")))
->orderBy(array("username" => "ASC"))
->setFirstResult(0)
->setMaxResults(20)
;
```



 Comments   
Comment by Doctrine Bot [ 03/Feb/14 ]

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





[DCOM-151] [GH-233] [DocParser] Fix trying include classes if its must be ignored. Created: 10/Dec/12  Updated: 03/Dec/13

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

Type: Bug Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

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

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

Message:

I recreate pull request (add test). Without fix test is failure.



 Comments   
Comment by Doctrine Bot [ 03/Dec/13 ]

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

Comment by Marco Pivetta [ 03/Dec/13 ]

Provided a cleaned up version at https://github.com/doctrine/annotations/pull/18





[DCOM-118] [GH-195] Add failing test to demonstrate parse error when @ is present in the description Created: 02/Oct/12  Updated: 25/Mar/14

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

Type: Bug Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

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

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

Message:

If someone can take this and fix the issue it'd be great. I couldn't figure it out at a quick glance and I don't really have time, but it's a pretty messed up bug and not so trivial to debug if you don't know what happens in the background so I'd say it's pretty important.



 Comments   
Comment by Philipp Scheit [ 02/Oct/12 ]

I digged a little deeper. The test case is a great one
The DocLexer cuts ut -1 position from the first @ (which is the @ in the @example.com). so that the lexer has to process:

o@example.com"
     * }
     *
     * @AnnotationTargetPropertyMethod("Bar")

So that the catchable pattern: ("(?:[^"]|"")*") matches here to greedy (it matches string in quotes):

"
     * }
     *
     * @AnnotationTargetPropertyMethod("

As a result the lexer does not catch the correct @ from the Annotation

I could not think of a fast fix for this. But maybe tomorrow.
(leaving quoted string pattern with an @ was a wrong idea)

Its not a workaround to do more or less cutting in the parser, because not-well-formed quoted strings would break anyway

Comment by Philipp Scheit [ 03/Oct/12 ]

can someone think of a case, where a string (in some annotation) has a newline in it? Otherwise the tests do not fail, when I leave the string matching pattern with a newline.
I still had another idea to restrict the position of a annotation more strictly to:

  • the beginning of a new line (\s**\s* before)
  • in another annotation

but the second is not solvable with the lexer itself and would transfer the quoted string matching to the parser, because it needs context.

I'll let seldaek pull, what I have (is this the right way?)

Comment by Marco Pivetta [ 03/Dec/13 ]

PR @ https://github.com/doctrine/annotations/pull/17

Comment by Doctrine Bot [ 25/Mar/14 ]

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





[DCOM-104] Dump() has side-effects or is unreliable Created: 02/Aug/12  Updated: 11/Jan/13

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

Type: Bug Priority: Major
Reporter: Tom Vogt Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Debian Squeeze, MySQL 5



 Description   

after setting a one-to-one bi-directional relationship, I am hunting a bug and trying this:

\Doctrine\Common\Util\Debug::Dump($this->lord, 1);
\Doctrine\Common\Util\Debug::Dump($this, 2);
\Doctrine\Common\Util\Debug::Dump($this->lord, 1);

The first Dump() shows $this->lord as being NULL.
The third Dump() shows it as NOT being null, just like the 2nd one also shows it as having a value.



 Comments   
Comment by Tom Vogt [ 02/Aug/12 ]

More analysis found the issue being caused by an overloaded setLord() method:

public function setLord($NewLord) {
// overwriting the setter because we also want to update the lord days counter
if ($NewLord!=$this->lord)

{ $this->lord->setFief(null); // this is the line causing the issue if ($NewLord) $NewLord->setFief($this); $this->lord = $NewLord; $this->lordDays = 0; }

return $this;
}

without the marked line, everything works as expected, but of course the inverse side doesn't get updated without it.

Comment by Tom Vogt [ 02/Aug/12 ]

it ate the newlines in the comment above. The problematic line is:

$this->lord->setFief(null);

i.e. the update of the inverse side.

Comment by Christophe Coevoet [ 07/Aug/12 ]

I confirm that the dump command has some side effects. It initializes the persistent collections too

Comment by Tom Vogt [ 11/Jan/13 ]

Could this for the time being be fixed with a notice in the documentation warning of possible side-effects of Dump() ?





[DCOM-92] CouchDB, MongoDB caches Created: 25/Dec/11  Updated: 25/Dec/11

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

Type: New Feature Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Very simple persisntent caches for query/view results now that result cache is actually useful






[DCOM-80] Add common exceptions into Doctrine\Common Created: 19/Nov/11  Updated: 20/Dec/11

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

Type: Improvement Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Following the ZF and SF2 Standard for Exceptions we should have base exceptions in Common






[DCOM-77] add a method to force removal of any unmapped data on flush for a given object Created: 16/Nov/11  Updated: 16/Nov/11

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

Type: New Feature Priority: Major
Reporter: Lukas Kahwe Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

in order to ensure that any unmapped fields are set to their defaults or removed in the case of nosql right now there is no way to do this except with 2 flush calls: aka remove+flush, persist+flush

there should be some way to do this in one flush






[DCOM-74] Ideas for Event Manager Improvements Created: 31/Oct/11  Updated: 06/Feb/13

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

Type: Improvement Priority: Major
Reporter: Johannes Schmitt Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

I have two ideas for improving the event manager.

1. Add a lazy-loading implementation as we discussed on IRC already (helpful for keeping the overhead of post generation schema listener down for example)
2. Providing better debugging information of what is going on (which listeners have been called for which event, similar to Symfony2's event dispatcher)



 Comments   
Comment by Guilherme Blanco [ 16/Jan/12 ]

I'm still a huge fan of DOM2 Events.

I even have the code somewhere here, but that would break BC.

Comment by Marijn Huizendveld [ 06/Feb/13 ]

Would you care to elaborate on your DOM2 Events implementation Guilherme?





[DCOM-73] CodeGeneration using Doctrine\Common\Persistence\Mapping\ObjectMetadata Created: 24/Oct/11  Updated: 03/Dec/13

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

Type: New Feature Priority: Major
Reporter: Benjamin Eberlei Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Currently we have tons of code in the ODM/ORMs regarding code generation that are ugly to extend and maintain. We should extract all them into a new component, for example named: doctrine-code-generator

  • It should be feed by only instances of Doctrine\Common\Persistence\Mapping\ObjectMetadata into a twig template.
  • A base template for an entity/document is shipped
  • Maybe ORM/ODM specific child templates or twig traits are necessary to handle writing annotations. This could also be done by adding hooks into the code-generation somehow.
  • Each entity of the user can provide its own template, for examples from a configurable directory "code_templates/Vendor.ProjectBundle.Entity.User.twig" to extend the base template and add own code.
  • As a perspective we should aim for 5.4 generating a trait so that you can have your entity "class User { use UserBase; }

    "






[DCOM-67] Introduce immutable DateTime with __toString() Created: 27/Aug/11  Updated: 29/Jan/12

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

Type: Improvement Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Comments   
Comment by Benjamin Eberlei [ 27/Aug/11 ]

Implemented

Comment by Koji Ando [ 11/Jan/12 ]

Though it is implemented once on https://github.com/doctrine/common/commit/7140ad3ba0ba2a94238976dd7f310ff92b478c96,
the class is removed on https://github.com/doctrine/common/commit/f845c1e267abf9069422eba8addfa976bc8d8685.

I think this issue must be reopened.

Comment by Benjamin Eberlei [ 11/Jan/12 ]

Code was removed due to implementation problems.





[DCOM-33] Allow to register callbacks in the EventManager Created: 01/Jan/11  Updated: 01/Jan/11

Status: Open
Project: Doctrine Common
Component/s: Event System
Affects Version/s: None
Fix Version/s: None

Type: New Feature Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Comments   
Comment by Benjamin Eberlei [ 01/Jan/11 ]

Consider to add a second queue for callbacks. Its not possible to simulate this by doing something like:

public function addCallbackListener($event, Closure $callback)
{
    $eventListener = new stdClass();
    $eventListener->$event = $callback;
    $this->addEventListener($event, $eventListener);
}

sad





[DCOM-238] FileCache does not remove directories on flush Created: 21/Mar/14  Updated: 21/Mar/14

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

Type: Bug Priority: Minor
Reporter: Ryan Korczykowski Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Windows 7



 Description   

FileCache::doFlush() does not remove the directories that store the cache file. The cache file is correctly deleted. This results in hundreds of hanging directories when the cache is flushed / rebuilt.

The version of doctrine/cache is 1.3.0.



 Comments   
Comment by Marco Pivetta [ 21/Mar/14 ]

This is likely because of the iterator skipping directories:

https://github.com/doctrine/cache/blob/36c4eee5051629524389da376ba270f15765e49f/lib/Doctrine/Common/Cache/FileCache.php#L120-L122





[DCOM-233] Support for class constant annotations Created: 05/Feb/14  Updated: 05/Feb/14

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

Type: New Feature Priority: Minor
Reporter: Steve Müller Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

I need to read annotations for class constants which currently is not possible. Obviously there is a good reason for that because PHP lacks a native ReflectionConstant class. Still sometimes this would be really useful and there are custom reflection implementation out there such as the PHP-Token-Reflection library (https://github.com/Andrewsville/PHP-Token-Reflection) which provide a class for that purpose.
Now the problem is that there is no way to extend the annotation reader to add support for this purpose without having to duplicate a lot of code. This is due to the annotation parser being private in the annotation reader and Doctrine not providing a Target::TARGET_CONSTANT.
If we could decide on supporting this, there are two options IMO:

1. Provide a ReflectionConstant interface in the core and add getConstantAnnotation(ReflectionConstant $constant, $annotationName) and getConstantAnnotations(ReflectionConstant $constant) to the Reader interface in conjunction with an AbstractReader class to throw an exception when calling those methods (to preserve BC).

2. Extend AnnotationReader to provide a final protected getParser() method for better extensibility so that one can subclass the annotation reader without heavy code duplication.

In both cases an addition of Target::TARGET_CONSTANT would desirable.

Currently I have to workaround this is in a very ugly manner by extending \ReflectionClass to access ReflectionConstant objects provided by PHP-Token-Reflection library and wrapping them into objects that emulate \ReflectionProperty, just to be able to use the annotation reader.

Do you think there is any solution to this which we can provide in Doctrine annotations lib?






[DCOM-224] If @ManyToOne targetEntity contains class name with double slashes, "Cannot redeclare class" error is raised Created: 30/Nov/13  Updated: 14/Dec/13

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

Type: Improvement Priority: Minor
Reporter: Ville Mattila Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

If @ManyToOne (and apparently any other association annotation) contains targetEntity with "wrongly" defined fully qualified class name in format like My\\Entity
Class, Fatal error "Cannot redeclare class" is raised when running command to generate schema.

It would be more intuitive (and save some debugging hours if a proper exception of wrongly defined class name would be raised.



 Comments   
Comment by Luis Cordova [ 14/Dec/13 ]

i haven't tried annotations yet but in yml and on master this gives me:

[Doctrine\ORM\Mapping\MappingException]
The target-entity Acme\DemoBundle\Entity\UserX cannot be found in 'Acme\DemoBundle\Entity\Category#users
'.

let me try annotations ...

Comment by Luis Cordova [ 14/Dec/13 ]

yeah this should be pretty much closed @ocramius @beberlei

Comment by Luis Cordova [ 14/Dec/13 ]

https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php#L945

Comment by Marco Pivetta [ 14/Dec/13 ]

Copied comment from 2844:

The issue should try to create a mapping of the kind

@ManyToOne(targetEntity="Foo\\Bar")

explicitly using two backslashes in the namespace seperator and try if an error occurs. This might be autoloader and Operating System dependent. Even if there is no error, we should fix "Doctrine\ORM\Mapping\ClassMetadataInfo" to replace double backslashes everywhere with one backslash correctly. This affects targetEntity and DiscrimnatorMap.

Comment by Marco Pivetta [ 14/Dec/13 ]

I'd rather throw an exception to warn the user about the abuse of backslashes.

Comment by Marco Pivetta [ 14/Dec/13 ]

Moved to doctrine common, since it's an issue with how metadata is being loaded when referenced

Comment by Marco Pivetta [ 14/Dec/13 ]

Provided a hotfix at https://github.com/doctrine/common/pull/309





[DCOM-214] Collection Criteria isNull does not work well Created: 12/Sep/13  Updated: 12/Sep/13

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

Type: Bug Priority: Minor
Reporter: Jan Pecek Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: collection, criteria, expression
Environment:

PHP 5.4.4, PostgreSQL 9.1



 Description   

I'm using the Collection project https://github.com/doctrine/collections and its Criteria building part. I'm not sure if I'm putting this bug to the good project. Please, correct me if not.

There is bug in method isNull: https://github.com/doctrine/collections/blob/master/lib/Doctrine/Common/Collections/ExpressionBuilder.php#L125

This produces SQL command where is 'IS ?' and null value is passed as param. This is fail.

Code example:

  $expr = Criteria::expr();
  $criteria = Criteria::create()
	->where($expr->lte('num', 42))
	->andWhere($expr->isNull('deleted'));
  return $this->myCollection->matching($criteria);

This produces SQL:

 SELECT ... FROM ... WHERE num <= ? AND deleted IS ? 

with params

[ 42, null ]





[DCOM-205] Missing filenames from exception messages Created: 01/Jul/13  Updated: 01/Jul/13

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

Type: Improvement Priority: Minor
Reporter: Igor Wiedler Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   
  • Doctrine\Common\Persistence\Mapping\MappingException
  • "File mapping drivers must have a valid directory path, however the given path seems to be incorrect!"

This would be more helpful if it included a path name. There are probably other similar exceptions affected as well, so you might want to adjust others too.






[DCOM-191] Wrong inflection for "identity" Created: 07/May/13  Updated: 07/May/13

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

Type: Bug Priority: Minor
Reporter: Tom Vogt Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None
Environment:

OS X and Linux, PHP 5.4.x



 Description   

console doctrine:generate:entities

For an association named "identities", the code generator creates the two methods
addIdentitie() and removeIdentitie() - apparently the inflector doesn't catch that it should be addIdentity and removeIdentity.






[DCOM-189] Doctrine Proxies may conflict with interfaced constructors Created: 03/May/13  Updated: 18/Dec/13

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

Type: Improvement Priority: Minor
Reporter: Harmen M Assignee: Marco Pivetta
Resolution: Unresolved Votes: 0
Labels: None


 Description   

The Doctrine ProxyGenerator generates for a proxy a constructor. The documentation of Doctrine states that the constructor is never called. For a project, I created a group of entities with a interfaced constructor in order to enforce a common interface. This results in a incompatible proxy and so a fatal error.



 Comments   
Comment by Marco Pivetta [ 03/May/13 ]

Cannot fix this - the constructor is required to override instantiation logic

Comment by Harmen M [ 03/May/13 ]

Edit: added the correct description. I accidentially submitted the form before editing the description.

Comment by Marco Pivetta [ 03/May/13 ]

Harmen M why do you have a constructor in an interface? That's a very bad practice, and it makes things quite hard to handle.

I can think of a workaround, but I first want to be sure there's a real advantage in changing the current implementation to use

unserialize()

just to handle this specific use case.

Comment by Benjamin Eberlei [ 03/May/13 ]

Adding __construct to an interface is an anti pattern and shouldn't be done.

Comment by Harmen M [ 03/May/13 ]

Ok, then I change my implementation.

But, maybe it is an idea to update the documentation of the ORM and state that constructor interfacing is not possible?
http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/architecture.html

Comment by Marco Pivetta [ 18/Dec/13 ]

I actually had more requests for this feature on a similar project ( https://github.com/Ocramius/ProxyManager/issues/115 ).
I will mark this as feature request, but can't guarantee that it will get into Doctrine 2.x, since it may be a BC break.





[DCOM-168] ignoredAnnotationNames doesn't work in Annotation loop Created: 27/Jan/13  Updated: 27/Jan/13

Status: Open
Project: Doctrine Common
Component/s: Annotations
Affects Version/s: 2.3
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: James S Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Mac OSX 10.6.8



 Description   

I'm just starting out with Doctrine, so my setup is a bit messy, but hopefully someone can figure out what is relevant from all my code.

Basically, I'm using Annotations on Doctrine ORM, and am integrating with Gedmo for several of their extensions.

I can run the CLI tool and update the schema, but when running via my web server, I'm getting the following error:

object(Doctrine\Common\Annotations\AnnotationException)[150]
  protected 'message' => string '[Semantical Error] The annotation "@Entity" in class Innertube\Models\Device was never imported. Did you maybe forget to add a "use" statement for this annotation?' (length=163)
  private 'string' (Exception) => string '' (length=0)
  protected 'code' => int 0
  protected 'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/common/lib/Doctrine/Common/Annotations/AnnotationException.php' (length=211)
  protected 'line' => int 52
  private 'trace' (Exception) => 
    array
      0 => 
        array
          'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/common/lib/Doctrine/Common/Annotations/DocParser.php' (length=201)
          'line' => int 592
          'function' => string 'semanticalError' (length=15)
          'class' => string 'Doctrine\Common\Annotations\AnnotationException' (length=47)
          'type' => string '::' (length=2)
          'args' => 
            array
              ...
      1 => 
        array
          'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/common/lib/Doctrine/Common/Annotations/DocParser.php' (length=201)
          'line' => int 533
          'function' => string 'Annotation' (length=10)
          'class' => string 'Doctrine\Common\Annotations\DocParser' (length=37)
          'type' => string '->' (length=2)
          'args' => 
            array
              ...
      2 => 
        array
          'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/common/lib/Doctrine/Common/Annotations/DocParser.php' (length=201)
          'line' => int 297
          'function' => string 'Annotations' (length=11)
          'class' => string 'Doctrine\Common\Annotations\DocParser' (length=37)
          'type' => string '->' (length=2)
          'args' => 
            array
              ...
      3 => 
        array
          'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/common/lib/Doctrine/Common/Annotations/AnnotationReader.php' (length=208)
          'line' => int 151
          'function' => string 'parse' (length=5)
          'class' => string 'Doctrine\Common\Annotations\DocParser' (length=37)
          'type' => string '->' (length=2)
          'args' => 
            array
              ...
      4 => 
        array
          'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/common/lib/Doctrine/Common/Annotations/CachedReader.php' (length=204)
          'line' => int 86
          'function' => string 'getClassAnnotations' (length=19)
          'class' => string 'Doctrine\Common\Annotations\AnnotationReader' (length=44)
          'type' => string '->' (length=2)
          'args' => 
            array
              ...
      5 => 
        array
          'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php' (length=205)
          'line' => int 61
          'function' => string 'getClassAnnotations' (length=19)
          'class' => string 'Doctrine\Common\Annotations\CachedReader' (length=40)
          'type' => string '->' (length=2)
          'args' => 
            array
              ...
      6 => 
        array
          'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php' (length=202)
          'line' => int 112
          'function' => string 'loadMetadataForClass' (length=20)
          'class' => string 'Doctrine\ORM\Mapping\Driver\AnnotationDriver' (length=44)
          'type' => string '->' (length=2)
          'args' => 
            array
              ...
      7 => 
        array
          'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php' (length=228)
          'line' => int 302
          'function' => string 'doLoadMetadata' (length=14)
          'class' => string 'Doctrine\ORM\Mapping\ClassMetadataFactory' (length=41)
          'type' => string '->' (length=2)
          'args' => 
            array
              ...
      8 => 
        array
          'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php' (length=228)
          'line' => int 205
          'function' => string 'loadMetadata' (length=12)
          'class' => string 'Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory' (length=64)
          'type' => string '->' (length=2)
          'args' => 
            array
              ...
      9 => 
        array
          'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/orm/lib/Doctrine/ORM/EntityManager.php' (length=187)
          'line' => int 268
          'function' => string 'getMetadataFor' (length=14)
          'class' => string 'Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory' (length=64)
          'type' => string '->' (length=2)
          'args' => 
            array
              ...
      10 => 
        array
          'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/orm/lib/Doctrine/ORM/EntityManager.php' (length=187)
          'line' => int 682
          'function' => string 'getClassMetadata' (length=16)
          'class' => string 'Doctrine\ORM\EntityManager' (length=26)
          'type' => string '->' (length=2)
          'args' => 
            array
              ...
      11 => 
        array
          'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/api/routes/devices.php' (length=108)
          'line' => int 16
          'function' => string 'getRepository' (length=13)
          'class' => string 'Doctrine\ORM\EntityManager' (length=26)

The call that initiates this is getRepository(), which IS NOT in the CLI.

I've tracked it down to the fact that DocParser is not getting the list of names to ignore.

Oddly, it gets it the first time that it's called by AnnotationReader. However, DocParser->parse() calls $this->Annotations(), which calls $this->Annotation(), calls $this->collectAnnotationMetadata(), which then creates a new parser

self::$metadataParser = new self();

and eventually parses it

self::$metadataParser->parse()

, but DOES NOT pass its ignorednames.

This seems like an oversight, but it clearly works for a lot of people. My configuration code is:

                if (self::$isDevMode) {
			$cache = new \Doctrine\Common\Cache\ArrayCache;
		} else {
			$cache = new \Doctrine\Common\Cache\ApcCache;
		}

		\Doctrine\Common\Annotations\AnnotationReader::addGlobalIgnoredName('package');

		AnnotationRegistry::registerFile(__DIR__ . "/vendor-composer/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php");
		\Gedmo\DoctrineExtensions::registerAnnotations();

		

		$annotationReader = new \Doctrine\Common\Annotations\AnnotationReader();
		$cachedAnnotationReader = new \Doctrine\Common\Annotations\CachedReader($annotationReader, $cache);



		$annotationDriver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($cachedAnnotationReader, self::$namespaceArray);

		$config = new \Doctrine\ORM\Configuration;
		$config->setProxyNamespace('Proxy');
		$config->setAutoGenerateProxyClasses(self::$isDevMode); // this can be based on production config.
		// register metadata driver
		$config->setMetadataDriverImpl($annotationDriver);
		// use our allready initialized cache driver
		$config->setMetadataCacheImpl($cache);
		$config->setQueryCacheImpl($cache);

		if (defined('DIR_FILES_CACHE')) {
			$config->setProxyDir(DIR_FILES_CACHE);
		} else {
			$config->setProxyDir(sys_get_temp_dir());
		}

		// create event manager and hook prefered extension listeners
		$evm = new \Doctrine\Common\EventManager();

		$prefix = new TablePrefix(null);
		$prefix->useNamespace(true);
		$evm->addEventListener(\Doctrine\ORM\Events::loadClassMetadata, $prefix);


		$blameableListener = new \Gedmo\Blameable\BlameableListener();
		$blameableListener->setAnnotationReader($config->getMetadataDriverImpl()->getReader());
		//class_exists makes this usable with the command-line
		if (class_exists('\User') && ($u = new \User()) != false) {
			$blameableListener->setUserValue($u->getUserID());
		}
		$evm->addEventSubscriber($blameableListener);


		$timestampableListener = new \Gedmo\Timestampable\TimestampableListener();
		$timestampableListener->setAnnotationReader($config->getMetadataDriverImpl()->getReader());
		$evm->addEventSubscriber($timestampableListener);

		$config->addFilter('soft-deleteable', '\Gedmo\SoftDeleteable\Filter\SoftDeleteableFilter');


		return EntityManager::create($connectionOptions, $config, $evm);

and the entity is (which sets up the repository) is:

namespace Innertube\Models;
defined('C5_EXECUTE') or die('Access Denied.');

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

/**
 * @ORM\Entity(repositoryClass="DeviceRepository") @ORM\Table(name="Devices")
 * @Gedmo\SoftDeleteable(fieldName="deletedOn")
 **/
class Device {

and the repository is:

namespace Innertube\Models;
defined('C5_EXECUTE') or die('Access Denied.');

use Doctrine\ORM\EntityRepository;

class DeviceRepository extends EntityRepository {





[DCOM-130] Paths in Doctrine\Common\Cache\FileCache could create large directory indexes Created: 23/Oct/12  Updated: 05/Jul/13

Status: Open
Project: Doctrine Common
Component/s: Caching
Affects Version/s: 2.3
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: R Churchill Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Any



 Description   

The way paths are created within FileCache currently, there is a theoretical maximum of 16^12 directories in the cache directory, which is quite a large number. Usually schemes like this are used to restrict the number of files in one directory.

Comparing with git, for example, the dirs are arranged

00/
1c/
...
ff/

and then the object store within those directories, which is a lot more manageable, say if you happen to type ls in the cache directory, you will get a maximum listing of 256 dirs. PhpThumb does something similar when caching images.

How about something like this for getFilename():

$idHash = md5($id);
$path = substr($idHash, 0, 2) . DIRECTORY_SEPARATOR . substr($idHash, 2, 2) . DIRECTORY_SEPARATOR . substr($idHash, 4);
$path = $this->directory . DIRECTORY_SEPARATOR . $path;

return $path . $id . $this->extension;

Not nearly so elegant, but I think this has better properties for the file system. Also I would be tempted to use one of the sha family hashes and not to include the $id within the filename, but perhaps this is helpful for debugging?



 Comments   
Comment by Julian Higman [ 10/May/13 ]

We hit this problem in a live system - with a lot of cached items, the number of subdirectories that FileCache creates can exceed the number that an ext3 filesystem allows in a single directory (about 32000).

After that, an attempt to cache a new item can get an error like this:

mkdir() [function.mkdir]: Too many links

Our solution was similar to that suggested:


    protected function getFilename($id) {
        $path = implode(str_split(md5($id), 2), DIRECTORY_SEPARATOR);
        $path = $this->directory . DIRECTORY_SEPARATOR . $path;
        return $path . DIRECTORY_SEPARATOR . $id . $this->extension;
    }

It splits the md5 of the item id into parts of length 2, rather than the original 12. This creates a deeply nested structure, but which won't ever exceed the limit on number of subdirectories in any one directory. It's the same subdirectory pattern used by default by Apache mod_disk_cache, as well.

Comment by Julian Higman [ 05/Jul/13 ]

After a couple of months in production, we ran into another problem with this - we reached the maximum number of inodes in the fielsystem.

The resulting errors look like this:

mkdir() [function.mkdir]: No space left on device

There is actually disk space left, but looking at the inodes shows that the limit has been hit:

-bash-3.2# df -i
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/sda1 6553600 6553600 0 100% /

The creation of directories and subdirectories can be constrained slightly by using 3 instead of 2 characters (with hex chars, that will give max of 16^3 = 4096 subdirectories per directory, still less than the ext3 limit of 32000)

$path = implode(str_split(md5($id), 2), DIRECTORY_SEPARATOR);

but ultimately the inodes will still all be used up.

The only other options are pruning the cache at intervals, or switching to a different caching strategy altogether.

Comment by Marco Pivetta [ 05/Jul/13 ]

Julian Higman I'd suggest file-based caching mechanisms are not suited for that environment. The file cache is really meant for all those environments where there's strict constraints (like shared hosting).





[DCOM-129] Annotation parser matches colon after annotation Created: 21/Oct/12  Updated: 21/Oct/12

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

Type: Bug Priority: Minor
Reporter: Konstantin Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Code

/**
* Removes given $node from the tree and reparents its descendants
*
* @todo may be improved, to issue single query on reparenting
* @param object $node
* @throws RuntimeException - if something fails in transaction
* @return void
*/
public function removeFromTree($node)
{

fails with `[Semantical Error] The annotation "@todo:" in method Gedmo\Tree\Entity\Repository\ClosureTreeRepository::removeFromTree() was never imported. Did you maybe forget to add a "use" statement for this annotation?`.

As you see it tryes find annotation with name "@todo:". Don't know, maybe rtrim($name, ':') would enough.






[DCOM-28] Extract Common Persistance Interfaces Created: 13/Oct/10  Updated: 30/Jul/11

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

Type: New Feature Priority: Minor
Reporter: Benjamin Eberlei Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None

Attachments: File dcom_persistence.diff    
Issue Links:
Duplicate
is duplicated by DCOM-23 Add interface for ObjectManager Resolved

 Description   

I discussed this with jwage on symfony day cologne and this also came up during discussions with @dzuelke at IPC yesterday. So i hacked up a first patch for discussion that adds a Doctrine\Common\Persistance namespace and extracts the functionality all our 3 layers implement with regards to EntityManager/EntityRepository (and equivalents).

Additionally i think it might make sense to also add an interface "ObjectMetadata" that has several getters-only that allow access to the field, identifier and association mapping information. This stuff is not necessarly compatible across layers when returned as its "array" representation, but for libraries hooking into the metadata (symfony admin generator) this might not even be necessary.



 Comments   
Comment by Jonathan H. Wage [ 15/Feb/11 ]

Added the interfaces here https://github.com/doctrine/common/commit/59e6b8c6edcb271622923035b687a063c2b47ce8

I implemented them here in the mongodb-odm https://github.com/doctrine/mongodb-odm/commit/8d02e8439fb6737de1e23e1953a643858a8a6c68

and the ORM https://github.com/doctrine/doctrine2/commit/68a40996841b1dbec3b8de5c1038809e5db512b7

I think we can add a few more methods to ClassMetadata interface that are always gonna exist between the different persistence layers. Let me know what you think and what you want to add.

Comment by Guilherme Blanco [ 15/Feb/11 ]

Jon is working on this.

Comment by Lukas Kahwe [ 19/Mar/11 ]

CouchDB ODM also has DocumentRepositry::findMany(array $ids)
Should we add that to the interface?

Comment by Benjamin Eberlei [ 19/Mar/11 ]

No, that method is only on the repository because CouchDB doesn't need persisters (yet). Its not part of the interfaceable public methods.

Comment by Lukas Kahwe [ 19/Mar/11 ]

Not sure I understand. The method is used in DocumentRepository::findBy() as well as in PersistentIdsCollection::load. Seems unnecessary for that method to be public just for this. At any rate imho the method seems convenient and also allows for more efficient access in many RDBMS compared to the generic findBy($criteria) method. So it seems worthwhile adding it.

Comment by Benjamin Eberlei [ 20/Mar/11 ]

It doesn't matter what CouchDB uses internally on the DocumentRepository, i don't think this method is particularly useful in another context than CouchDBs use of Collections. In any case the method is just a proxy for findBy(array("id" => array(1, 2, 3, 4, 5, 6))); and i am not sure we need such a method on an interface just for convenience, Repository::find() use-case is much broader.

Comment by Lukas Kahwe [ 20/Mar/11 ]

Actually using findMany($ids) ias clearly more efficient in CouchDB than using findBy(array("id" => $ids));
The same applies to PHPCR, since going by the node path means you can go via the normal node API, rather than the search API.
So this is already 2 out of 3 examples and I do not know MongoDB enough to tell if they also have some specific API advantage.

Comment by Benjamin Eberlei [ 20/Mar/11 ]

Hm, you might be right. Ok, this should be included.

What i am still pondering with is adding array $orderBy and $firstResult, $maxResults to findOneBy() and findBy() and findAll().

@Jon: Would this be possible for MongoDB?

It would not be possible for all use-cases in CouchDB, but for some it can work.

Comment by Lukas Kahwe [ 20/Mar/11 ]

Just a super trivial pull to add this to the interface:
https://github.com/doctrine/common/pull/11

Comment by Lukas Kahwe [ 21/Mar/11 ]

also wondering if we want to include the idgenerator API in the interface?

Comment by Benjamin Eberlei [ 21/Mar/11 ]

Hm yes, i think that is necessary. At least the differentation between assigned and auto-generated ids is relevant for metadata queries.

Comment by Jonathan H. Wage [ 21/Mar/11 ]

Yes, findMany() is possible with MongoDB.

I think it would just be a proxy to:

public function findMany(array $ids)
{
    return $this->findBy(array('_id' => array('$in' => $ids)));
}
Comment by Benjamin Eberlei [ 21/Mar/11 ]

Hm, What is this syntax? This is not conforming to the EntityRepository interface.

The only two allowed methods are:

IN Query:

$ids = array(...);
findBy(array('_id' => $ids)); 

Equals = Query:

$ids = 1234;
findBy(array('_id' => $id)); 

Everything else is not portable accross implementations and should only be able through DocumentManager::CreateQuery* sort of apis.

Comment by Jonathan H. Wage [ 21/Mar/11 ]

To find by things in MongoDB you just give an array of key => value pairs. It gets passed straight through to MongoDB. The $in syntax is just soemthing mongodb supports. It's not anything specific to Doctrine.

Comment by Lukas Kahwe [ 30/Jul/11 ]

i want to heat this topic back up:

  • findMany()
  • id generator API




[DCOM-229]  DocParser - add support for php5 MyClass::class call to get path of the class Created: 06/Jan/14  Updated: 06/Jan/14

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

Type: Bug Priority: Trivial
Reporter: Umed Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

When I try to use in my annotations

 
Career::class

I get Semantical Error. Career is imported, so I dont want to use full class path name again. How about to add this feature to support by annotations?
We need to add some code like this (DocParser#Constant):

 
            if ($found) {
                 if ($const === 'class') {
                    return $className;
                 }

                 $identifier = $className . '::' . $const;
            }
        }

        if (!defined($identifier)) {
            throw AnnotationException::semanticalErrorConstants($identifier, $this->context);
        }

        return constant($identifier);





[DCOM-207] Add AnnotationReader::getFunctionAnnotations() Created: 09/Jul/13  Updated: 09/Jul/13

Status: Open
Project: Doctrine Common
Component/s: Annotations
Affects Version/s: 2.3
Fix Version/s: None

Type: New Feature Priority: Trivial
Reporter: Benjamin Morel Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Currently, the annotation reader supports reading annotations on class, method and property.
This could be extended to read annotations on any kind of function, by adding the following methods:

public function getFunctionAnnotations(\ReflectionFunctionAbstract $function);
public function getFunctionAnnotation(\ReflectionFunctionAbstract $function, $annotationName);

This could be done without breaking BC in the following ways:

  • Keep the Reader interface as it is
  • Add a new interface, for example FullReader, that would extend Reader to add these two methods
  • Add the new methods to AnnotationReader, CachedReader, etc.
  • Update these classes to implement FullReader; thus they would still implement Reader and stay compatible.

Then, on the next major release (3.0.0), we could:

  • Add the two methods to Reader
  • Remove FullReader
  • Add a note to the UPGRADE file to rename FullReader to Reader in application code.

In case you're wondering why I'm proposing this feature, I'm developing a lightweight framework, which allows any method, function, or closure to be used as a controller.
I can currently parse annotations when using a class method, but cannot provide support for annotations on the others.

That would be a great addition.
I've checked the code, and it looks like the only difficulty would be to parse "use" statements for the file where the function is declared, whereas for now it is always assumed that there is a class, and that the file name will be inferred from there. But as ReflectionFunctionAbstract provides a getFileName() method, it's technically feasible as well.

Let me know what you think!
If you have no objection to the concept, I can start working on a PR for this feature.






[DCOM-165] Entities seems not be recognized by AnnotationDriver Created: 02/Sep/12  Updated: 03/Dec/13

Status: Awaiting Feedback
Project: Doctrine Common
Component/s: Annotations
Affects Version/s: 2.2, 2.3
Fix Version/s: None

Type: Bug Priority: Trivial
Reporter: Maarten de Keizer Assignee: Marco Pivetta
Resolution: Unresolved Votes: 0
Labels: annotationdriver, realpath, symlink, windows
Environment:

Windows 7 Profesional, Enterprise and Windows Server 2003 and 2008; Common: 2.2.3 DBAL: 2.2.2 ORM: 2.2.3; PHP 5.4.5 and 5.3.5



 Description   

Problem:
--------
"$em->getMetadataFactory()->getAllMetadata()"
Will result in an empty array. The entitiy manager is correctly configured and the entities files are loaded (echo's in the files will be displayed).

Debug steps:
------------
Looking in the code for the problem I created the following debug points first:

file AnnotationDriver.php method getAllClassNames()
after the line: "$includedFiles[] = $sourceFile;"
add: "echo $sourceFile . ' is loaded' . PHP_EOL;"

file AnnotationDriver.php method getAllClassNames()
after the line: "$sourceFile = $rc->getFileName();"
add: "echo $className . ' is loaded from: ' . $sourceFile . ' in the includedFiles array? ' . (in_array($sourceFile, $includedFiles) ? 'YES' : 'not found ') . PHP_EOL;"

the following output will be displayed:
...
f:\workspace\nl.markei.posto-2.3\lib\relaties\Contact.php is loaded
...
nl\markei\posto\relaties\Contact is loaded from: F:\workspace\nl.markei.posto-2.3\lib\relaties\Contact.php in the includedFiles array? not found

It seems that Doctrine includes the file from f: but ReflectionClass say it is loaded from F:. The in_array() will fail and Doctrine will not recognized the entity.

But this is not the full problem. I created a new debug point:

file AnnotationDriver.php method getAllClassNames()
after the line: "foreach ($this->_paths as $path) {"
add: "echo 'path: ' . $path . ' after realpath: ' . realpath($path) . PHP_EOL;"

This will result in the following output:
"path: F:\domains\markei.nl\lib\nl.markei.posto\ after realpath: f:\workspace\nl.markei.posto-2.3\lib"

So the conversion of the F: to f: is done by realpath; its look like

A simple fix should be in AnnotationDriver.php / getAllClassNames()
replace: "$sourceFile = $rc->getFileName();"
by: "$sourceFile = realpath($rc->getFileName());"

After I did that, the problem still exists. So I add to echo's (one with realpath and one without at the part of the code). And both echo's result in a path starting with "F:".

So my first reaction was freaky!

After some frustrating hours I found the problem in the symlink I used.
"F:\domains\markei.nl\lib\nl.markei.posto" was a symlink to "f:\workspace\nl.markei.posto-2.3\lib" and realpath will not convert the driver char in the target of the symlink for some freaky reason. After changing the symlink target to "F:\workspace...." everything works fine.

Summary:
--------
realpath results are not consistent on Windows. This will resulting in problems under Windows.

Possible solutions:
-------------------
Saying "this is a PHP bug".
It is possible that there are more case sensitive problems hidding here on Windows. Maybe it is better to use (for Windows only!) a case insensitive in_array-alternative in AnnotationDriver.php getAllClassNames() (or convert all paths for to lowercase for Windows)



 Comments   
Comment by Marco Pivetta [ 23/Jan/13 ]

Maarten de Keizer looks like the issue is still there in doctrine/annotations. Are you able to come up with a failing test case?





Generated at Sun Apr 20 03:35:50 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.