When using the Icon API: Filter module, and inserting a tag with a bundle that does not exist (i.e. has not yet been imported) after it can't find the bundle, the module causes a fatal error:

Recoverable fatal error: Argument 1 passed to icon_process_attached() must be an array, boolean given, called in /www/sites/all/modules/icon/modules/icon_filter/icon_filter.module on line 69 and defined in icon_process_attached() (line 383 of /www/sites/all/modules/icon/includes/utilities.inc).

The website encountered an unexpected error. Please try again later.

Attached patch fixes the issue.

To reproduce, enable the Icon API: Filter module and its filter for a text format, then insert a tag in the body content like [icon:some-false-bundle-that-does-not-exist:%icon] and attempt to view the processed result.

Comments

Rory’s picture

StatusFileSize
new616 bytes
mariacha1’s picture

Status: Needs review » Reviewed & tested by the community

Patch applies cleanly and solves the problem mentioned.

markhalliwell’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: -fatal error bundle false filter

A much clearer approach would be:

if ($bundle = icon_bundle_load($match[1])) {
  icon_process_attached($bundle);
}
kyletaylored’s picture

Status: Needs work » Needs review
StatusFileSize
new638 bytes

re-rolled with suggestion.

mariacha1’s picture

Status: Needs review » Needs work

Small, change, you're repeating a line of code unnecessarily here:

           if (!isset($icons[$match[0]])) {
               $bundle = icon_bundle_load($match[1]);
-              icon_process_attached($bundle);
+              if ($bundle = icon_bundle_load($match[1])) {
+                icon_process_attached($bundle);
+              }
             }

Should be:

           if (!isset($icons[$match[0]])) {
-              $bundle = icon_bundle_load($match[1]);
-              icon_process_attached($bundle);
+              if ($bundle = icon_bundle_load($match[1])) {
+                icon_process_attached($bundle);
+              }
             }

The original $bundle = icon_bundle_load($match[1]); can come out, since that's in the if statement as well.

kyletaylored’s picture

Status: Needs work » Needs review
StatusFileSize
new730 bytes

You can always just re-roll the patch.

mariacha1’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me!

klonos’s picture

Issue summary: View changes
klonos’s picture

Title: Fatal error on calling a non-existing bundle » "Recoverable fatal error: Argument 1 passed to icon_process_attached() must be an array..."on calling a non-existing bundle

...adding the error message to the issue summary (and part of it in the issue title) so that people can find this issue easier when searching by error text.

#6 fixes this. Thanx @kyletaylored!!!

klonos’s picture

Title: "Recoverable fatal error: Argument 1 passed to icon_process_attached() must be an array..."on calling a non-existing bundle » "Recoverable fatal error: Argument 1 passed to icon_process_attached() must be an array..." on calling a non-existing bundle

...missed a space there. Sorry for the noise.

markhalliwell’s picture

Title: "Recoverable fatal error: Argument 1 passed to icon_process_attached() must be an array..." on calling a non-existing bundle » Fatal error on calling a non-existing bundle

Adding it to the issue summary is enough (it will be picked up in search). Changing the title back for legibility and preventing unnecessarily long issue table rows.

markhalliwell’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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