I'm getting multiple occurrences of the following errors when I select a field type when adding a new formatter. This is a new install of 2.4. I'm just trying this module for the first time, so this was the first formatter I tried to create.

Warning:  preg_match_all() expects parameter 2 to be string, array given in /path/to/includes/common.inc on line 7534
Warning:  array_unique() expects parameter 1 to be array, null given in /path/to/includes/common.inc on line 7535
Warning:  Invalid argument supplied for foreach() in /path/to/includes/common.inc on line 7538

The errors occur during an AJAX call when I select a field type and are repeated 13 times.

Comments

ExTexan’s picture

I also get the same errors when selecting a different "format".

Deciphered’s picture

Priority: Critical » Normal

I have not seen that error; Can you confirm it on http://ply.st/custom_formatters? If so, please provide reproduction steps.

ExTexan’s picture

Hmmm. As you said, it didn't occur in the sandbox. It must be a conflict with, or actually caused by, another module, but without any clues as to which other module might be involved, I'm at a loss as to telling you the steps to reproduce.

Feel free to close this issue if you wish.

Deciphered’s picture

It could could be many things, a module, server configuration, etc.

I'd love to know the cause in the case I can prevent others from having the issue. If you can provide any information you think might be relevant?

ExTexan’s picture

@Deciphered, I admire your tenacity on this. How could I *not* step up and at least try to help you nail down this problem (if it is, in fact, a problem with your module)?

First, my apologies that the following backtrace array is incomplete. If you recall, this error is coming up in an AJAX call, so the "print" of the array appears in a popup text window generated by the browser (I guess). Perhaps the browser allocates limited space to the text window. Or maybe the fact that the array is incomplete is a clue about the issue itself (memory issues, perhaps?).

Second, my apologies if the formatting (indentation) of the array is not correct. In the text window, it was all left-justified, so I had to copy/paste it into my editor and do the indentation myself (a tedious task, to say the least).

Third, sorry it is so long. I think the part you need is at the top (the "args" section for "drupal_explode_tags"), but I included as much as I could, just in case it might be helpful.

ResponseText: Array(
  [0] => Array(
    [file] => /home/vps1/public_html/mrs/sites/all/modules/custom_formatters/plugins/export_ui/custom_formatters.inc
    [line] => 255
    [function] => drupal_explode_tags
    [args] => Array(
      [0] => Array()
    )
  )
  [1] => Array(
    [file] => /home/vps1/public_html/mrs/sites/all/modules/custom_formatters/plugins/export_ui/custom_formatters.inc
    [line] => 137
    [function] => _custom_formatters_preview_variables
    [args] => Array(
      [0] => Array(
        [info] => Array(
          [label] => Array(
            [#type] => textfield
            [#title] => Formatter name
            [#description] => This will appear in the administrative interface to easily identify it.
            [#default_value] =>
          )
          [name] => Array(
            [#title] => Name
            [#type] => machine_name
            [#default_value] =>
            [#description] => The unique ID for this formatter.
            [#required] => 1
            [#maxlength] => 255
            [#machine_name] => Array(
              [exists] => ctools_export_ui_edit_name_exists
              [source] => Array(
                [0] => info
                [1] => label
              )
            )
          )
          [description] => Array(
            [#title] => Description
            [#type] => textarea
            [#default_value] =>
          )
          [#title] => Basic information
          [#type] => fieldset
          [#collapsible] => 1
          [#collapsed] =>
          [mode] => Array(
            [#title] => Format
            [#type] => select
            [#options] => Array(
              [php] => PHP
              [token] => HTML + Tokens
              [formatter_preset] => Formatter preset
            )
            [#default_value] => token
            [#ajax] => Array(
              [callback] => custom_formatters_export_ui_form_js
              [wrapper] => engine-wrapper
            )
          )
        )
        [#attached] => Array(
          [css] => Array(
            [0] => sites/all/modules/custom_formatters/styles/custom_formatters.css
          )
          [js] => Array(
            [0] => sites/all/modules/custom_formatters/scripts/custom_formatters.admin.js
          )
        )
        [#item] => stdClass Object(
          [name] =>
          [label] =>
          [description] =>
          [mode] =>
          [field_types] =>
          [code] =>
          [fapi] =>
          [export_type] =>
          [type] => Local
        )
        [#formatters] => 1
        [engine] => Array(
          [#type] => container
          [#prefix] =>
          [#suffix] =>
          [field_types] => Array(
            [#title] => Field type(s)
            [#type] => select
            [#options] => Array(
              [advpoll_field] => Array(
                [advpoll] => Advanced Poll Choice
              )
              [date] => Array(
                [date] => Date (ISO format)
                [datestamp] => Date (Unix timestamp)
                [datetime] => Date
              )
              [ds] => Array(
                [ds_author] => Author
                [ds_changed_date] => Last modified
                [ds_ds_user_picture] => User picture
                [ds_more_link] => Read more
                [ds_name] => Username
                [ds_node_link] => Read more
                [ds_permalink] => Permalink
                [ds_post_date] => Post date
                [ds_signature] => User signature
                [ds_submitted] => Submitted
                [ds_submitted_by] => Submitted by
                [ds_title] => Title
                [ds_user_signature] => User signature
              )
              [entityreference] => Array(
                [entityreference] => Entity Reference
              )
              [field_collection] => Array(
                [field_collection] => Field collection
              )
              [field_countdown] => Array(
                [field_countdown] => Countdown Timer Field
              )
              [file] => Array(
                [file] => File
              )
              [fivestar] => Array(
                [fivestar] => Fivestar Rating
              )
              [image] => Array(
                [image] => Image
              )
              [list] => Array(
                [list_boolean] => Boolean
                [list_float] => List (float)
                [list_integer] => List (integer)
                [list_text] => List (text)
              )
              [location_cck] => Array(
                [location] => Location
              )
              [number] => Array(
                [number_decimal] => Decimal
                [number_float] => Float
                [number_integer] => Integer
              )
              [taxonomy] => Array(
                [taxonomy_term_reference] => Term reference
              )
              [text] => Array(
                [text] => Text
                [text_long] => Long text
                [text_with_summary] => Long text and summary
              )
              [video_filter_field] => Array(
                [video_filter] => Video Filter
              )
            )
            [#default_value] =>
            [#required] => 1
            [#ajax] => Array(
              [callback] => custom_formatters_export_ui_form_js
              [wrapper] => engine-wrapper
            )
            [#disabled] =>
          )
          [code] => Array(
            [#title] => Formatter
            [#type] => textarea
            [#default_value] =>
            [#required] => 1
            [#rows] => 10
          )
        )
      )
      [1] => Array(
        [plugin] => Array(
          [schema] => formatters
          [access] => administer custom formatters
          [menu] => Array(
            [menu prefix] => admin/structure
            [menu item] => formatters
            [menu title] => Formatters
            [menu description] => Administer Formatters.
            [items] => Array(
              [list callback] => Array(
                [path] =>
                [title] => Formatters
                [description] => Administer Formatters.
                [page callback] => ctools_export_ui_switcher_page
                [page arguments] => Array(
                  [0] => custom_formatters
                  [1] => list
                )
                [access callback] => ctools_export_ui_task_access
                [access arguments] => Array(
                  [0] => custom_formatters
                  [1] => list
                )
                [type] => 6
              )
              [list] => Array(
                [path] => list
                [title] => List
                [page callback] => ctools_export_ui_switcher_page
                [page arguments] => Array(
                  [0] => custom_formatters
                  [1] => list
                )
                [access callback] => ctools_export_ui_task_access
                [access arguments] => Array(
                  [0] => custom_formatters
                  [1] => list
                )
                [type] => 140
                [weight] => -10
              )
              [add] => Array(
                [path] => add
                [title] => Add
                [page callback] => ctools_export_ui_switcher_page
                [page arguments] => Array(
                  [0] => custom_formatters
                  [1] => add
                )
                [access callback] => ctools_export_ui_task_access
                [access arguments] => Array(
                  [0] => custom_formatters
                  [1] => add
                )
                [type] => 388
              )
              [edit callback] => Array(
                [path] => list/%ctools_export_ui
                [page callback] => ctools_export_ui_switcher_page
                [page arguments] => Array(
                  [0] => custom_formatters
                  [1] => edit
                  [2] => 4
                )
                [load arguments] => Array(
                  [0] => custom_formatters
                )
                [access callback] => ctools_export_ui_task_access
                [access arguments] => Array(
                  [0] => custom_formatters
                  [1] => edit
                  [2] => 4
                )
                [type] => 0
              )
              [edit] => Array(
                [path] => list/%ctools_export_ui/edit
                [title] => Edit
                [page callback] => ctools_export_ui_switcher_page
                [page arguments] => Array(
                  [0] => custom_formatters
                  [1] => edit
                  [2] => 4
                )
                [load arguments] => Array(
                  [0] => custom_formatters
                )
                [access callback] => ctools_export_ui_task_access
                [access arguments] => Array(
                  [0] => custom_formatters
                  [1] => edit
                  [2] => 4
                )
                [type] => 140
                [weight] => -10
              )
              [import] => Array(
                [path] => import
                [title] => Import
                [page callback] => ctools_export_ui_switcher_page
                [page arguments] => Array(
                  [0] => custom_formatters
                  [1] => import
                )
                [access callback] => ctools_export_ui_task_access
                [access arguments] => Array(
                  [0] => custom_formatters
                  [1] => import
                )
                [type] => 388
              )
              [export] => Array(
                [path] => list/%ctools_export_ui/export
                [title] => Export
                [page callback] => ctools_export_ui_switcher_page
                [page arguments] => Array(
                  [0] => custom_formatters
                  [1] => export
                  [2] => 4
                )
                [load arguments] => Array(
                  [0] => custom_formatters
                )
                [access callback] => ctools_export_ui_task_access
                [access arguments] => Array(
                  [0] => custom_formatters
                  [1] => export
                  [2] => 4
                )
                [type] => 132
              )
              [revert] => Array(
                [path] => list/%ctools_export_ui/revert
                [title] => Revert
                [page callback] => ctools_export_ui_switcher_page
                [page arguments] => Array(
                  [0] => custom_formatters
                  [1] => delete
                  [2] => 4
                )
                [load arguments] => Array(
                  [0] => custom_formatters
                )
                [access callback] => ctools_export_ui_task_access
                [access arguments] => Array(
                  [0] => custom_formatters
                  [1] => revert
                  [2] => 4
                )
                [type] => 0
              )
              [delete] => Array(
                [path] => list/%ctools_export_ui/delete
                [title] => Delete
                [page callback] => ctools_export_ui_switcher_page
                [page arguments] => Array(
                  [0] => custom_formatters
                  [1] => delete
                  [2] => 4
                )
                [load arguments] => Array(
                  [0] => custom_formatters
                )
                [access callback] => ctools_export_ui_task_access
                [access arguments] => Array(
                  [0] => custom_formatters
                  [1] => delete
                  [2] => 4
                )
                [type] => 0
              )
              [clone] => Array(
                [path] => list/%ctools_export_ui/clone
                [title] => Clone
                [page callback] => ctools_export_ui_switcher_page
                [page arguments] => Array(
                  [0] => custom_formatters
                  [1] => clone
                  [2] => 4
                )
                [load arguments] => Array(
                  [0] => custom_formatters
                )
                [access callback] => ctools_export_ui_task_access
                [access arguments] => Array(
                  [0] => custom_formatters
                  [1] => clone
                  [2] => 4
                )
                [type] => 0
              )
              [enable] => Array(
                [path] => list/%ctools_export_ui/enable
                [title] => Enable
                [page callback] => ctools_export_ui_switcher_page
                [page arguments] => Array(
                  [0] => custom_formatters
                  [1] => enable
                  [2] => 4
                )
                [load arguments] => Array(
                  [0] => custom_formatters
                )
                [access callback] => ctools_export_ui_task_access
                [access arguments] => Array(
                  [0] => custom_formatters
                  [1] => enable
                  [2] => 4
                )
                [type] => 0
              )
              [disable] => Array(
                [path] => list/%ctools_export_ui/disable
                [title] => Disable
                [page callback] => ctools_export_ui_switcher_page
                [page arguments] => Array(
                  [0] => custom_formatters
                  [1] => disable
                  [2] => 4
                )
                [load arguments] => Array(
                  [0] => custom_formatters
                )
                [access callback] => ctools_export_ui_task_access
                [access arguments] => Array(
                  [0] => custom_formatters
                  [1] => disable
                  [2] => 4
                )
                [type] => 0
              )
            )
          )
          [title singular] => formatter
          [title singular proper] => Formatter
          [title plural] => formatters
          [title plural proper] => Formatters
          [handler] => custom_formatters_ui
          [form] => Array(
            [settings] => custom_formatters_export_ui_form
            [submit] => custom_formatters_export_ui_form_submit
            [validate] =>
          )
          [export] => Array(
            [admin_title] => label
            [admin_description] => description
            [key] => name
            [key name] => Name
            [primary key] => name
            [identifier] => formatter
            [default hook] => custom_formatters_defaults
            [api] => Array(
              [owner] => custom_formatters
              [api] => custom_formatters
              [minimum_version] => 2
              [current_version] => 2
            )
          [object] => stdClass
            [status] => default_formatters
            [can disable] => 1
            [bulk export] => 1
            [list callback] => custom_formatters_formatters_list
            [to hook code callback] => custom_formatters_formatters_to_hook_code
            [cache defaults] =>
            [default cache bin] => cache
            [export type string] => type
            [boolean] => 1
          )
          [module] => custom_formatters
          [name] => custom_formatters
          [path] => sites/all/modules/custom_formatters/plugins/export_ui
          [file] => custom_formatters.inc
          [plugin module] => ctools
          [plugin type] => export_ui
          [has menu] => 1
          [title] => custom_formatters
          [allowed operations] => Array(
            [edit] => Array(
              [title] => Edit
            )
            [enable] => Array(
              [title] => Enable
              [ajax] => 1
              [token] => 1
            )
            [disable] => Array(
              [title] => Disable
              [ajax] => 1
              [token] => 1
            )
            [revert] => Array(
              [title] => Revert
            )
            [delete] =>
Deciphered’s picture

Hi ExTexan,

Thanks for the follow up, greatly appreciated.

I'm pretty certain that the issue in question is valid, it's just clearly a little tricky to reproduce. If it is what I think it is, it's related to the Preview controls and the problematic last minute change I made just before releasing 2.3 which prompted a 2.4 release.

This particular issue should be already fixed in the latest dev release. I will have to push out a 2.5 release soon, but I actually want some substantial changes to be in it before I do so (of which I do have some in mind already).

Let me know if the Dev release resolves the issue for you, and thanks again for following up.

Cheers,
Deciphered.

ExTexan’s picture

@Deciphered,

I finally found time to try the dev version. Alas, it didn't fix the issue. :-(

Deciphered’s picture

Can you post a stack trace again? Or at least just the first couple entries?

japanitrat’s picture

Same problem here, btw

japanitrat’s picture

Hmm, I feel like it has something to do with the text which is being trimmed. I just tried it on my site where I had two nodes of the same type. In one it worked, in the other one the text got repeated. The difference between the two was that second one had significantly more markup, like long spans with style attributes (CKEditor added it for some reason). When I made it shorter, and removed the redundant markup, the issue got fixed. I guess the text was trimmed at a position where it was missing a closing tag (like a </p>)

Deciphered’s picture

@japanitrat If you can give me the content of the fields and the formatter so that I can reproduce the issue, then I can try to fix the issue.

If you can run through http://simplytest.me to determine 100% reproducible steps, then post those steps here.

japanitrat’s picture

Argh, sorry Deciphered, wrong issue queue (I meant to post it here: https://www.drupal.org/node/1678334#comment-10612876).
Still have the problem described in this thread, though. Will try to give you a reproducible flow.

japanitrat’s picture

Okay well, it's pretty simple to reproduce actually.
Go to http://simplytest.me, add custom formatters, run. Go to Structure -> Custom Formatters, and change the select field value to something other than PHP code. Now go to Reports -> Recent Log Messages, you'll see the error (warning) mentioned in this issue.
If your PHP config treats errors as warnings, you actually have a problem.

Now, if you add Devel to the mix and enable Krumo backtrace, the custom-formatter-config page actually becomes unusable.

P.S.: here is the vanilla installation example (only custom formatters added to the installation): https://dmgia.ply.st/#overlay=admin/reports/dblog

Deciphered’s picture

Status: Active » Closed (cannot reproduce)

I'm not sure if this issue was already resolved in Dev, or if the steps here on reproducing the issue aren't clear, but I am unable to reproduce the issue.

Closing for now, feel free to re-open if you are still having the issue, and provide clearer steps (Go to Structure -> Custom Formatters, and change the select field value; there's no select field with 'PHP code' on the specified page).

bohemier’s picture

Status: Closed (cannot reproduce) » Active

Reopening this...

Actually japanitrat is right, it's just missing a step (Add new formatter). To reproduce : Go to Structure -> Custom Formatters -> Add formatter then change Format from PHP to something else. If your Development setting displays errors and warnings, you'll get a javascript popup error message (Warning : preg_match_all() expects parameter 2 to be string, array given), otherwise you won't. Using the latest dev.

Thanks!

supriyarajgopal’s picture

Subscribing. Message appears in watchdog.

It could be because of this that I am unable to preview anything for an Entity Reference field in a field collection.

The latest dev version of this module solved my problem.

Regards,
Supriya Rajgopal