-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Warning: rename(...\var\cache\dev/doctrine/orm/Proxies\__CG__DemoProductBundleEntityProductBrand.php #6713
Comments
The issue is not with your code but with your dev environment. The error message points you toward the cache, which probably has the wrong permissions. You have to check your cache folder and fix the file permissions, but that may depend on what dev environment you have. |
@Jean85 i tried to set cache permission. after clear cache, this error message is disappeared. but it will be displayed again in few times. the development environment is windows. i got this error when use ajax to load some data from database. if i pause 1-2 seconds for ajax loading, this error will not be displayed again. |
I faced the same problem. It isn't because of permissions, it's because doctrine tries to regenerate proxies on each of ajax requests (in dev) and tries to write the file at the same time (multiple requests). Therefore some of requests are denied file access by OS. However I haven't this happen in quite a while now... Try updating both doctrine and symfony, maybe it was fixed at some point |
This issue as well as fix was documented here: doctrine/mongodb-odm#1495 The authors of the library know about this issue and proposed fix but chose not to implement it. |
We need a reproducible test case to fix this.
…On 1 Oct 2017 15:03, "Eugene Luzgin" ***@***.***> wrote:
This issue as well as fix was documented here: doctrine/mongodb-odm#1495
<doctrine/mongodb-odm#1495>
And here: doctrine/mongodb-odm#1495
<doctrine/mongodb-odm#1495>
The HydratorFactory kept exploding on my local Docker about 50% of the
time until I patched it locally by replacing single rename() operation with
with copy() followed by unlink().
The authors of the library know about this issue and proposed fix but
chose not to implement it.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#6713 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAJakPknoRwILITfBTnnyc1OPOIbHrhGks5sn42-gaJpZM4PeuP6>
.
|
Unfortunately I can not share my docker image since project source code is not mine. Details: |
Well aware of the error, just need a way to prevent regressions (test
automation)
…On 1 Oct 2017 15:23, "Eugene Luzgin" ***@***.***> wrote:
Unfortunately I can not share my docker image since project source code is
not mine.
Here is the screenshot of error however:
[image: image]
<https://user-images.githubusercontent.com/561618/31054884-46d6c8ac-a679-11e7-8f84-f77a4f24132a.png>
Details:
- in /var/www/trackingfirst/vendor/doctrine/mongodb-odm/lib/
Doctrine/ODM/MongoDB/Hydrator/HydratorFactory.php line 415
- at ErrorHandler->handle('2', 'rename(/var/www/
trackingfirst/app/cache/dev/doctrine/odm/mongodb/Hydrators/
TrackingFirstMainBundleDocumentOmnitureAccountHydrator.php.
59d0eb54bd23c1.56493991,/var/www/trackingfirst/app/cache/
dev/doctrine/odm/mongodb/Hydrators/TrackingFirstMainBundleDocumentOmnitureAccountHydrator.php):
Operation not permitted', '/var/www/trackingfirst/
vendor/doctrine/mongodb-odm/lib/Doctrine/ODM/MongoDB/Hydrator/HydratorFactory.php',
'415', *array*('class' => *object*(ClassMetadata), 'hydratorClassName' =>
'TrackingFirstMainBundleDocumentOmnitureAccountHydrator', 'fileName' =>
'/var/www/trackingfirst/app/cache/dev/doctrine/odm/mongodb/Hydrators/
TrackingFirstMainBundleDocumentOmnitureAccountHydrator.php', 'code' =>
'<?php
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#6713 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAJakGTIqax_UipxAL_S0w1M9FEQT_Soks5sn5JMgaJpZM4PeuP6>
.
|
Since you linked a pull request that suggested a change, allow me to also link the reason why I chose to not implement it: doctrine/mongodb-odm#1495 (comment).
One option would be to add a |
...to move a file without side effects. This gist reproduces the problem: https://gist.github.com/alcaeus/a367e895e6c55f7fb93870dcba46efa9 Same issue is fixed in a similary way in symfony core: symfony/symfony#12533 resolves doctrine/orm#6713
What's the best solution now? (while the ORM isn't updated yet) |
The solution that we used for our project was to apply this change locally - it worked for us: https://github.com/doctrine/mongodb-odm/pull/1495/files You mileage may vary. |
This has already been repeated twice in this thread. |
Yes, because an issue that stems from people misconfiguring their virtualised environments should be fixed with an untested patch that can have severe performance implications for everyone else. It can also cause fatal errors due to incomplete cache files being read while the copy operation is in progress. Let me also ask you to tone down your language a bit: we’ve repeatedly explained why the solution proposed for ODM doesn’t work in most instances and that the issue is not with our code but the configuration of the system. This is the second time you’re insinuating that we’re not fixing that out of malice, and I won’t have it. Bring a fix with reproducible test cases that show you’re not introducing regressions for users that aren’t affected by this issue in the first place, or fix it for yourself without potentially introducing issues for millions of other users. Thank you for understanding. |
I apologize if I have insinuated anyones feelings. May comment was made with just a bit of sarcasm but no insinuating intentions. Regardless, this is an old problem. If I was developer on this project I would code defensively and at least try to capture the error with rename (which happens on rare occasions) and try alternatives. Just my 2c. |
A solution provided in https://stackoverflow.com/questions/12894822/access-denied-error-on-rename-call-when-uploading-files-in-symfony was appropriate for me: private function renameWindowsCompatible($oldfile,$newfile) {
try {
rename($oldfile,$newfile);
} catch(\Exception $e) {
if (copy($oldfile,$newfile)) {
unlink($oldfile);
return TRUE;
}
return FALSE;
}
return TRUE;
} |
Check webimpress/safe-writer#1 and help with improving that - this is a common problem of atomic file writes done via rename, and needs extensive testing, but "hacking our own" in here ain't happening unless very carefully tested. Closing as "incomplete" here - please open a pull request if/when tests are part of a proposal. |
Same problem into vendor\doctrine\common\lib\Doctrine\Common\Proxy\ProxyGenerator.php:293. To test:
|
when i query entity with doctrine, i got this error message.
the query code:
$category = $this->getDoctrine()->getRepository('DemoProductBundle:Category')->find($nameId); $i = 0; $products = $this->getDoctrine()->getRepository('DemoProductBundle:Product')->findBy(array('porductCategory' => $category)); foreach ($products as $product) { dump($i); $i++; }
or
$category = $this->getDoctrine()->getRepository('DemoProductBundle:Category')->find($nameId); $i = 0; foreach ($category->getProducts() as $product) { dump($i); $i++; }
Error Message:
when i used mysql_query replace doctrine, it worked.
$host = $this->getParameter('database_host'); $user= $this->getParameter('database_user'); $password = $this->getParameter('database_password'); $database = $this->getParameter('database_name'); $con = mysql_connect($host, $user, $password); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db($database, $con); $sql = "SELECT * FROM demo_product WHERE category_id = $nameId"; // dump($sql); // exit(); $result = mysql_query($sql); $brandselect = "<option value='0'>please select...</option>"; while($row = mysql_fetch_object($result)) { $brandselect .= "<option value={$row->id}>{$row->title}</option>"; } mysql_close($con);
There are my yml files:
product.yml
`Demo\Bundle\ProductBundle\Entity\Product:
type: entity
table: demo_product
id:
id:
type: integer
nullable: false
options:
unsigned: true
id: true
generator:
strategy: IDENTITY
fields:
title:
type: string
nullable: true
length: 45
options:
fixed: false
sn:
type: string
nullable: true
length: 45
options:
fixed: false
excerpt:
type: string
nullable: true
length: 45
options:
fixed: false
description:
type: blob
nullable: true
length: 65535
options:
fixed: false
thumbnail:
type: string
nullable: true
length: 100
options:
fixed: false
pdf:
type: string
nullable: true
length: 100
options:
fixed: false
stock:
type: integer
nullable: true
options:
unsigned: false
price:
type: string
nullable: true
length: 45
options:
fixed: false
status:
type: string
nullable: true
length: 45
options:
fixed: false
created:
type: datetime
nullable: true
modified:
type: datetime
nullable: true
`
productBrand.yml
Demo\Bundle\ProductBundle\Entity\Brand: type: entity table: demo_product_brand id: id: type: integer nullable: false options: unsigned: true id: true generator: strategy: IDENTITY fields: name: type: string nullable: true length: 45 options: fixed: false #简称 Abbreviation: type: string nullable: true length: 45 options: fixed: false sn: type: string nullable: true length: 45 options: fixed: false description: type: string nullable: true length: 45 options: fixed: false thumbnail: type: string nullable: true length: 45 options: fixed: false created: type: datetime nullable: true modified: type: datetime nullable: true lifecycleCallbacks: { }
productCategory.yml
`Demo\Bundle\ProductBundle\Entity\ProductCategory:
type: entity
table: demo_product_category
`
what's wrong with my code? thanks.
The text was updated successfully, but these errors were encountered: