Jump to content

Error when adding a "0" page?


sn4ke
 Share

Recommended Posts

Good evening,

I think I may have found a bug in the current release (PW 2.2.5) - I tried to add a new page which is called "0/" (URL "/gallery/0/").

Problem is, I could not save the page - The following error appeared:

Error Call to a member function error() on a non-object (line 267 of ...\wire\modules\Process\ProcessPageAdd\ProcessPageAdd.module)

I havent looked into it, but taking a wilkd guess I'd say there's a check on an "empty" URL?

I created another page called "test" (URL "/gallery/test/") and edited it, after creation - It worked.

Link to comment
Share on other sites

I can reproduce this too. This is a bug, as it should allow a page named "0". Sn4ke I think you are right, that there is likely an empty() check somewhere there should be a !strlen() check. Unfortunately I can't seem to find where it is yet, so going to add this to the issues list until I've got more time to get deeper into it. Btw, the error message you got is actually something different, and I have fixed that. The actual error message is "Can't add because that page already exists."

Link to comment
Share on other sites

The error is here: (from w/core/mod/Proc/PPA/ProcessPageAdd.module:265)

$this->parent->child("name=$name")->id

This code actually returns id of first child of 'parent', so I'd look either in query builder or for MySQL bug.

Edit: DEBUG Log from the query:

 array(4) {
   ["time"]=>
   string(21) "0.26071100 1347894072"
   ["action"]=>
   string(4) "find"
   ["details"]=>
   string(51) "parent_id=1007, name=0, limit=1, start=0, sort=sort"
   ["result"]=>
   string(4) "1008"
 }

Edit: tested query with mysql

select * from pages where name=0

returns all pages.

Link to comment
Share on other sites

I think it's the way PW handles selector values, see my comment on the issue at GitHub (for some reason I thought it was better to comment there at first - could have said something here as well).

That field (pages.name) is a varchar(128) but whenever a page name that can be interpreted as an integer is given, the value in the SQL query is not quoted and thus not interpreted as a string as it should be when the field is declared as varchar.

This may get tricky so I didn't want to go any deeper myself - I'll let Ryan do his magic :).

Link to comment
Share on other sites

This is now fixed in the latest commit. https://github.com/ryancramerdesign/ProcessWire/commit/4b5f8e7aacd56d52dd82f84211870d20492d7520

Basically was converting something to an integer that shouldn't have been converted. Only appeared to affect pages named "0", but the fix was easy and well isolated. Thanks to Nik for helping me to track it down.

Link to comment
Share on other sites

  • 3 weeks later...

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

×
×
  • Create New...