Sam Wilson's Journal


I’m getting and annoying error when running reverting a Feature (drush fr featurename):

/var/www/$ drush fr featurename
Fatal error: __clone method called on non-object in /var/www/ on line 55
Drush command terminated abnormally due to an unrecoverable error.
Error: __clone method called on non-object in /var/www/, line 55

It looks like this bug was fixed 2 September 2014 and is tagged as being fixed in 7.x-2.4 … but that version was released on 15 July.

[Update:] Ah. A coffee later, and I realise my stupidity this morning — the bug is tagged as being in 7.x-2.4, not fixed in that version. Gosh, one shouldn’t post before coffee!

I apply the patch manually.

[No comments] [Keywords: , , , , ] [Permanent link] [23 views]

The Features module is great. I think. Sometimes it seems too good to be true… usually it just is good though.

One can build a site in one’s local Drupal installation, and then piece by piece export its definition to a feature module that can be put under version control and deployed to other sites in one fell swoop. Start with:

drush fe --version-set=7.x-0.1 --destination=sites/all/modules/custom/featurename featurename components

where featurename is the new module’s name and components is the first thing to export (usually a content type). From then, the destination can be left out, and the components definition is also pretty flexible at making it quicker to select which components to export (naming contentions, such as common prefixes, help with this). So, as the site progresses, export new components to the feature:

drush fe --version-increment featurename components

If a component that’s already been exported needs to be changed, just change it and then update the feature with:

drush fu --version-increment featurename

That’s about all there is to the construction phase. Stick the sites/all/modules/custom/featurename directory into a VCS. Then it’s deployment time…

Check the featurename module out to the staging site (in the custom directory still, just for clarity’s sake) and enable the module:

drush en featurename

That only needs to be done the first time; subsequent updates are just cycles of updating the code and reverting the feature (a note on the slightly-confusing terminology of Features: one reverts (fr) the site, or updates (fu) the code).

$ git pull origin master
$ drush fr featurename

[No comments] [Keywords: , , , , , ] [Permanent link] [36 views]

Very often one wants to add a link to a View’s header or footer that allows users with permission to quickly jump to the relevant content creation form.

It’s easy to create a Global: Text area with the link, but this would then be seen by all users, regardless of authorization.

A few people have had similar thoughts.

I don’t know if there’s a better way (i.e. probably one that doesn’t involve PHP, not because this is a particularly complicated way of doing things but just that I always figure that Drupal should be usable by non-coders), but here’s how I’ve got it working:—

Required modules: views, views_ui, and php.

Add a Global: Text area header to a view, and select the PHP code text format for it. The code is as follows:

<?php if (user_access('create article content')): ?>
<a href="<?=url('node/add/article')?>" class="btn btn-default">Add new article</a>
<?php endif ?>

[No comments] [Keywords: , , ] [Permanent link] [66 views]

tl;dr: Drupal is good with the Video and Flowplayer modules. Install them with drush -y en video flowplayer and just make sure you’re testing with a video file that isn’t broken!

I’m trying to create a very simple video library in Drupal. Just a single Content Type with a bunch of fields, one of which should be for uploading a video.

The Video module looks to be the first choice. It creates a field type, and sets up a system for re-encoding. Sensible.

So I install it: drush -y en video

Then set up a transcoder by installing FFmpeg and telling Drupal where to find it. Also a Preset, which groups together output details like file extension, codec, sizes, and a bunch of other details—most of which I left as given.

Probably silly, as when I try to upload an MP4 (one of these) I get: “The video conversion process has failed. You might want to submit a simpler video format like mpeg or divx avi.” So why can’t I just upload a simple mpeg and have it displayed without being re-encoded?

The video field settings have an option, “Enable auto video conversion”, which I turn off. This works: I can upload the MP4 and it’s thumbnail is displayed at a nice size and things sort of start to look like a video player… but sadly emblazoned with “No video with supported format and MIME type found.” Oh well, maybe a different player is needed (I was relying on the standard HTML5 player).

Installing the Flowplayer module helps a bit: now there’s a video player with controls and a spinning loader—but the same MIME type error as before. Switching the MP4 player to ‘FLV Flash Players’ (from ‘HTML5 Player’) is a bit great: now there is a player, and it plays the file… audio only though, no video.

I tried another video though, and all works correctly! So that’s nice.

[No comments] [Keywords: , , ] [Permanent link] [49 views]

The Freo Farm website has gone off the air, it would seem. is now an empty blog called Marginal Field.

[One comment] [Keywords: , , , , ] [Permanent link] [983 views]

I’m doing a bit of proofreading of the first volume of the first edition of Emma, and I’ve just realised that there are more punctuation errors than I’d thought were likely. I’m slowing down now and taking more care.

[2 comments] [Keywords: , , , ] [Permanent link] [178 views]

This is a project that I’ve wanted for years, and now it’s here:

Project GITenberg is a Free and Open, Collaborative, Trackable and Scriptable digital library. It leverages the power of the Git version control system and the collaborative potential of Github to make books more open.

40,000 Project Gutenberg books have been uploaded to GitHub, and can now be forked, fixed, and fed back to the world’s biggest library of public domain ebooks. Other alliteration is also possible.

I’ve just sent my first pull request, for a typo I found in Gissing’s The Paying Guest.

The only thing lacking now is the original scans of these books, so that the ebooks can be verified against the source.

[2 comments] [Keywords: , , , , ] [Permanent link] [983 views]

WikiTeam has released an update of the chronological archive of all Wikimedia Commons files, up to 2013. Now ~34 TB in total.

Just seed one or more of these torrents (typically 20-40 GB) and you’ll be like a brick in the Library of Alexandria (or something), doing your bit for permanent preservation of this massive archive.

From this post to wikimedia-l.

[2 comments] [Keywords: , , , , ] [Permanent link] [2,895 views]

I’ve just been tinkering with writing a new Dokuwiki plugin that I’ve wanted for a while: log404. It logs all not-found page hits (as in, HTTP status 404 Not Found), and gives an admin page for viewing (and deleting) them. Soon to come is a way to add a not-found page ID to the redirect plugin’s list of redirects. That’ll be about all the thing shall do. Oh, and keep a list of 404s to ignore. And have a nicer-looking admin page! That’s all…

I’ve not created a page on yet ( because it’s not finished enough yet.

I have, however, added it to Travis CI—the first thing I’ve done that with. It’s jolly nice having a little green badge in the readme!

Right then. Friday arvo—time to get a beer.

[2 comments] [Keywords: , , , , , , ] [Permanent link] [1,290 views]

Task Scheduler is failing to run a particular task. Or, rather, it’s running it, exiting immediately, and refusing to log the output. (I don’t know why Microsoft came up with the brilliant idea of Task Scheduler not having a MAILTO feature!) This is a PHP command, something like php file.php --param=val …all Task Scheduler sees it as, according to its log, is Task Scheduler successfully completed task "\Stage\DB\Generate_VU_files" , instance "{3676cfd5-9fc0-460d-9738-1b1b5347ecb9}" , action "C:\Program Files (x86)\PHP\php.exe" with return code 255. Agh! Tell me more!

When the same ‘action’ command command is run from the command line, by the same user as whom Task Scheduler runs the task, everything works fine. There is no error, and the command does it stuff. Running through Task Scheduler, on the other hand… :-(

The chances are that this is a permissions problem.

Yes, it would seem that attempting to change permissions on a parent directory of the directory to which the command is trying to write gives “Error Applying Security”.

An answer on Server Fault suggests taking ownership (and only in Windows-world does one see things like “This can happen if you really don’t have access to that directory.”! because one’s first thought is always that the error is just stupid and not telling you the whole story —— I’m an admin, and admins have write access, but do I have write access? No!).

So I changed the owner of the target directory, clicking “Replace owner on subcontainers and objects”.


[3 comments] [Permanent link] [1,094 views]