Nuclear option for deleting troublesome packages or blocks
Permalink 3 users found helpful
Some background:
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:
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.
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.
http://www.concrete5.org/marketplace/addons/amiant-image-gallery/
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.
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.
Not sure there's a one-size-fits-all approach, since a package can install a whole host of things, not just blocks. However, if you zap the record(s) in the BlockType table, that relate to the blocks installed by the package that will stop any errors showing up in the page. You can then blow away the package files. For good measure, remove the record in the Package table, and checkout the package/blocks db.xml file(s) and consider dropping the tables that are mentioned in there.
Yes, this is the way I was thinking. Just seems dangerous somehow, haha. I've made a backup of my SQL, so I will just dive in and try it out. If it works I'll document it here.
Thanks for your help!
Thanks for your help!
It worked! I tested my site a bit, everything seems ok. I was finally able to delete those "undeleteable" pages and page versions. No more errors. To help others I have documented my actions here...
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.
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:
x is the btID number, y is the pkgID number.
5. Using the table name(s) you found in step #1, drop them:
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.
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.
If you look at the code for core/models/package.php method uninstall() (line 322 ish), you will see a case statement with a host of places the package could have things in tables, so could use that as a checklist for a final tidy up.
That is excellent, thanks a lot! Here is a list of the other tables that contain the field "pkgID":
Pages
PageThemes
PageTypes
SystemAntispamLibraries
MailImporters
Config
AttributeKeyCategories
PermissionKeyCategories
AttributeSets
GroupSets
AttributeTypes
WorkflowTypes
PermissionKeys
PermissionAccessEntityTypes
SystemCaptchaLibraries
I may have missed a few.
Pages
PageThemes
PageTypes
SystemAntispamLibraries
MailImporters
Config
AttributeKeyCategories
PermissionKeyCategories
AttributeSets
GroupSets
AttributeTypes
WorkflowTypes
PermissionKeys
PermissionAccessEntityTypes
SystemCaptchaLibraries
I may have missed a few.
Amiant Image Gallery has ruined all my hard work! The add block UI is unusable now. Maybe an auto backup feature would be a good idea before installing new packages? Thanks PC
Follow my precedure above, it should bring your site back. Be sure to backup your database first!
I probably should make a how-to...
I probably should make a how-to...
I get the following:
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? :(
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? :(
I tried to install it again and got the following:
Not sure what to do now! :(
Did a search and got:
my btID is 31
UPDATE: fixed it thanks to your nuke plan.. Please make a guide and please remove the package from the store! :|
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! :|
Hey that is great! Congrats. I know the feeling, it can be quite a shock when your site suddenly doesn't work right.
I don't work for concrete5 though, you'll have to complain to the management about the package.
I don't work for concrete5 though, you'll have to complain to the management about the package.
Hi All
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?
Thanks
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?
Thanks
I haven't communicated with the developer, as I wanted a general solution to the problem, and his package is not crucial to me. But yea, somebody should mention something to him.
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.
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.
Seems like the uninstall function might be broken.