Remove rows from the node table - drupal

Some nodes are displayed in the content list even if they don't exist anymore.
When I click on them I get an empty page.
I was wondering if I can just delete the rows from the "Node" table or I should clean something else.
thanks

First: on the administer page, go to performance, and click on the clear all caches button. If it doesn't solve your problem, then try disabling every contrib, and see if the problem still exists. If not, try enabling them one-by-one, and you will know which contrib made the problem. Report it to the module's issue queue.
If disabling modules doesn't solve your problem, download drush. Try deleting the node directly with node_delete. Example (if the wrong node's nid is 3):
drush php-eval 'node_delete(3);'
If you are not familiar with the command line, you can do the same with this little PHP file (put it into the Drupal's root):
include './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
node_delete(3);
If it doesn't work then make a backup from your database, delete the node from the node table and go through every node-related table (which has a nid column), and delete the related entries.

This may not be your problem but:
You don't want to delete rows directly from the database. You'll end up with no way of knowing what shape your database is in afterwards. Node IDs exist in many tables and nodes are distributed through more than one table.
Go through the nodeapi and use the Drupal framework because that's what it's meant for! The node api will treat your database schema correctly.
See:
http://api.drupal.org/api/function/node_delete/6
So if you know the node ID, you can call node_delete.

Note that (depending on your Drupal permissions) you will likely need to be operating as a user with permissions to delete nodes -- such as user-1 rather than the default anonymous user. You can do this by pre-appending your node_delete() call with,
global $user;
$user = user_load(1);
You may also experience a timeout if deleting many nodes and invoking the PHP file via a browser. One fix for this is to invoke the PHP file via the command line (if you have shell access). For example,
php -f custom-script.php
Again, if you are deleting many nodes, you may also run out of memory. Increase the PHP memory limit for your script's invocation like this,
php -f custom-script.php -d memory_limit=512M
This works against my tests with Drupal 6. Note that you may also be able to fix the server timeout issue by setting an explicit timeout in the custom-script.php.

Related

How can I manually enable/disable a module?

I am trying to automate the process of enabling/disabling the module for my Drupal-8 website. As far I could understand from the docs, Drupal saves the info related to the modules in the table config inside its database (drupal/sites/default/files/.ht.sqlite).
Before enabling the module snowflake, I'm not unable to see any entry for it, but after manually enabling it through http://website/admin/modules, I can see this entry at the end of the table.
collection name data
---------- -------------- --------------------------------------------------------------------------------------------------------------------
snowflakes.set a:5:{s:8:"langcode";s:2:"en";s:7:"enabled";b:1;s:13:"exclude_admin";b:1;s:13:"toggle_button";b:0;s:5:"_core";a:1:{s:19:"default_config_hash";s:43:"gWu2_RT_6nrFtvXiYNQFgZm17c3CEXCxrb-JnsCFKmM";}}
Is there any file/function that is generating entries like this for similar modules? Once I'm able to figure this out, it might help me automate the process of enabling a module without manually clicking the checkbox from http://website/admin/modules every time.
you can use drush to enable/disable modules.
See https://www.drush.org/latest/
Example (install):
drush pm:install "mymodule"
Unninstall
drush pm:uninstall "mymodule"
replace "mymodule" with the module machine name.

Unix how to create files and directories with specific user

I'm trying to create files and directories and executing a script with a specific user instead of root user. How can I do that? I don't want to switch users from root user to another user; instead, I always want it to use a specific user, for example, wasadmin user.
Whenever I'm creating a new file or executing a script, this should be run as wasadmin user. Can you please help me with this?
It depends on how you create the file. As far as I know, it's not possible to do this when you use touch or echo, but depending on the way you create the file, there might be a possibility to add a user parameter.
In case this is not possible, you might use the chown command (change ownership), this command gives the possibility to modify the owner/group of an already created file (which obviously means that you can only do this after the file has already been created). I've been looking for an official chown reference, but I think that launching the command man chown can answer all questions you might have on this command.

Unable to delete uploaded XML file on Drupal 8.5

I have created a media type that accepts XML files and saves them to a custom publicly accessible location on the server.
Ideally I would like the file to be overwritten when the exact same file is uploaded. This does not happen, instead it creates a new file and adds a number on the end. I have "Create new Revision" turned off.
To get around this issue I thought I could just delete the file via the CMS. The uploaded file has status of "Permanent" and is used 0 places. I know the cron job cleans up files for you, but when I run the cron the file in question is still there. I figure it's because the file is set to permanent, but I don't see a way to flip this to temporary.
Any help is much appeciated.
There is a setting nested away in the file system settings, which lets you configure it to remove (or not removed) orphaned files. If drush isn't removing them despite having no usages recorded, I'd check this option isn't ticked.
The temporary and permanent status are used for storing temporary files during the upload/save process, so I wouldn't tinker with those too much.
If you fancy making the form yourself using the form API, then you can save the file programmatically using the FILE_EXISTS_REPLACE parameter.
https://api.drupal.org/api/drupal/core%21modules%21file%21file.module/function/file_save_data/8.5.x

A route named 'Admin_default' is already in the route collection. Route names must be unique. Parameter name: name

I have an ECommerece site which had some issues regarding Nuget Updates. I did all kind of updates but now I am facing another Issues at RunTime which i never faced before.
A route named 'Admin_default' is already in the route collection. Route names must be unique.
Parameter name: name
I checked my Entire solution, there is no any other Route name 'Admin_default'.
It has only one Route. I tried to Rename the Route and Run, It Run successfully for the first time.
but when i Stop it. Rebuild the Solution and then Run again. then It Again give me the same issue with new Name of Route.
Also I checked all of other posts related to my issue. but can't fix my bug.
Edit:
I did all kind of Deletion of folder bin and Obj. It works only for the first time when I Run. for the 2nd time I get same issue again with new name of Route.
The main issue is that. I need to Clean my Solution each time before Run.
If I do not Clean it before Run, it will give me this issue.
But I want It should automatically be Replaced with old dll file on Build command. and do not need to Clean Manually.
But It need to Delete ( Clean ) the previous dll manually before Rebuild.
Can I have any technique through which i don't need to clean solution manually and I Rebuild solution successfully and Replace old dll automatically.?
Seems a similar problem has been logged on the nopcommerce site.
Read it and let us know if the described solution(s) worked for you.

Rules requiring manual run in Alfresco

I have a rule on a folder which executes a JavaScript code whenever a new document enters the folder. The issue is the rule doesn't run automatically when a document enters the folder, but I have to run it manually.
I have tried running the script in background too. If I put a rule on update, that works automatically. The problem is with creation or entering of new documents in the folder. I am using Alfresco community 4.2.f share.
Please advise.
Thanks.
I cannot recreate this problem in Alfresco Community Edition 4.2.f. Make sure that:
All of the rules are enabled
The person putting the document in folder1 has permissions to create new documents in Folder 2.
The criteria for the rules are valid
The script in Folder 2 is not actually running. The best way to validate this is by turning on the server-side JavaScript debugger by editing $TOMCAT_HOME/webapps/alfresco/WEB-INF/classes/log4j.properties and setting log4j.logger.org.alfresco.repo.web.scripts.AlfrescoRhinoScriptDebugger=on
Alternatively, for #4, you could change to an out-of-the-box action, like another Move that would move the document to Folder 3. That's what my test does. If that works for you like it does for me, you would be able to narrow down your troubleshooting to a problem with the custom script.
when running scripts fired by rules you can't rely on search for the new doc since indexing isn't finished when the script runs. If SOLR is configured as search engine, indexing is executed async from outside the repository every 15 secs. You already may know that you can get the name from the script node?

Resources