I get the following:

Fatal error: Call to undefined function mime_content_type() in /home/vih/drush/commands/make/make.download.inc on line 108

When trying to use my drush make file located at: https://github.com/vih/vih.dk-deploy/blob/master/vih_dk.make

As far as I can tell - the error occurs when trying to dl autopager like this:

libraries[autopager][download][type] = "get"
libraries[autopager][download][url] = "http://jquery-autopager.googlecode.com/files/jquery.autopager-1.0.0.js"
libraries[autopager][directory_name] = "autopager"
libraries[autopager][destination] = "libraries"

Comments

lsolesen’s picture

Seems that mime_content_type() has been deprecated:

PHP 5.3.5 with Suhosin-Patch (cli) (built: Jan 18 2011 11:59:55) 
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
    with Suhosin v0.9.32.1, Copyright (c) 2007-2010, by SektionEins GmbH
jhedstrom’s picture

This went in as part of #1447558: Make fails for library archives with no file "extension". Looks like some 5.3 builds of php don't include deprecated functions, so we probably need to also include the fileinfo functionality if mime_content_type() doesn't exist.

lsolesen’s picture

hm. none are part of a standard dreamhost php 5 build

adamdicarlo’s picture

@Isolesen, to confirm, you're saying that Dreamhost's PHP 5 includes neither the fileinfo module nor the mime_content_type() function?

That's pretty darn lame if true.

@jhedstrom, Since the only reason we need (one of) those functions is to determine if a file is tar, tgz, or zip can we just sniff the binary file header ourselves? It should be pretty easy.

jhedstrom’s picture

@adamdicarlo, we could do that as a secondary fallback--I envision changing this to use a function called drush_mime_content_type(), and within that do various function_exists checks, so we can start with file info functions, then fallback to mime_content_type, and then lastly attempt to sniff the header ourselves.

lsolesen’s picture

@adamdicarlo - I am pretty sure that neither is included in the build.

@jhedstrom - that seems like a good approach.

moshe weitzman’s picture

The `file --mime` command, if available, can also provide this info.

adamdicarlo’s picture

Status: Active » Needs review
StatusFileSize
new3.95 KB

Where should drush_mime_content_type() go? Should it be called something else? Its functionality is (at its worst case) limited to detecting only tar, gz/tgz, and zip.

I didn't want to add yet another "if it's available, use it" so I didn't try to add `file --mime`. That said, first time using pack() -- how's that look? Should the code check for endianness / are the fall through switch cases necessary?

adamdicarlo’s picture

Whoops, header comment is totally wrong about return values. What *should* this return on error?

moshe weitzman’s picture

Assigned: Unassigned » jhedstrom
Status: Needs review » Reviewed & tested by the community

Looks fine to me. Will let jhedstrom make final call here.

adamdicarlo’s picture

StatusFileSize
new2.51 KB
new4.01 KB

Updated patch with an interdiff. This patch fixes the header comment, removes the case FALSE which is redundant (was left over from older version), always reads the magic bytes in little endian and thus only does the tests in little endian. also contains links to file header magic docs online.

jhedstrom’s picture

Status: Reviewed & tested by the community » Fixed

Committed #11. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.