Sign in to follow this  
cosmicsafari

Page save() method dying without output?

Recommended Posts

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?

 

 

 

Share this post


Link to post
Share on other sites

Not sure, but I would first of all look at the XML file. Has anything changed recently? What happens if you "manually" grab the XML, and update/create page(s)?

  • Like 1

Share this post


Link to post
Share on other sites

Thanks for the reply but I think I have sussed it, not sure why it was never an issue up to this point right enough.

I updated my code from above to try:

$this->log(1);
try {
     $p->save();
} catch (\Exception $e) {
     $this->log($e);
}
$this->log(2);

Which gave me an error mentioning using $p->setOutputFormatting();

So I updated to

$this->log(1);
try {
     $p->setOutputFormatting(false);
     $p->save();
} catch (\Exception $e) {
     $this->log($e);
}
$this->log(2);

Which appears to have fixed the issue.

:)

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

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Harmen
      Hello all,
      Was wondering if any of you tried to include the Exact PHP client by Picqer in Processwire (URL)? I am trying to at the moment but I am stuck at the Authorization process. Building it inside a module file to execute a certain function every 6 hours to update something on the website. For the authorization process the file has to execute the following piece of code:
      header('Location:'. $urlThatRedirectsMeToTheLoginOfExact); But each time I am trying  to do so, I get the following error: Cannot modify header information - headers already sent by (output started at /processwire/index.php:55). I am out of options so that's why I am trying to find someone who used this library and could get it to work or someone who knows how I can fix it.
      Tips are highly appreciated (if they work ;))
      Cheers, Harmen
    • 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 JurgenP
      First of all I'm as new to ProcessWire (PW) as they come, so bear with me if I ask stupid questions with obvious answers.
      I started looking into PW because I'm looking for something that would take out some of the grunt work of building an applications, yet be flexible enough to be able to implement custom functionality.
      I'm trying to work out if PW is suitable for my needs, ...
      A the moment I'm trying to create an architecture for a web platform on which multiple websites/webshops (750-1000) for pharmacists will be run.
      The websites will have different types of information, obviously there will be the 'own' pages the pharmacists create themselves.
      But as pharmacists tend 'not to be computer people' there is also content provided by the platform to make the site look alive, as well as public health information provided by the goverment.
      I was wondering if there is a way to structure/set up PW so that they have full access to their own content, and limited access (basically chose to publish it or not) to the externally provided content.
      Also is there a way to have the templates/page for the own content located in their own folder, and the 'external ones' in a shared folder so that they don't have to be repeated 1000 times on the server (and if modifications need to be done, it only has to be done once as well).
      Sincerely,
      Jurgen
    • By nickngqs
      Does anyone know how to do an export of a page entries to CSV using the Processwire way?
      I'm trying to setup a list where the client can see a list of user's form values.

      Example ->
      A front end form -> Upon submit -> Adds to database -> Shows on the admin of Processwire.

      From there, I can see the entries and sort stuff. And lastly I can export them in CSV.

      I'm looking at the Processwire cheatsheet and see the $files, is this the one I should be looking at? 
    • 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