Page MenuHomePhabricator

`asort()` and `array_unique()` expects parameter 1 to be array, object given in "PF_ValuesUtils.php"
Closed, ResolvedPublic

Description

Setup

  • MediaWiki | 1.27.4 (4584e81)04:51, 6. Apr. 2018
  • PHP | 5.6.33-0+deb8u1 (apache2handler)
  • MySQL | 5.5.59-0+deb8u1
  • Semantic MediaWiki | 2.5.6 (33df15e) 14:09, 14. Feb. 2018
  • Page Forms 4.3 (c35e352) 18:50, 14. Mär. 2018

Issue
When using a from to create a page the following warnings are emitted:

Warning: asort() expects parameter 1 to be array, object given in /.../w/extensions/PageForms/includes/PF_ValuesUtils.php on line 638
Warning: array_unique() expects parameter 1 to be array, object given in /.../w/extensions/PageForms/includes/PF_ValuesUtils.php on line 639

Event Timeline

Do you know what in the form definition is causing this error to occur?

I have no idea. This is the form definition which basically contains no extras or complications:

{{{for template|Benutzer|label=BenutzerInnen}}}
{| class="table-hover table-responsive table-condensed"
|Foto: 
|{{{field|Foto|uploadable|default filename={{PAGENAME}}.png|values from namespace=Datei|image preview|class=form-control}}}
|-
| Titel: 
| {{{field|Titel|input type=text with autocomplete|class=form-control}}}
|-
| Vorname: 
| {{{field|Vorname|input type=text with autocomplete|class=form-control}}}
|-
| Nachname: 
| {{{field|Nachname|input type=text|class=form-control}}}
|-
| Titel (nachgestellt): 
| {{{field|Titel_nach|input type=text with autocomplete|class=form-control}}}
|-
| Telefon: 
| {{{field|Telefon|input type=text|class=form-control}}}
|-
| Mobil: 
| {{{field|Mobil|input type=text|class=form-control}}}
|-
| E-Mail: 
| {{{field|E-Mail|input type=text|class=form-control}}}
|-
| Abteilung: 
| {{{field|Abteilung|input type=tokens|values from category=Abteilungen|placeholder=auswählen bzw. eingeben...|class=form-control}}}
|-
| Funktion: 
| {{{field|Funktion|input type=tokens|values=Verantwortliche/r,Datenschutzbeauftragte/r,AbteilungsleiterIn,MitarbeiterIn|placeholder=auswählen bzw. eingeben...|class=form-control}}}
|}
{{{end template}}}

I'm guessing it's one of either "values from namespace=", "values from category=", or (maybe) "values=". Could you see if removing any of those causes the error to go away?

Affirmative, removing "values from namespace=" makes the issue go away while "values from category=" and "values=" are still in there.

@Kghbln - what input type is showing up for the "Foto" field? (With "values from namespace=" back in there.)

I believe it is "input type=text". Since $wgPageFormsSimpleUpload = true; is used only a button is shown as expected.

Okay - in that case, "values from namespace=" serves no purpose, right? (This still sounds like a bug that needs to be fixed, though maybe it's just a minor one.)

I guess you are right. :) This is actually not a form I created. I just happened to be the first one who happened to notice it.

Oh, okay. Well, I'm still curious about what exactly is happening here. Looking through the code, my guess is that the problem is coming from this line in /includes/PF_FormField.php, around line 364:

$f->mPossibleValues = PFValuesUtils::disambiguateLabels( $f->mPossibleValues );

Do you have access to the server that this wiki is running on? If so, could you put in a "print_r($f->mPossibleValues);" right above that line to see what is being passed in?

It prints all files uploaded like Array ( [MyFirstFile.jpeg] => MyFirstFile.jpeg [MySecondFile.png] => MySecondFile.png ) Array ( )

Hm, that seems fine... so maybe that's not the line causing the problems. In that case, I don't where the error is coming from.

Fair enough. Let's wait until others perhaps stumble on this with different clues or if it gets a serious issue at some point. There are currently indeed serious issues around with much higher priority I think.

@Jaideraf I guess it will be nice to add you findings to this issue report? No?

On the respective wiki I was reporting this issue for the configuration parameter $wgPageFormsUseDisplayTitle is not explicitly set. So I believe it is set to true.

@Kghbln You're right. I was a little bit confused because in 4.3 $wgPageFormsUseDisplayTitle has changed to true. [0]
So, changing it to false will vanish the warnings (but you will lose the benefits of using DisplayTitle, wich in my case is not desirable).

[0] https://www.mediawiki.org/wiki/Extension:Page_Forms/Version_history

I should have asked this before, but - could either of you let me know what the object is that's being passed in instead of an array? (A print_r() statement is probably necessary.)

I should have asked this before, but - could either of you let me know what the object is that's being passed in instead of an array? (A print_r() statement is probably necessary.)

@Yaron_Koren I am not sure what do do now. I already posted results further up T192575#4153827

Well, you added the print_r() statement to PF_FormField.php, which I thought would be helpful but turned out not to be. I'm asking about the results for print_r() statements in PF_ValuesUtils.php, where the error messages are originating from.

Yaron_Koren claimed this task.

I'm guessing that this was fixed at some point, since I haven't heard about the problem since. Feel free to re-open if not.