Drupal - clean database - drupal

Is there a way to clear or clean the database of all the unnessecary entries that was added by amodules that have since been uninstalled. Ive created my site but have added alot of modules to ploay around with, I have no removed all of those I dont use, but just wondering if there is a way top clear the database etc.. to ensure nothing unused was left behind ?
thanks

If you have your own content that you would want to keep AND you have used the uninstall feature for all the modules that you have installed, then the only route is to manually check. if you don't have much content you could export it and replace the db with a clean one, then put your content back into it.

You can use the Schema module for discovering the remaining tables from not properly uninstalled modules.

You can also use DEVEL modules reinstall feature if you only want to clean the database but don't want remove the module.

Related

Is Drupal project supposed to be empty?

I was given a Drupal project and asked to figure out how its code base structured and how the project is structured overall.
I successfully installed it using xampp.
Now I see nothing custom in the project:
For blocks I have only Bartik and Rubik. For content type only Basic page. For file types Audio, Document, Image and Video. For menus Main Menu, Management, Navigation and User menu.
So, does it mean that I was given a blank empty project? What else may I check that may have been customly changed in an empty project? What may I have missed while installing the project that may cause it to become empty, without any customisations? Maybe it is possible to check for something in the files of the project?
I am asking a few questions here, since I am not sure which one of them will convey the matter which concerns me. But basically all of them mean the same: I just want to see what someone else did in the project. And the more customisations I will find, the better it will be.
Thank you.
This does look like a virgin install typically does. If you were expecting to see more, perhaps you need to import a database...
Confirm you've imported the project database and that your settings file is pointing to it. It looks like you're using Drupal 8, so the file should be in sites/default/settings.php
Check under Content to see if any nodes have been created. If you have some sort of botched import, you can also try accessing a few nodes randomly at example.com/node/1, example.com/node/2 to check directly in case something is wrong with the index
Other than Nodes, Drupal content can be also in the form of Views. These are available at example.com/admin/structure/views. This is usually for heavily customised content. There are roughly 15 default Views that come with Drupal 8.
A default install will have no Modules installed in /modules. If you're seeing any directories there, it could be that the site was relying on these to display the content you're being asked to admin.
Trust this puts you on the right path. :)

installing custom/default content types when site already has a theme

I am relatively new to DNN/developing content and the project I am currently on is already set up, it has a theme/skin and its mostly already set. They wanted me to create a module that I can't find elsewhere and was going to try to make it through. When I installed 2sxc and tried to add content I was prompted with needing to install a content package. I just want to make sure it won't alter all the other content already set up on my site because there are many pages already set up and as designed. I want to make sure I don't mess up elsewhere on the site. I just want to use this to create two drop-downs for the user to select and them display the query results based on it.
Thanks for any help/advice.
The initial install package just adds some common types / templates for you. It's only on the current portal, so it won't affect anything else.
As the prompt only appears if you have nothing installed yet, it's a safe thing to do.

Refactor Drupal site while preserving content

My dilemma: My small team has been pegged with the task of refactoring/redesigning a rather large Drupal site. The site is littered with unused modules and content types, CSS/JS/HTML/etc hacks, and has a myriad of strange work-arounds for external data imports. I am currently the sole backend developer for the team, and our Drupal expertise is beginner level. We cannot build a custom CMS because of the amount of content that the site has combined with the complexity of Drupal's DB structure, it would be impossible to export it reliably; as well, content is being constantly added and modified on a daily basis.
My question: Is there any best practices, tips, advice, or any suggestions that anyone can provide that might aide us in our attempt to refactor this site?
Specifically...
Detecting, disabling, uninstalling, and removing unused modules and QAing afterwards.
Updating modules and QAing (systematic approach?).
Detecting and deleting unused content types.
Detecting and removing unused PHP code (tpls mostly).
Detecting and removing unused CSS/JS.
On modules back-end page you have dependencies shown for every module. Is some other module using it and what other modules current module uses. So, if you see that module is not used by any other module and that it's feature is not needed you can try disabling it first, check if everything works well and finally remove the module.
About content types - go to content, check is there some node of specific content type you doubt it's not needed. If there are nodes of that type try viewing them. It they are not styled well...might be that they are not used/needed.
Php - hmm...you can i.e. add some line of your code writing out some thing, or even saving some text to the file and then open page...see if you'll get some output or something saved into your file. You can even call exit() function and check will it break the site.
Similar with JS - alert something or write to console to see will it be called.
And most important thing - make a backup of all files and database first!

WordPress - Overriding a function in a plugin

I've been wonder for some time what the best practice is for modifying a plugin created by a WordPress user?
For example there are a couple lines of code I want to change within the Contact Form 7 plugin. The function is called function wpcf7_ajax_json_echo() and is located in:
wp-content > plugins > contact-form-7 > includes > controller.php
Of course I could just change the code right in that file and be done, but then I'm out of luck when I want to update that plugin as my modifications will probably get written over.
I know I should be making this happen via my functions.php file, but I'm not sure how to go about achieving this. Also, that particular function is 100+ lines of code and I'm guessing I don't want to overwrite that whole function, because there is a good chance the author of the plugin may choose to update something in that function in the future.
Does anyone know the cleanest way for me to modify a few lines within that function via my functions.php file?
Thank you!
I do not recommend changing the core. However, you are in a bit of a pickle.
You can:
Update the function code directly in the plugin
Copy the current function code from the plugin and override it in functions.php
In the end, you still run into the same problem - future compatibility.
Either:
The update will overwrite your plugin changes.
Your function overwrites the plugin changes.
So, as much as I don't want to say it, I'd update the plugin directly. At least then when you upgrade, you'll know pretty quick that your change is missing. Furthermore, it's possible the plugin updates will include your change.
You could use SVN if you wanted to maintain forwards compatibility (and your host has SVN available), whilst being able to keep your own changes.
Each plugin that's on the Plugin Directory has to have an SVN repo (that's how the Directory knows if there are updates). Here's the CF7 repo.
Checkout the trunk to your /plugins/ directory inside a folder like /custom-contact-form-7/. Alter the wp-contact-form-7.php file to give it a unique name, and make the changes you want to make to customise it.
To get new updates you can just svn up to get them, and they'll merge with your changes. Though, you may have to clean up merge conflicts sometimes.
Version Control with Subversion is the place everyone starts to learn SVN, if you need it. There's also a Github repo now, if you'd like to fork that.
I definitely think you should add your updates to functions.php or to a custom plugin. It's a hassle right now, but MUCH less hassle every time you upgrade the plugin.
You'll always have to reference the changes made in updates no matter what. Even if you're able to extend the functionality without copying this file, you'll have to at least check and make sure your changes still work. And WinDiff/BBEdit's compare will make quick work of that.
So my first suggestion is to override that function.
Second suggestion:
I noticed there's some extensions (a, b, c) to this plugin; perhaps you can find out how they made their extensions and use those details to make your own. Well, that's like suggesting you make a new house in order to fix the dripping faucet, but it's an idea.

Export Drupal Content?

I want to know what is the easiest way to export ALL content of a specific user in Drupal, by only making use of the database. Is this even possible?
Reason being, I moved a site, and now clients created content on the old server, unknowingly, and I need to move it to the new server. Unfortunately, the site can't be accessed anymore (due to the move) so I only have access to the database.
Should I perhaps look at finding a way to maket the isntallation accessible and then using an export mdoule, or is there an easy way to export using PHPMyAdmin?
Ouch
You could take the db and set it up on a sandbox somewhere, which would give you access to see what changed. Genrally if you have access to a DB (and know which version of drupal and modules you had), you can run a drupal site from it.
In an earlier question I suggested the migrate module for getting content from one drupal db to another, I think that appies here. If you can't get another code base to look at the old DB.
Instead of trying to pinpoint the content that a specific user has created, it will probably be a lot easier to get the stuff you need based on the datetime. But it really depends what kind of content that have been created. If it's just nodes, it should be fairly simple to load the nodes from the one database and save it to the other.
Another thing worth mentioning is that Drupal support having more than one database in your settings. You can relatively change the db connection if they are of the same type (e.g. MYSQL). See the db_set_active function.
You can also try to make use of the migrate modules like Jeremy suggested, which way to go depends a bit on how well your Drupal/PHP/SQL skills are and how tricky it is to get the data you need.
I think this module will help you
data_export_import
I know you already fixed this, but what about the backup_migrate module?

Resources