Jump to content


Photo

Admin Data Table and rows starting with numbers cause problems

bug

  • Please log in to reply
7 replies to this topic

#1 teppo

teppo

    Sr. Member

  • Members
  • PipPipPipPip
  • 388 posts
  • 385

  • LocationFinland

Posted 22 May 2012 - 02:11 AM

For some reason Admin Data Table breaks when you insert a row which starts with number. See attached screenshot -- link doesn't show up and instead it's URL is printed out as plain text. Screenshot is from (unmodified) admin/users, but I'm seeing same strange behavior when adding rows to custom made Admin Data Table too.

So far I've tested this with 2.1 and 2.2 and I'm seeing same bug in both.

Can anyone else produce this or is there something wrong with my PW installation(s)?

Attached Thumbnails

  • users_table_problem.png


#2 Soma

Soma

    Hero Member

  • Moderators
  • 3,205 posts
  • 1757

  • LocationSH, Switzerland

Posted 22 May 2012 - 04:56 AM

I can't reproduce this. Works all as it should.

But I think you're missing the "setEncodeEntities" setting.


$dt = $this->modules->get("MarkupAdminDataTable");
$dt->setEncodeEntities(false);
...

@somartist | modules created | support me, flattr my work flattr.com


#3 teppo

teppo

    Sr. Member

  • Members
  • PipPipPipPip
  • 388 posts
  • 385

  • LocationFinland

Posted 22 May 2012 - 06:01 AM

@soma, actually I failed to explain this properly. It's not enough that name starts with a number, it must BE a number.

As far as I can see, this seems to be caused by function "row" of MarkupAdminDataTable.module, more specificly this check:

	if(is_string($k)) {
		// Associative arrays get converted to:
		// Anchor Text => URL
		$v = "<a href='$v'>" . $this->encode($k) . "</a>";
	} else {
		$v = $this->encode($v);
	}

So unless I'm missing something, 123 (username in this test) isn't a string (is_string($k) === false) and because of that link isn't created (and name is dumped.) Right? :)

#4 Soma

Soma

    Hero Member

  • Moderators
  • 3,205 posts
  • 1757

  • LocationSH, Switzerland

Posted 22 May 2012 - 06:42 AM

Ah, sorry I didn't get it that's on user list.

You're right, user names with only numbers breaks the output.

In DataTable, if a row array entry is a key=value, where value would be a url, it will be outputed as link automaticly...

$row["username"] = "edit/?=123";

This is the code that does it on user list in ProcessPageType.module :


foreach($fieldNames as $name) {
    if(!$n) $row[(string)$page->get($name)] = "edit/?id={$page->id}";
        else $row[] = $this->renderListFieldValue($name, $page->get($name)); 
    $n++;
}

So you're right. Even though the key should be a (string) it doesn't work with a number.

@somartist | modules created | support me, flattr my work flattr.com


#5 slkwrm

slkwrm

    Sr. Member

  • Members
  • PipPipPipPip
  • 248 posts
  • 66

Posted 22 May 2012 - 07:57 AM

I had this problem with as far as I remember languages list some time ago, but I could not reproduce it afterwards, so didn't report back then.

#6 renobird

renobird

    Sr. Member

  • Members
  • PipPipPipPip
  • 374 posts
  • 236

  • LocationGainesville, Florida

Posted 22 May 2012 - 08:36 AM

I have this same problem as well. All my user names are numbers.

#7 ryan

ryan

    Hero Member

  • Administrators
  • 5,780 posts
  • 3124

  • LocationAtlanta, GA

Posted 22 May 2012 - 11:01 AM

Despite that number being typecast to a string, it looks like PHP actually typecasts it back to an integer if the string contains only digits, when creating an array index. I found that I could get PHP to keep it as a string if I appended a non-digit character to the end of it (space). I just committed the update, so this issue should be fixed. Since this PHP typecasting behavior is a little unexpected, I'm just hoping the behavior is the same across PHP versions. Let me know if you find there is still an issue.

#8 teppo

teppo

    Sr. Member

  • Members
  • PipPipPipPip
  • 388 posts
  • 385

  • LocationFinland

Posted 22 May 2012 - 11:31 AM

Seems to work now. Thanks Ryan! :)





Also tagged with one or more of these keywords: bug

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users