partkeepr / PartKeepr

Open Source Inventory Management
http://www.partkeepr.org
GNU General Public License v3.0
1.38k stars 401 forks source link

Error while adding new parts #235

Closed fcobcn closed 12 years ago

fcobcn commented 12 years ago

It took me a while to setup partkeepr on a mac with 10.6.8 and MAMP. It worked fine until I rebooted my machine, now I can't create new parts, here's the full report:

SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (partkeepr.part, CONSTRAINT FK_E93DDFF812469DE2 FOREIGN KEY (category_id) REFERENCES PartCategory (id))

Exception

PDOException

Backtrace

PDOException

Request

{"method":"POST","headers":{"session":"34361e1cbf71b2057ddd13245edad62e"},"jsonData":{"id":0,"category":5,"footprint":0,"storageLocation":1,"partUnit":1,"averagePrice":0,"name":"sadasd","description":"","comment":"","status":"","stockLevel":0,"minStockLevel":0,"createDate":"","needsReview":false,"initialStockLevel":0,"initialStockLevelUser":0,"initialStockLevelPrice":0,"initialStockLevelPricePerItem":false,"partUnitName":"","footprintName":"","storageLocationName":"","categoryName":"","categoryPath":"","projects":"","internalPartNumber":"","attachmentCount":0,"partUnitDefault":false,"manufacturers":[],"parameters":[],"distributors":[],"attachments":[]}}

Response

{"status":"systemerror","success":false,"exception":{"message":"SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (partkeepr.part, CONSTRAINT FK_E93DDFF812469DE2 FOREIGN KEY (category_id) REFERENCES PartCategory (id))","exception":"PDOException","backtrace":"#0 \/Applications\/MAMP\/bin\/php\/php5.3.6\/lib\/php\/Doctrine\/DBAL\/Statement.php(131): PDOStatement->execute(NULL)\n#1 \/Applications\/MAMP\/bin\/php\/php5.3.6\/lib\/php\/Doctrine\/ORM\/Persisters\/BasicEntityPersister.php(239): Doctrine\DBAL\Statement->execute()\n#2 \/Applications\/MAMP\/bin\/php\/php5.3.6\/lib\/php\/Doctrine\/ORM\/UnitOfWork.php(896): Doctrine\ORM\Persisters\BasicEntityPersister->executeInserts()\n#3 \/Applications\/MAMP\/bin\/php\/php5.3.6\/lib\/php\/Doctrine\/ORM\/UnitOfWork.php(304): Doctrine\ORM\UnitOfWork->executeInserts(Object(Doctrine\ORM\Mapping\ClassMetadata))\n#4 \/Applications\/MAMP\/bin\/php\/php5.3.6\/lib\/php\/Doctrine\/ORM\/EntityManager.php(355): Doctrine\ORM\UnitOfWork->commit(NULL)\n#5 \/Applications\/MAMP PRO\/partkeepr\/src\/backend\/de\/RaumZeitLabor\/PartKeepr\/Manager\/AbstractManager.php(82): Doctrine\ORM\EntityManager->flush()\n#6 \/Applications\/MAMP PRO\/partkeepr\/src\/backend\/de\/RaumZeitLabor\/PartKeepr\/Part\/PartService.php(111): de\RaumZeitLabor\PartKeepr\Manager\AbstractManager->createEntity(Array)\n#7 \/Applications\/MAMP PRO\/partkeepr\/src\/backend\/de\/RaumZeitLabor\/PartKeepr\/Service\/ServiceManager.php(80): de\RaumZeitLabor\PartKeepr\Part\PartService->create()\n#8 \/Applications\/MAMP PRO\/partkeepr\/frontend\/rest.php(55): de\RaumZeitLabor\PartKeepr\Service\ServiceManager::call()\n#9 {main}"},"timing":0.0968461036682}

Server Configuration

doctrine_orm_version: 2.2.2 doctrine_dbal_version: 2.2.2 doctrine_common_version: 2.2.2 php_version: 5.3.6 maxUploadSize: 33554432 availableImageFormats: 3FR,A,AAI,AI,ART,ARW,AVI,AVS,B,BGR,BGRA,BMP,BMP2,BMP3,BRF,C,CAL,CALS,CANVAS,CAPTION,CIN,CIP,CLIP,CMYK,CMYKA,CR2,CRW,CUR,CUT,DCM,DCR,DCX,DDS,DFONT,DNG,DOT,DPX,EPDF,EPI,EPS,EPS2,EPS3,EPSF,EPSI,EPT,EPT2,EPT3,ERF,FAX,FITS,FRACTAL,FTS,G,G3,GIF,GIF87,GRADIENT,GRAY,GROUP4,HALD,HDR,HISTOGRAM,HRZ,HTM,HTML,ICB,ICO,ICON,INFO,INLINE,IPL,ISOBRL,JNG,JPEG,JPG,K,K25,KDC,LABEL,M,M2V,M4V,MAC,MAP,MAT,MATTE,MEF,MIFF,MNG,MONO,MOV,MP4,MPC,MPEG,MPG,MRW,MSL,MSVG,MTV,MVG,NEF,NRW,NULL,O,ORF,OTB,OTF,PAL,PALM,PAM,PANGO,PATTERN,PBM,PCD,PCDS,PCL,PCT,PCX,PDB,PDF,PDFA,PEF,PES,PFA,PFB,PFM,PGM,PICON,PICT,PIX,PJPEG,PLASMA,PNG,PNG24,PNG32,PNG8,PNM,PPM,PREVIEW,PS,PS2,PS3,PSB,PSD,PTIF,PWP,R,RADIAL-GRADIENT,RAF,RAS,RGB,RGBA,RGBO,RLA,RLE,SCR,SCT,SFW,SGI,SHTML,SR2,SRF,STEGANO,SUN,SVG,SVGZ,TEXT,TGA,THUMBNAIL,TIFF,TIFF64,TILE,TIM,TTC,TTF,TXT,UBRL,UIL,UYVY,VDA,VICAR,VID,VIFF,VST,WBMP,WEBP,WMV,WPG,X,X3F,XBM,XC,XCF,XPM,XPS,XV,XWD,Y,YCbCr,YCbCrA,YUV

Thanks!

Drachenkaetzchen commented 12 years ago

Have a look in your MySQL log - probably there's more insight. If that doesn't help, please provide a database dump and which version of PartKeepr you use.

fcobcn commented 12 years ago

I don't see nothing special on my MySQL error log:

120702 14:36:22 [Note] /Applications/MAMP/Library/bin/mysqld: Normal shutdown

120702 14:36:22 [Note] Event Scheduler: Purging the queue. 0 events 120702 14:36:22 InnoDB: Starting shutdown... 120702 14:36:22 InnoDB: Shutdown completed; log sequence number 13219412 120702 14:36:22 [Note] /Applications/MAMP/Library/bin/mysqld: Shutdown complete

120702 14:36:22 mysqld_safe mysqld from pid file /Applications/MAMP/tmp/mysql/mysql.pid ended 120702 14:36:25 mysqld_safe Starting mysqld daemon with databases from /Library/Application Support/appsolute/MAMP PRO/db/mysql 120702 14:36:25 [Warning] Setting lower_case_table_names=2 because file system for /Library/Application Support/appsolute/MAMP PRO/db/mysql/ is case insensitive 120702 14:36:25 [Note] Plugin 'FEDERATED' is disabled. 120702 14:36:25 InnoDB: The InnoDB memory heap is disabled 120702 14:36:25 InnoDB: Mutexes and rw_locks use GCC atomic builtins 120702 14:36:25 InnoDB: Compressed tables use zlib 1.2.3 120702 14:36:25 InnoDB: Initializing buffer pool, size = 128.0M 120702 14:36:25 InnoDB: Completed initialization of buffer pool 120702 14:36:25 InnoDB: highest supported file format is Barracuda. 120702 14:36:25 InnoDB: Waiting for the background threads to start 120702 14:36:26 InnoDB: 1.1.5 started; log sequence number 13219412 120702 14:36:26 [Note] Event Scheduler: Loaded 0 events 120702 14:36:26 [Note] /Applications/MAMP/Library/bin/mysqld: ready for connections. Version: '5.5.9' socket: '/Applications/MAMP/tmp/mysql/mysql.sock' port: 0 Source distribution

I'm using version 0.1.7

EDITED: dump is below

Drachenkaetzchen commented 12 years ago

Please don't put long stuff into a bug report - use a pastebin service, like http://paste.debian.net/ or one of the many other pastebin services.

fcobcn commented 12 years ago

Sorry for that, I'm a noob here. Here's the full MySQL dump. Thanks for your help.

http://pastebin.com/sKzzawze

Drachenkaetzchen commented 12 years ago

I've downloaded your dump and tested against it, it works for me. Can you try to restart your web server and see if the issue goes away?

fcobcn commented 12 years ago

Restarting does not fix the issue. I did some tests. I have created a second virtual host on the same machine, installed another copy of partkeepr fully configured. First run works OK, after doing a server reboot the same problem appeared. Pretty weird. Thanks for your help!

Drachenkaetzchen commented 12 years ago

This is very wierd - never seen such a behaviour, and I can't reproduce it.

fcobcn commented 12 years ago

Managed to solve it. For some reason my mac is not loading new ENV VARS, so it looks like I wasn't geting doctrine properly loaded. ". .profile" solved the problem. This is related to using MAMP, I had to tweak it a lot to get all the extensions working. Thanks for this great piece of software!

Drachenkaetzchen commented 12 years ago

I'm glad you've found the issue! It sounded very wierd :)