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

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Similar Content

    • By JeevanisM
      Hi,
      I have installed 1 year old project backup into the new latest PW version. I used an earlier backup(taken in August 2020) and installed such as :
      1. I downloaded the latest (ProcessWire 3.0.185 dev © 2021) then extracted into htdocs 2. copy pasted the site-profile from my backup. (this has the files/folders same as other site profiles, classic, beginner etc) 3. I chose my backup site profile and installed 4. I am able to login the admin panel  5. My fronted home page shows error as below  Error: Exception: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'page_path_history.language_id' in 'field list' (in wire/modules/PagePathHistory.module line 752) #0 wire/modules/PagePathHistory.module (752): PDOStatement->execute() #1 wire/core/PagesPathFinder.php (1014): PagePathHistory->getPathInfo('/', Array) #2 wire/core/PagesPathFinder.php (222): PagesPathFinder->getPathHistory('/') #3 wire/core/PagesRequest.php (255): PagesPathFinder->get('/', Array) #4 wire/core/Wire.php (414): PagesRequest->___getPage() #5 wire/core/WireHooks.php (951): Wire->_callMethod('___getPage', Array) #6 wire/core/Wire.php (485): WireHooks->runHooks(Object(PagesRequest), 'getPage', Array) #7 wire/modules/Process/ProcessPageView.module (10 This error message was shown because: you are logged in as a Superuser. Error has been logged.
       
      so I removed the line where its selecting language_id from the file wire/modules/PagePathHistory.module line 752
      But this is an ugly fix, so is there any other proper fix for this issue ? Does any one experience same issue when trying to install from a backup site profile ? 

       

       
       thanks
       
    • By spercy16
      I was hoping to be able to do this entirely in PHP but was having all kind of issues getting it to see my values as numbers instead of strings (got error messages because my PW debugging is currently set to true). I currently have about 10 cards that PW is generating that include thumbnails, descriptions, donation amounts (raised amounts and goal amounts), and donate buttons. What I was trying to do was take the goal amount divide it by the raised amount (using PHP) and simply insert that value into the Progress element's Value attribute. Sounded simple enough but I couldn't get PHP to simply divide those two fields. First I tried dividing the goal value by the raised value and inserting it into the value attribute, like so:
      <? php $raised = $page->get("raisedAmount$count"); $goal = $page->get("goalAmount$count"); $percent = $goalNum / $raisedNum; ?> <progress value="<?php echo $percent; ?>" max="100"></progress> Which gave me this error message:
      Uncaught TypeError: Unsupported operand types: string / string
      Then I tried converting the two strings to integers because apparently PHP couldn't detect they were numbers and do it, like so:
      <?php $raised = $page->get("raisedAmount$count"); $goal = $page->get("goalAmount$count"); $goalNum = (int) $goal; $raisedNum = (int) $raised; if ($raisedNum != 0) : $percent = $goalNum / $raisedNum; else: $percent = 0; endif; ?> <progress value="<?php echo $percent; ?>" max="100"></progress> but all of the progress bars remain at zero percent (not shown), even when I have values in some of the $raised variables.
      Please note, if I add this code:
      <?php echo $percent; ?> below the Progress element, it shows 0 on every single card, so the $percent is never calculated (as per the $percent = $goalNum / $raisedNum;) even though $raisedNum should not equal 0 during that iteration of the loop (the original code includes a loop, which I omitted to keep the code sections above smaller, notice the $count at the end of the $raised and $goal variable declarations). When the loop goes over "raisedAmount1" there is a value in there; however, after typecasting it to an integer ($raisedNum) the value is 0 for someodd reason instead of 40,000, which is what is in the $raisedAmount1 field in Processwire...
      I'm new to relatively new to PHP and Processwire and could really use some help on this one. Thanks in advance for any helpful replies!
    • By rjgamer
      Hi,
      is there a hook after the current (active) page got created? Or which method got called in the Page class after the Constructor of the current page got initialized?
      Thanks.
       
    • By rjgamer
      Hi guys,
      the field "redirect_last" of type DateTime got not updated. The update on the field "redirect_counter" works and got saved.
      Does anybody know what I did wrong in my code?
      if ($input->urlSegment(1) === 'redirect') { $page->of(false); $page->redirect_last = time(); $page->redirect_counter += 1; if ($page->save('redirect_counter')) { $session->redirect($page->website_url, 302); } } Thanks.
    • By theoretic
      Hi there! And thanks for Processwire!
      I have an interesting task which i cannot fulfill as i want. Maybe someone could help me please?
      Let's imagine a simple page structure of this kind:
      Category 1
      + Item 1.1
      + Item 1.2
      Category 2
      + Item 2.1
      + Item 2.2
      My task is to attach some items to more than one category, at least to show some items on different frontend category pages. With PW, it's a piece of cake. I've just created a field called Items (of type Page Reference) and attrached it to Category template. Since i have lots of items inside each category i preferred to use Page Autocomplete input for my Items field. The pages available for autocomplete are restricted by a very simple selector:
      template=item
      It works like a charm. But later i decided to make this autocomplete even smarter and to exclude current category children items from it. I tried to update my selector this way...
      template=item,parent!=(page)
      ...and oops, this broke my selector. My autocomplete founds nothing. Sorry, i had to replace the square braces by () because of this forum limitations, i swear i'm using square brackets in real-life selector!
      What am i doing wrong? And is there any way to include current page info in autocomplete-related selectors? Thanks in advance!
       
×
×
  • Create New...