Is it possible to flush all image module directories in Drupal 7? - drupal

Is there a way to flush all of the image directories at once? Perhaps using Drush?

Also, from the command line, with drush installed:
drush image-flush
which gives you a drop-down of all catagories. Choose 'all'!

I've done this on my system, but make sure you back it up when you test it out yourself.
Simply delete the styles directory in your files directory. They will re-create as they are loaded.
i.e. from the command line, from your web root, you would run:
$ rm -rf sites/default/files/styles
You may run into permission issues as those files will be owned by the web user. In that case, maybe you could have a form & submit handler in a module delete those files since that would be run by the web user. That is another topic though.

Related

openshift wordpress plugin needs to be granted write access, how do this?

I am trying to install CiviCRM in my openshift wordpress 'gear' And I am getting the following when I attempt to run civicrm's installation wizard:
The user account used by your web-server - 542ddc2950044666c40008d9 -
needs to be granted write access to the following directory in order
to configure the CiviCRM settings file:
//var/lib/openshift/542ddc2950044666c40008d9/app-root/data/plugins/files
Does anyone know if what it is asking is possible?
and then how do I go about setting that?
Thanks!
The plugins/files/civicrm directory is where CiviCRM stores its cached templates, file attachments, premium (thank-you gift) images, and more. It'll need to save stuff there regularly, not just at first.
The best thing to do is to log in through SSH like developercorey recommends and:
cd ~/app-root/plugins
chmod 755 files (changing the permissions so the owner can write and everyone can read/execute)
chown 542ddc2950044666c40008d9:542ddc2950044666c40008d9 files (making the user that the web server runs as ("542ddc2950044666c40008d9" as mentioned in the error message) be the owner of the directory
have the installer check again
SSH into your gear using the rhc ssh command
cd ~/app-root/plugins
ls -lah
Look for the "files" directory and see what the user and the permissions are on that folder, you can change with the "chmod" command to allow it to be written to by the web server, but be careful what you do or you could cause a major headache for yourself (like getting your WP blog hacked). Hopefully the instructions for that plugin include setting the permissions to something reasonable when you are done.

Silverstripe install admin js errors

For some reason my admin screen just hangs with some javascript errors. I have it installed on xampp on windows 7 ultimate 64bit. What could be causing this? Ill post a screenshot of the errors any help would be nice! p.s. This is my first time installing silverstripe ever so be nice. :)
This sort of things usually occurs when combined asset files cannot be created. Make sure the web server user has write access to the assets/ and assets/_combinedfiles folders, then go to your-site.com/admin/pages?flush=1.
Alternatively, since this is a local install, run in dev mode. There are instructions in the documentation on how to set this.
As indicated by #simon_w, this issue occurs due to the folder permissions:
In your local environment, in addition to the way via yml config, you can just put the following in _config.php inside mysite folder.
Director::set_environment_type("dev");
In dev mode, the installation doesnt need to write to assets/_combinedfiles. However, you had better have write permission for assets folder anyway.
So, just increase permissions for assets and directories under it. Uploaded files are also stored there, if not sufficient permission, you can't upload files from the admin panel. Other functionalists may also be affected.

How do I configure git to create files with the right permissions?

I have a git repo that includes submodules for wordpress and a wordpress theme. I am trying to configure this so that I can run "git pull" on the server whenever there is a change, to update the files from the repo. The problem I am having is that after I do a git pull, I end up with a 500 error on the front end and my server logs saying "file is writeable by group". Basically, I need all of the files to have the permissions of "0755" and to stay that way after I update them with git. How can I set this up correctly?
Check out the documentation on filemode. In your repository under .git/, the config file has a section starting with [core]. If you set filemode to FALSE (or zero, I can't quite recall), it will stop git from changing permissions on any of the files. Then, you can just update them to the right permission and leave them alone.
Note that you could run into other permissions errors if you are having git run as a separate user (we do this with a git user who runs automated updates). Just something to be aware of as you set things up.

Drupal: "The directory is not writable"

I recently upgraded my Drupal core from 6.15 to 6.26. In the update process, I was asked to make a backup of all my files, then delete the entire Drupal installation from my server, and rebuild it using the supplied files. I then copied all relevant back-up files back to the server from my local machine. The problem I'm having now is that I get a "The directory is not writable" notification whenever I do any sort of action as an admin. Initially, I was getting the error that "sites/default/files" was not writable, but I fixed that, and I changed the permissions on every file in the installation to 755. Why am I getting this error, and how can I fix it?
Although permissions may be set to 755, most likely the directory ownership is set to the wrong user.
Just wanted to add this possibility, which fixed this issue for me after trying many things:
If you're running SELinux (like Fedora), you may have a "security context" issue on /sites/default or /sites/default/files. So even if you open it up using chmod 777 (not a good idea), you STILL get the permission issue.
the fix is (first cd to sites directory):
restorecon -rv default/
I ran this locally as root.
I don't pretend to be an expert on security contexts by any stretch, but Fedora documentation is here.
Hope that helps others avoid my headache!
After finding the permissions problem, you'll probably want to go back and chmod 644 for all files, and 755 for directories (besides the upload folder) just to be safe.
Drupal sometimes create some directories so check if sites/default/files sub directories have the right permissions
You can do it using two possible options:
1. change the owner of files directory and all files inside it to apache user
2. Give 777 permissions recursively to files directory

What is your workflow for creating websites based on WordPress?

I a starting a project where 2 people will be developing a site on WordPress. It also may be necessary to have a development server setup where my client can view changes to the site before we push it live. There also may be database changes (like wordpress settings) that should be pushed all the way from development to dev to production.
I am wondering what the best workflow is for this. I understand the general concepts because I usually develop in Rails and therefore run migrations and use capistrano and git, but I would like to have the same tight workflow for a WordPress site. Any experienced WordPress developers out there?
Update: Maybe I did not make this clear enough but I understand wordpress. I have created 5-10 wordpress blogs and customized functionality. However, I have never worked on a wordpress site with multiple people or had to deal with having a dev, staging, and production environment.
Thank you!
To deal with this type of DEV and PRODUCTION environment, I've written a perl script to help me with what would otherwise be manual work. I've given certain steps familiar names so I remember to run them in the correct order. I only have DEV under SVN. I create a PRODUCTION environment each time with this script. That way I don't have to worry about maintaining 2 branches of code.
I'm using SVN so I choose a new checkout directory (like /tmp/foobar) of my DEV code. It's not going to be there very long.
Optional step 0: diff database structures
mysqldump -d -u USER -pPASS mydotcom > production.sql
mysqldump -d -u USER -pPASS mydotcom_dev > development.sql
vim -d production.sql development.sql
Sometimes plugins will add tables, and this will show that. Otherwise I replay the changes made within tables (install a plugin) when it's not worth it to diff certain tables and copy SQL statements.
step 1 clean:
The script deletes all files in the current directory, do a fresh svn checkout of the DEV branch. This fresh checkout is going to be transformed into the PRODUCTION code and copied to its webroot.
step 2 make:
perl runs a vim search and replace of the database name in wpconfig.php. The search and replace is just as easily done in perl.
system('vim -c "%s/define(\'DB_NAME\', \'mydotcom_dev\'/define(\'DB_NAME\', \'mydotcom\'/g | w | q" wp-config.php');
Remove local file uploads directory (so we don't overwrite the PRODUCTION one). wpcontent/uploads I believe it is on a standard install.
Another find and replace on all text files within the project that have my DEV url, for example
vim -c "%s/dev\.mydot\.com/www.mydot.com/g | w | q FILENAME.php
step 3 install.
Backup the wpcontent/uploads with dircopy() to be safe. Do a dircopy() of this cleaned up directory to the PRODUCTION webroot. Remove all .svn directories within the webroot like so:
find /PRODUCTION/WEBROOT -ignore_readdir_race -name .svn -exec rm -fr {} \; >/dev/null 2>&1
Now your DEV code has been transformed into your PRODUCTION code replacing all hardcoded URLs and keeping safe around the uploads directory that is not in SVN. You can even have it stop and start apache for you too. I hope my solution helps solves your problem.
Workflow huh? Well I worked with a couple of people on complex WordPress websites and still do. We use Subversion and Trac most of the time and it rarely comes to making some changes in the database. Only during setup I guess.
Here's the script:
#!/bin/sh
echo Copying $1 to $2 ...
mysqldump -uroot -pPASSWORD $1 > /tmp/tempdump.sql
mysql -uroot -pPASSWORD -e "CREATE DATABASE $2;"
mysql -uroot -pPASSWORD $2 < /tmp/tempdump.sql
rm -f /tmp/tempdump.sql
echo Complete
It's way too simple, I know, but that's the way I like it ;) Don't forget to replace PASSWORD with your password and pehaps you wouldn't like to use the user root for these purposes (I don't really care though, that's why I do).
Save the file into copydb.sh for example, then chmod +x copydb.sh and then you can run it like this: ./copydb.sh database1 database2 ;)
WordPress tends to be quite modular; I think a source control will help, and perhaps write a script to automate the uploading to a preview site. You can keep one folder which is only updated by SVN, and one working folder.
WordPress is modular in a sense that it can use Page Templates and Widgets, as well as plugins. You can write pieces of your site as widgets and plugins, and put them together to make it work. For pages with custom layout or PHP code, you can use Page Templates. You rarely need to touch the WordPress core files (nor should anyone), so if you stick to the extension tools given by WordPress, it would be fine.
You might want to try Role Manager plugin for permissions management and Turnkey Wordpress for quick wp install in virtual machine. Don't have a clue about something that could have git-like role, though.

Resources