I am receiving the following fatal error when attempting to load the "Condition settings" page on any derivative and have been unable to determine the exact cause. All of the other derivative setting pages load ok.

Fatal error: Call to undefined function file_info_file_types() in /home/.../public_html/sites/all/modules/media_derivatives/plugins/media_derivatives.conditions.inc on line 55

I also tried the dev version with the same result.

Any tips will be appreciated.

-George Aiello

Comments

slashrsm’s picture

Status: Active » Fixed

It looks like file_info_file_types() was removed from File entity 7.x-2.x. It is still in 7.x-1.x (which is part of Media 7.x-1.x), though.

gaiello’s picture

Thank you. I'll roll back the modules.
-George Aiello

pq’s picture

Status: Fixed » Needs review
StatusFileSize
new598 bytes

Here's an attempt at a patch... not sure if it's the best way to fix or whether $reset should be passed as TRUE or FALSE to file_type_get_all_types().

slashrsm’s picture

Version: 7.x-1.0-beta1 » 7.x-1.x-dev
Category: support » feature
Status: Needs review » Needs work
+++ b/plugins/media_derivatives.conditions.incundefined
@@ -51,10 +51,10 @@ function media_derivatives_type_support($file, $preset) {
 function media_derivatives_type_support_ui() {
   $form = array();
-  $types = file_info_file_types();
+  $types = file_type_get_all_types(TRUE);

I believe that $reset = TRUE is not needed.

As file_type_get_all_types() does not exist in File entity 7.x-1.x, I'd add some backward compatibility code here. We could use function_exists() to determine which version of File entity is used and then call the right function to get list of all file types.

pq’s picture

StatusFileSize
new746 bytes

this includes a function_exists() check. I haven't tested with File entity 7.x-1.x.

slashrsm’s picture

+++ b/plugins/media_derivatives.conditions.incundefined
@@ -51,10 +51,10 @@ function media_derivatives_type_support($file, $preset) {
   foreach ($types as $key => $type) {
-    $types[$key] = $type['label'];
+    $types[$key] = is_array($type) ? $type['label'] : $type->label;

Do we need this check here if we convert everything in array above?

pq’s picture

something like

+++ b/plugins/media_derivatives.conditions.incundefined
@@ -51,10 +51,10 @@ function media_derivatives_type_support($file, $preset) {
   foreach ($types as $key => $type) {
+  $type = (array)$type;
    $types[$key] = $type['label'];
slashrsm’s picture

+++ b/plugins/media_derivatives.conditions.incundefined
@@ -51,10 +51,10 @@ function media_derivatives_type_support($file, $preset) {
+  else {
+    $types = (array)file_type_get_all_types();

No... I meant that it is not needed to check if you convert here.

pq’s picture

ahh, I tried that, first but the response of both functions is an array, but one is an array of objects and the other an array of arrays, so I guess the conversion has to take place inside the loop.

slashrsm’s picture

Status: Needs work » Needs review
StatusFileSize
new762 bytes

Like this then? I added some sting sanitization, since I believe it should be done here.

pq’s picture

looks good to me.

slashrsm’s picture

Status: Needs review » Fixed

Committed. Thanks for your great work!

Status: Fixed » Closed (fixed)

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

ahoeben’s picture

Status: Closed (fixed) » Needs work

file_type_get_all_types() was recently renamed to file_type_load_all()
https://drupal.org/node/1977728

slashrsm’s picture

Status: Needs work » Fixed

Fixed. Thanks for reporting this.

Status: Fixed » Closed (fixed)

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

bdombro’s picture

Issue summary: View changes

#14 Helped me.

davidpugh’s picture

#14 Fixed my problem. Thanks.