bmacnaughton

Pages::saved hook called even when failure

Recommended Posts

I have a hook that creates a page for a subset of the pages on our site. It uses the saved page's name as part of the created page's name.

The problem I am having is that my hook, attached to Pages::saved(), is being called even when the page save failed because of missing fields. Is there a way I can tell that the page save failed due to missing fields?

 

Never mind - it does succeed; it just issues warnings about required fields.

 

Share this post


Link to post
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


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By noelboss
      Short description of the issue
      Since PW 3.0.88: When I try to retrive a croped file using the api filesManager() and it's basename, I get the original version instead of the croped variation.
      Expected behaviour
      Looking up a variation using the path and filesManager should return the variation file.
       $page->filesManager->getFile("/path/to/filebasename.400x400.jpg"); // $file->basename > filebasename.400x400.jpg Actual behavior
      The variation is returned.
       $page->filesManager->getFile("/path/to/filebasename.400x400.jpg"); // $file->basename > filebasename.jpg  
      » Is this a bug or do I miss something here?
       
      Code:
      dump($page->filesManager->path.$input->get->filename('f')); $file = $page->filesManager->getFile($page->filesManager->path.$input->get->filename('f')); dump($file); dump($page->filesManager->path.$file->basename); Output:
      "/home/ubuntu/workspace/www/site/assets/files/-1579/colin-rex-434063.400x400.jpg" (79) ProcessWire\Pageimage #796f pageimages protected => ProcessWire\Pageimages #d195 original protected => ProcessWire\Pageimage #796f { RECURSION } variations private => null imageInfo private => array (2) width => 0 height => 0 error protected => "" pagefiles protected => ProcessWire\Pageimages #d195 data protected => array (6) basename => "colin-rex-434063.jpg" (20) description => "" tags => "" formatted => true modified => 1516025386 created => 1516025386 useFuel protected => true _instanceNum private => 870 localHooks protected => array () trackChanges private => 2 changes private => array (1) formatted => array (1) 0 => null _notices protected => array (3) errors => null warnings => null messages => null _wire protected => ProcessWire\ProcessWire #28d0 in .../www/site/templates/app/utils/download.php:29
      "/home/ubuntu/workspace/www/site/assets/files/-1579/colin-rex-434063.jpg" (71)
    • By cosmicsafari
      Hi all,
      Im a bit confused by an issue I have come across today.
      I have a module which connects to a third party (once an hour using LazyCron), parses a publicly available XML file, turns it into useable information which I then use the API to save as PW Pages.
      On the whole this has been working great however today I noticed that it kept failing on one of the imports.
      After doing some investigation I realised its appears to be dying at the save page stage.
      From the documentation $page-save() should return either True/False, so I thought I would update the code to reflect this while debugging.
      $this->log(1); $bool = $p->save(); if($bool){ $this->log('Saved successfully'); } else { $this->log('Fail to save'); } $this->log(2); However the script only gets to the save() part and then appears to terminate. Then when checking the error log the latest entry is always just '1'
      Any ideas as i'm a tad confused why I at least don't get a response of some kind?
       
       
       
    • By iNoize
      Hello, 
      for an Project i need help for an Script. 
      There is an XML File with all the Objects Data and Images for every object. 

      This is the Data Structure 
      http://prntscr.com/hvfo31


      One XML file and Pictures. 
      So every Time the new Data is Uploadet via ImmoTool there have to be maybe an batch or something or an button in the Sitebackend to check the new files. 

      If the Status is  NEW then create an Object 
      if the Status is CHANGE  then make some changes 
      If the Status is Delete then remove the Object in other Parent 

      There are Basic infos in XML like Description Rooms etc. 
      Also the latitude and attitude for the maps. 
      After succsessful changes the Folder schould be empty for the next upload. 

      I need only help to create and handle the sites with some data (PW API ). The output I will generate by myself. 


      I have some basic php code 

      Need somebody to fix it ready for me in PW. 

      Tnx 


       
    • By cosmicsafari
      Hi all,
      From my attempts it seems like this is not possible but thought I would raise it here before scrapping the idea and trying something else.
      I have an importer script reading a third party feed and creating some pages (page_type_A) based on that.
      It also creates some other pages (page_type_B) which are by default set to unpublished as the third party don't seem to have control over some of the data they send us, so we set them to unpublished so that someone on our end needs to approve them, so far so good.
      The issue I have encountered is that page_type_A at creation uses the API to set one of its fields to a particular page_type_B, the field is setup as PageSelector. When I look at the database this seems to work fine, but if you go into page_type_A the Page Selector list is always preset to blank?
      I updated the Page Selector and set the Selector String to use "include=all" which does populate the drop down with all the correct pages but since there all unpublished it never seems to be preselected to the one which is actually saved as in the DB.
      Hope that makes some sort of sense.
    • By thomasaull
      I recently started to build Vue SPAs with ProcessWire as the backend, connected with a REST API. Thanks to code and the help of @LostKobrakai (How to use FastRoute with ProcessWire) and @clsource (REST-Helper) I got it up and running pretty quickly and now have put all of it in a site profile for others to use. It includes the REST API with routing for different endpoints, JWT Auth and a simple Vue SPA which shows the process of logging in a user (nevertheless, you don't have to use the Vue part, the API will work on it's own).
      Check it out here: https://github.com/thomasaull/RestApiProfile
      I'm pretty sure, it's not the perfect or most sophisticsted solution, but it gets the job done for me…
      Feedback or Improvements are very welcome