adrian

Module
Migrator

286 posts in this topic

Hey Joss - thanks for the file.

The issue was with some broken images embedded into your blog posts - some linking to an old joomla site :). Migrator now handles broken images properly so no errors.

I also took the opportunity to add a few more fixes and enhancements to embedded images and captions - links to the original sized version now also work (although I am wondering the best way to add a class for lightbox display of these. I don't want to assume the class that users want, so maybe this needs to be a configurable setting - any thoughts?).

Please try the latest versions of both ProcessMigrator and MigratorWordpress (again from my fork) and let me know how you go.

Here's a screenshot of what one of blog posts looks like for me once imported. Be patient - it can take quite some time to download all those images, but it will work :)

post-985-0-51869800-1417570430_thumb.png

1 person likes this

Share this post


Link to post
Share on other sites

I think with the lightbox side you could add a field for a class, but some lightboxes need more than that and it could get complicated. Maybe a note in the instructions that this might be something better handled with a bit of javascript on the fly. I might find a mix between the two useful - adding a class at processing at least identifies the image and then one could decide what to do later.

On the other hand, a blog might not always have images linked to bigger version - so not sure what to do then....

Share this post


Link to post
Share on other sites

Am not importing a JSON its a wordpress.xml am trying to import to Processwire using Nico's MigratorWordpress. wow that was a fast response

Share this post


Link to post
Share on other sites

Any finally got it to import my contents but i had to comment the following

 
if(empty($fp)){



                $this->error("Missing required ZIP or JSON Source");
                if($this->session->migratorFilesDir && file_exists($this->session->migratorFilesDir)) $this->recursiveDelete($this->session->migratorFilesDir);
                //$this->session->redirect('./'.$this->session->type);
                return $form->render();
            }

Share this post


Link to post
Share on other sites

I am not really sure on why that would happen - did the import actually work properly after commenting out that check?

The fact that $fp is empty at that point in the code suggests that the conversion from the xml into a json file ready for parsing by migrator didn't work. But if it all worked as expected for you, then I'll just add it to my list of things to keep an eye on.

Share this post


Link to post
Share on other sites

Ignore what i wrote it imported also without the comment, am still going to look at it again in the morning take care

Share this post


Link to post
Share on other sites

I am not sure why you are getting that missing required zip or json error, but it would be helpful if you could PM me the xml file so I can test. 

I don't really understand what is wrong in the second image you posted.

To attach images here, you need to click the "More Reply Options" button.

Share this post


Link to post
Share on other sites

Thanks - I have been doing lots of testing with your file and can't replicate the "missing required zip or json" error. I did however find some bugs regarding image import in certain situations that I have just fixed, so please grab the latest versions of both Migrator and MigratorWordpress.

I will send some screenshots showing the properly imported content in reply to the PM you sent.

In an attempt to figure out why you are getting that error, can you please try logging the value of: $this->session->jsonFilename and also uncomment the exit on line 882. Then make sure that there is some json content in the file at the path that should be stored in: $this->session->jsonFilename

Share this post


Link to post
Share on other sites

Thanks now i am more encourage knowing it works on your end. I will do as specified and debug it and monitor the variables. I wanted to be sure I wasn't an exception thanks alot andrian.

1 person likes this

Share this post


Link to post
Share on other sites

While trying to get some contents into my site i got the following issue, been familiar with PHP Development I tried looking for codes that tried to do the similar:

$SessionFakeObject->set('keyStore',$DatabaseInstance);

As the above will cause the $DatabaseInstance to be serialized which is not allowed, however I have tried debugging and can't really point what could be the cause (also my Zend Debugger is busted) so if anyone has experienced such error please respond so i look at how to fix it. 

As for the previous error am behind a Firewall so that's explainable

post-2850-0-03174200-1419933727_thumb.pn

Share this post


Link to post
Share on other sites

Sepiroth - I moved your post here, because all those relate to Migrator.

The first one regarding Github is surprising - perhaps they were down momentarily. Please let me know if you continue to see that one.

The serialize error is also a mystery to me - I see it occasionally when I use Migrator - it seems to be random and it doesn't seem to affect the import process. I don't do any database serialization in the module at all. I need to investigate further at some point, but I think for the moment it can be safely ignored.

Share this post


Link to post
Share on other sites

Sepiroth - I moved your post here, because all those relate to Migrator.

The first one regarding Github is surprising - perhaps they were down momentarily. Please let me know if you continue to see that one.

The serialize error is also a mystery to me - I see it occasionally when I use Migrator - it seems to be random and it doesn't seem to affect the import process. I don't do any database serialization in the module at all. I need to investigate further at some point, but I think for the moment it can be safely ignored.

The first one is all me I work in Switching company (Online Payment and all), so our firewall is pretty strong so that I know is as a result of the firewall, however the second error which is quite confusing because there's no assign of any Database instance in a session in your code. so am wondering how that's happening. Spent the whole night trying to get my Zend Debugger working but failed once its up i will check the Debug steps. 

Share this post


Link to post
Share on other sites

Okay so i switched to Xdebug and spent the whole night debugging and during the Xdebug it never broke at ll, it converted the code and returned the json and exited as expected. This has nothing to do with the Module/Processwire if not i should have been thrown an exception during the debugging. so i will research more on this but i took out the thirdparty.json it outputted after monitoring the code. will simply import that and move on with life. 

Share this post


Link to post
Share on other sites

All the Post imported into ProcessWire from WordPress thanks alot am really glad thanks for the support.

post-2850-0-38131100-1420126463_thumb.pn

1 person likes this

Share this post


Link to post
Share on other sites

Very glad it is working for you as expected. But I am curious what, if any changes you made. Did the Github issue fix itself?

What about the missing zip/json error - was that just a result of the exit code commenting?

Is there anything else I should know about?

Thanks again for your extensive testing - did you ever figure out anything around that serialization error?

Share this post


Link to post
Share on other sites

The exit code stops the script so it was the main reason i assumed the PDOException halted it but when i commented it, the script works perfectly. I no longer get the Missing Json or Zip Source message. As for the PDO Serialization issue i guess it's something we have to keep in mind, I have researched and scanned all PW source code I can't see any reason why it should. but I will occasionally look into it gradually. 

1 person likes this

Share this post


Link to post
Share on other sites

Hi, I'm trying to import pages with images from a website to another (PW 2.5.3 both) using migrator module, but I get errors and it doesn't work for me.


The errors appear during import.


I set the home as parent and then I click "upload and create content" button and the result are shown in this images.


 


error1a.jpg


 


error1b.jpg


 


 


If instead I check "Edit Imported content", after I click "Upload and create content" button, everything seems to work but in the end of the page I have this error


 


error2.jpg


 


And after when I click "Create Content" I have this one


 


error3.jpg


 


This the first time I use migrator. Thank you for any help.


Share this post


Link to post
Share on other sites

Has anyone tried importing an XML the size of 30mb when i try to nothing happens it just renders the same page. will try increasing my post_max_size and see what happens.

Share this post


Link to post
Share on other sites

Okay so increasing post_max_size works but if it's lower it fails silently so maybe a feature would be a message that checks the size of file against the ini_get('post_max_size') and display that to the user. should i create a pull-request for that ? Happy Sunday

1 person likes this

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 abdus
      After this tutorial you'll have learned how to:
      Build a Process module Make an AJAX request to backend Serve JSON as response Let's say you want to display the latest orders in a dashboard that you can access from admin panel. And you want it to refresh its content with a button click. Most straightforward and proper way (that I know of) is to create a Process module, as they're built for this purpose.
      First, create a directory under /site/modules/, call it ProcessDashboard, and create a file named ProcessDashboard.module under that directory. Following is about the least amount of code you need to create a Process module.
      <?php namespace ProcessWire; class ProcessDashboard extends Process { public static function getModuleInfo() { return [ 'title' => 'Orders Dashboard', 'summary' => 'Shows latest orders', 'version' => '0.0.1', 'author' => 'abdus', 'autoload' => true, // to automatically create process page 'page' => [ 'name' => 'order-dashboard', 'title' => 'Orders', 'template' => 'admin' ] ]; } public function ___execute() { return 'hello'; } } Once you refresh module cache from Modules > Refresh, you'll see your module. Install it.

      It will create an admin page under admin (/processwire/) and will show up as a new item in top menu, and when you click on it, it will show the markup we've built in execute() function.

       
      All right, now let's make it do something useful. Let's add create a data list to display latest orders. We'll change execute() function to render a data table.
      public function ___execute() { /* @var $table MarkupAdminDataTable */ $table = $this->modules->MarkupAdminDataTable; $table->setID($this->className . 'Table'); // "#ProcessDashboardTable" $table->headerRow([ 'Product', 'Date', 'Total' ]); // fill the table foreach ($this->getLatest(10) as $order) { $table->row([ $order['title'], $order['date'], $order['total'] ]); } // to refresh items $refreshButton = $this->modules->InputfieldSubmit; $refreshButton->name = 'refresh'; $refreshButton->id = $this->className . 'Refresh'; // "#ProcessDashboardRefresh" $refreshButton->value = 'Refresh'; // label of the button return $table->render() . $refreshButton->render(); } where getLatest() function finds and returns the latest orders (with only title, date and total fields)
      protected function getLatest($limit = 5, $start = 0) { // find last $limit orders, starting from $start $orders = $this->pages->find("template=order, sort=-created, limit=$limit, start=$start"); // Only return what's necessary return $orders->explode(function ($order) { return [ 'title' => $order->title, 'date' => date('Y-m-d h:i:s', $order->created), 'total' => $order->total ]; }); } When you refresh the page, you should see a table like this

      Now we'll make that Refresh button work. When the button is clicked, it will make an AJAX request to ./latest endpoint, which will return a JSON of latest orders. We need some JS to make AJAX request and render new values. Create a JS file ./assets/dashboard.js inside the module directory.
      window.addEventListener('DOMContentLoaded', function () { let refresh = document.querySelector('#ProcessDashboardRefresh'); let table = document.querySelector('#ProcessDashboardTable'); refresh.addEventListener('click', function (e) { // https://developer.mozilla.org/en/docs/Web/API/Event/preventDefault e.preventDefault(); // Send a GET request to ./latest // http://api.jquery.com/jquery.getjson/ $.getJSON('./latest', { limit: 10 }, function (data) { // check if data is how we want it // if (data.length) {} etc // it's good to go, update the table updateTable(data); }); }); function renderRow(row) { return `<tr> <td>${row.title}</td> <td>${row.date}</td> <td>${row.total}</td> </tr>`; } function updateTable(rows) { table.tBodies[0].innerHTML = rows.map(renderRow).join(''); } }); And we'll add this to list of JS that runs on backend inside init() function
      public function init() { $scriptUrl = $this->urls->$this . 'assets/dashboard.js'; $this->config->scripts->add($scriptUrl); } Requests to ./latest will be handled by ___executeLatest() function inside the module, just creating the function is enough, PW will do the routing. Here you should notice how we're getting query parameters that are sent with the request.
      // handles ./latest endpoint public function ___executeLatest() { // get limit from request, if not provided, default to 10 $limit = $this->sanitizer->int($this->input->get->limit) ?? 10; return json_encode($this->getRandom($limit)); } Here getRandom() returns random orders to make it look like there's new orders coming in. 
      protected function getRandom($limit = 5) { $orders = $this->pages->find("template=order, sort=random, limit=$limit"); return $orders->explode(function ($order) { return [ 'title' => $order->title, 'date' => date('Y-m-d h:i:s', $order->created), 'total' => $order->total ]; }); } And we're done. When refresh button is clicked, the table is refreshed with new data.
      Here it is in action: 
      2017-04-29_19-01-40.mp4 (227KB MP4, 0m4sec)
      Here's the source code:
      https://gist.github.com/abdusco/2bb649cd2fc181734a132b0e660f64a2
       
      [Enhancement] Converting page titles to edit links
      If we checkout the source of MarkupAdminDataTable module, we can see we actually have several options on how columns are built.
      /** * Add a row to the table * * @param array $a Array of columns that will each be a `<td>`, where each element may be one of the following: * - `string`: converts to `<td>string</td>` * - `array('label' => 'url')`: converts to `<td><a href='url'>label</a></td>` * - `array('label', 'class')`: converts to `<td class='class'>label</td>` * @param array $options Optionally specify any one of the following: * - separator (bool): specify true to show a stronger visual separator above the column * - class (string): specify one or more class names to apply to the `<tr>` * - attrs (array): array of attr => value for attributes to add to the `<tr>` * @return $this * */ public function row(array $a, array $options = array()) {} This means, we can convert a column to link or add CSS classes to it.
      // (ProcessDashboard.module, inside ___execute() method) // fill the table foreach ($this->getLatest(10) as $order) { $table->row([ $order['title'] => $order['editUrl'], // associative -> becomes link $order['date'], // simple -> becomes text [$order['total'], 'some-class'] // array -> class is added ]); } Now, we need to get page edit urls. By changing getLatest() and getRandom() methods to return edit links in addition to previous fields
      protected function getLatest($limit = 5, $start = 0) { // find last $limit orders, starting from $offset $orders = $this->pages->find("template=order, sort=-created, limit=$limit, start=$start"); return $orders->explode(function ($order) { return [ 'title' => $order->title, 'date' => date('Y-m-d h:i:s', $order->created), 'total' => $order->total, 'editUrl' => $order->editUrl ]; }); } protected function getRandom($limit = 5) { $orders = $this->pages->find("template=order, sort=random, limit=$limit"); return $orders->explode(function ($order) { return [ 'title' => $order->title, 'date' => date('Y-m-d h:i:s', $order->created), 'total' => $order->total, 'editUrl' => $order->editUrl ]; }); } and tweaking JS file to render first column as links
      function renderRow(row) { return `<tr> <td><a href="${row.editUrl}">${row.title}</a></td> <td>${row.date}</td> <td>${row.total}</td> </tr>`; } we get a much more practical dashboard.

       
    • By abdus
      I'm building a module using Comments field as reference. Inside Comments module and many others, there's always this expression which is used to inject dependencies (according to Wire class documentation)
      $fieldset = $this->wire(new InputfieldWrapper()); Is there a reason for injecting API variables inside objects? Because everything seems to work fine without.

    • By matjazp
      Module: Auto Smush PDF
      https://github.com/matjazpotocnik/AutoSmushPDF 
      Compress PDF files automatically on upload,  manually by clicking the link for each file and in bulk mode for all PDF files.
      In Automatic mode PDF files that are uploaded are automatically compressed.
      In Manual mode "Compress" link will be present. This allows manual compression of the individual PDF file.
      In Bulk mode all PDF files can be compressed in one click. Will process PDF files sitewide, use with caution! 
      Using https://labstack.com/, free (at the moment) online web service that provides compressing of PDF files. There is no limit in file size and no limit on number of uploaded PDF's. No privacy policy available. 
       
      EDIT April 30 2017: This module is not working anymore as Labstack removed support for pdf compression.
    • By justb3a
      Little admin helper module: Using this module you can view all template cache settings at once. E.g. cache status, cache time (configurable). Furthermore it adds the functionality to clear the entire template cache or just the template cache for a given template. Note that this may cause a temporary delay for one or more requests while pages are re-cached.

      GitHub: https://github.com/justb3a/processwire-templatecacheoverview
    • By blad
       
      Hi guys!
      I'm creating a module to manage, edit, publish ... pages. It is very similar to ProcessBatcher.
       
       
      Changelog:
      In progress 
      Features:



      Select pages with your mouse like a desktop enviroment. If you press "edit" the selected pages will appear in a lightbox.


      Drag pages to do actions.
      Any feedback is welcome