Jump to content

Error when template name contains only numbers


apeisa
 Share

Recommended Posts

I usually put my issues on github, but I didn't figure how to post screens there, so I put this one here. I think similar problem is on user listing, so probably little problem on code that generates the table markup.

But the screenshot probably tells everything that is needed. Running on latest version of P21.

post-79-132614277901_thumb.gif

Link to comment
Share on other sites

Thanks for the report. I haven't seen this and I've been adding templates all week–developing 2 sites like a madman. :) Is there anything I need to do to duplicate this or browser I need to test in? I've been using mostly FF5 mostly and Chrome 12 a little less so. If you select that area and 'view source', do you see any obvious problems in the markup? I'm not seeing anything on mine, but of course this problem could be somewhere else and just affecting the table. I'll do some testing with a validator. But based on what you see, do you have any thoughts as to what the problem is? (markup error, javascript, etc.?)

Link to comment
Share on other sites

Thanks for the report. I haven't seen this and I've been adding templates all week–developing 2 sites like a madman. :) Is there anything I need to do to duplicate this or browser I need to test in?

You did try with template name that contains only numbers? I tried again with name "123" and same error. Here is the markup that table contains:

	<tr>
		<td>edit?id=51</td>
		<td>0</td>
		<td>1</td>
		<td></td>
	</tr>
	<tr>
		<td><a href='edit?id=40'>home</a></td>
		<td>1</td>
		<td>1</td>
		<td></td>
	</tr>

Similar error is also when you create a user with name that is only numbers.

Link to comment
Share on other sites

I'm an idiot. I never read the subject line, just the message. I completely missed the part about the template name containing only numbers... time for me to get a cup of coffee and wake up. :)

Link to comment
Share on other sites

This has been fixed in the latest commit. It also pointed out something strange about PHP arrays that I did not know before. PHP will convert strings with only digits in them to be integers when used as array indexes. I had expected that an explicit string would stay a string, but apparently PHP does a type conversion of digit-based strings to integers. The solution is to add some non-digit character (like a space) to the string you want to use an array index, if it happens to consist of digits (despite being a string!).

Here is a test case and the results:

test.php

<pre>
<?php

$var1 = "123";
$var2 = "456 ";

var_dump($var1);
var_dump($var2); 

$a = array(
    $var1 => "foo", 
    $var2 => "bar"
    );

var_dump($a);

And the resulting output:

string(3) "123"
string(4) "456 "
array(2) {
  [123]=>
  string(3) "foo"
  ["456 "]=>
  string(3) "bar"
}

Strange, IMO.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...