Nuclear option for deleting troublesome packages or blocks2 users found helpful
I have a c5 package that doesn't work and will not let me delete it. Any pages that have the block from the package in it will throw this error when viewed:
Fatal error: Call to a member function getAttributeKeyID() on a non-object in /c5root/updates/concrete5.6.1/concrete/core/models/file_version.php on line 556
When I do a "delete forever" of said infected page, it doesn't go away (no error given). When I try to unistall the package I get the same error above.
When I manually deleted the package files, that really messed things up. It brought down the whole site. I had to put the files back to make the site work again.
Soooo, at this point I'd like to just go in the DB and zap the proper tables and fields manually. But the C5 schema is not trivial, so I'm not sure how to go about this without breaking other things.
Here's my question:
Is there a standard way of removing packages and blocks directly from the database? Without using the C5 interface (in case C5 blows up)? If not, shouldn't there be?
A note about the package:
It's a free package from the C5 marketplace. I don't mind the random blowup from this price range. I don't blame the author, I'm happy people are making free stuff for C5.
Seems like the uninstall function might be broken.
I don't think it's the uninstall function. The error comes up when interacting with it in any way (adding to a page, viewing the page, deleting the page, uninstalling, etc.)
Installing works fine, heh.
I'm looking for a solution that would apply to any problematic package, not just the Amiant Image Gallery. I'm sure there will be other packages that cause (accidental) pain, so a general solution for deleting packages and blocks would be great for emergencies.
Outside of the C5 web interface, in case the C5 site is fubar.
Thanks for your help!
Nuclear Option for deleting packages and blocks
This should only be used if you are desperate, and you cannot delete using the concrete5 web interface. Your mileage may vary, your car (website) may spontaneously combust. You will need to know how to use MySQL directly to use these steps. These steps assume your package only has one block. Adjust your actions accordingly if your situation is different.
1. Look at the package's block's db.xml file(s) for table names. You'll need this later to clean up in the end.
2. Back up your database, put your site in maintenance mode, pray to your gods, etc.
3. Start up mysql, load up your database and find out the block ID of your problem block.
select btID,pkgName,pkgHandle,pkgID from BlockTypes;
Look at the names and make a note of the btID that applies to the problem block. Also make note of the pkgID.
4. Now for the destruction! Using the btID and pkgID from the previous step, delete thusly:
delete from Blocks where btID = "x"; delete from BlockTypes where btID = "x"; delete from Packages where pkgID = "y";
x is the btID number, y is the pkgID number.
5. Using the table name(s) you found in step #1, drop them:
drop table btSomeBlockThatCausesProblems; drop table btSomeBlockAlpha; drop table btSomeBlockBeta;
The number of tables and your table names may vary.
6. For the coup de grâce, delete the problem package directory manually from your /c5root/packages/ directory.
This was done on version 5.6.1. If the database schema changes in the future you are on your own.
I may have missed a few.
I probably should make a how-to...
Warning: require_once(C:\wamp\www\concrete\concrete/blocks/amiant_gallery/controller.php) [function.require-once]: failed to open stream: No such file or directory in C:\wamp\www\concrete\concrete\core\libraries\loader.php on line 215
when I try to add a new block to a page.
I couldn't find anything in the db.xml file? The pkgID was 4 and I have deleted the gallery tables using DROP.
Not sure what else i can do? :(
mysql error: [1062: Duplicate entry 'amiant_gallery' for key 'btHandle'] in EXECUTE("INSERT INTO BlockTypes(btID,btHandle,btName,btDescription,btActiveWhenAdded,btCopyWhenPropagate,btIncludeAll,btIsInternal,btDisplayOrder,btInterfaceWidth,btInterfaceHeight,pkgID) VALUES (NULL,'amiant_gallery','Amiant Image Gallery','Display an images with various ways.',1,0,0,0,25,'850','500','4')")
Not sure what to do now! :(
Did a search and got:
SELECT * FROM `blocktypes` WHERE `btHandle` = "amiant_gallery" LIMIT 0 , 30
my btID is 31
UPDATE: fixed it thanks to your nuke plan.. Please make a guide and please remove the package from the store! :|
I don't work for concrete5 though, you'll have to complain to the management about the package.
I've used Amiant on a few sites and it's worked well. Unfortunately, I loaded it on a new clients site and got the fatal error you experienced. I deleted the page I had it on and the site is functioning fine however I too cannot delete the add-on.
Now, shy of nuking the database elements, has anyone sent an email to the developer with this bug and received any response?
I really like the functionality of this add-on and would love to see a fix.
Anyone have an idea of where the issue lies (php version, Apache, conflict with C5 code somewhere)? I'm no coder by any stretch but maybe between the lot of us we can find where the error lies?
My guess is that the fault lies with the package. The dev seems pretty active so go ahead and give him a poke. I'm sure he would like to get the package fixed as much as you do.