plugin don't work anymore after changing siteurl

Closed
ImportWP Pro - WordPress XML & CSV Importer ImportWP Pro - WordPress XML & CSV Importer April 26, 2019
Login to reply
gael dompeyre
3 months ago
Resolved.
gael dompeyre
3 months ago

Hi again.

Everythings seems to be fine. I'll will check during the next imports but thanks a lot.
I must say that this is the first time I had such a reliable and serving support service.
Can you send me your mail at g.dompeyre@aspodelk.net ? I'm interested having you to work for me on others cases that have nothing to do with this.

And by the way, have you a website or references of your personnal work?

You may close this ticket.

Regards.

James Collings Support Agent
3 months ago

For the cron to be setup you create an new importer that fetches a csv file from either a remote url, or from the servers local filesystem.

Your attachment downloads are returning the error: "Error: curl_setopt(): CURLOPT_FOLLOWLOCATION cannot be activated when an open_basedir is set", was this working before changing site url? I have modified the importer to use an old method since you are using a very old version of php and ran the import and it appears to be working: http://dompeyre-lestrade.com/listing/villa-de-plain-pied-avec-sous-sol-castelsarrasin/

To seperate the extra code from the functions file you can remove it from the functions.php file and create a php file with the scripts and add it to /wp-content/mu-plugins/ directory.

Working functions file code:

<?php

add_action('iwp/importer/file_uploaded', function($attachment, $importer_id){

 if(isset($attachment['dest']) && file_exists($attachment['dest'])){

  $contents = file_get_contents($attachment['dest']);
  $contents = str_replace('!#', ',', $contents); // §
  $contents = str_replace('"Vente"','"Buy"', $contents);
  $contents = str_replace('"Location"','"Rent"', $contents);
  file_put_contents($attachment['dest'], $contents);
 }

}, 5, 2);

function jciwp_set_file_encoding($encoding, $importer_id){

 // set encoding
 $encoding = 'Windows-1252';
 return $encoding;
}
add_filter('iwp/importer/file_encoding', 'jciwp_set_file_encoding', 10, 2);

function jciwp_strip_querystring_from_image_ext( $destination){

 // Check to see if filename has ? in it
 $pos = strpos($destination, '?');
 if($pos > 0){
  $destination = substr($destination, 0, $pos);
 }

 return $destination;
}
add_filter('iwp/attachment/filename', 'jciwp_strip_querystring_from_image_ext');
gael dompeyre
3 months ago

Ok it worked but sorry not for the pics; they appear in the preview of the import but are not correctely recorded : ex http://dompeyre-lestrade.com/listing/villa-de-plain-pied-avec-sous-sol-castelsarrasin/ but should have a slider before the text "Ref: 3536
Secteur : castelsarrasin – Type: maison/villa – Prix: 465000 €
Surface: 272 m2 – Surface terrain : 4689 m2...."

And after thaht, two last questions:
> how to do without adding code in the funtions.php (to avoid erasing after update)
> how to have a cron launching the import?

gael dompeyre
3 months ago

Hi again, the preview seems to be weel. I test it right one.

James Collings Support Agent commented privately
James Collings Support Agent
3 months ago

Why when i have my code commented out in your functions file does it still convert !# to § , what process that is doing this is causing issues with the importer.

If it was to change the !# to a comma, this would fix the issues because this character § is actually 2 chracters which is what we are trying to fix by moving away from !#

Changing the !# to , will not break the csv as all , within the columns are between " which means they are not mistaken for the seperators.

gael dompeyre
3 months ago

For having the fastest, here is the original zip file which contain the csv. It worked with that.

James Collings Support Agent
3 months ago
Can you attach a copy of the file that is using #! and i can test it
gael dompeyre
3 months ago
And I think that if you change #! to § it will work again because, and I'd like to know how, your code allowed it to retreive the csv file.
gael dompeyre
3 months ago

To be very prefcise: before the changing of url, it worked, after it's not working.

James Collings Support Agent
3 months ago
So if you import that file it works (based on the preview text)? http://dompeyre-lestrade.com/wp-admin/admin.php?page=jci-importers&import=918&action=edit
gael dompeyre
3 months ago
I've just checked in the back-office: the csv file is now read but the use of the "," generates mistakes.
I've just seen your answer, so here it is.
I couldn't download with ftp, so I've opened it and paste it in notepad++ before recording it.
James Collings Support Agent
3 months ago
Can you please attach the csv that has a §
gael dompeyre
3 months ago

But note that before the changing of url, your plugin worked perfectly with the same files: so it's not a problem of encoding character.

gael dompeyre
3 months ago
Hi thanks but we can't use a "," because this character is often used in the description field of the csv: that's why I selected the § which is never used by my client in its texts.
But the changing is made with an another file called bi.php located in the same folder as the csv file.
James Collings Support Agent
3 months ago

Hi,

I have updated the code in your themes functions.php file:

add_action('iwp/importer/file_uploaded', function($attachment, $importer_id){



    // Limit it to a specific importer id

   if(918 === $importer_id){

        if(isset($attachment['dest']) && file_exists($attachment['dest'])){


            $contents = file_get_contents($attachment['dest']);


$contents = str_replace('!#', ',', $contents); // §
$contents = str_replace('"Vente"','"Buy"', $contents);
$contents = str_replace('"Location"','"Rent"', $contents);


            file_put_contents($attachment['dest'], $contents);

        }

    }


}, 10, 2);

function jciwp_set_file_encoding($encoding, $importer_id){
 if(918 === $importer_id){
  $encoding = 'Windows-1252';
 }
 return $encoding;
}
add_filter('iwp/importer/file_encoding', 'jciwp_set_file_encoding', 10, 2);

function jciwp_strip_querystring_from_image_ext( $destination){

 // Check to see if filename has ? in it
 $pos = strpos($destination, '?');
 if($pos > 0){
  $destination = substr($destination, 0, $pos);
 }

 return $destination;
}
add_filter('iwp/attachment/filename', 'jciwp_strip_querystring_from_image_ext');

For some reason the !# is still being changed to a § when it should be changed to a ",", do you have any other code is changing this, or does your server have opcache, apc cache, or anything like that?

Because of the file encoding you are using "Windows-1252" the character "§" is displayed as  "§" which is why we need to use a comma.

James

gael dompeyre
3 months ago

Hi,

Splet well?

gael dompeyre
3 months ago

Hi,

I don't have an error log but i've turn the debug mode to true and when i try to upload a new csv file, i got

à la place. in /var/www/alternc/l/lestrade/www/2016.dompeyrelestrade.com/wp-includes/functions.php on line 3943 Catchable fatal error: Argument 1 passed to IWP_Importer_Settings::clear_edit_config() must be an instance of int, integer given, called in /var/www/alternc/l/lestrade/www/2016.dompeyrelestrade.com/wp-content/plugins/importwp-pro/importwp/libs/class-iwp-admin.php on line 429 and defined in /var/www/alternc/l/lestrade/www/2016.dompeyrelestrade.com/wp-content/plugins/importwp-pro/importwp/libs/class-iwp-importer-settings.php on line 590 *
Hope it helps you

James Collings Support Agent
3 months ago

Hi,

Do you have an error log on your server, if so can you go into your importer, and click on the files tab and try to reupload your csv file, recently when i do this i get a 500 error, can you let me know what this error is. 

I did notice that the functions you added to your themes functions.php file were using the wrong importer id which i have now switched this to the id 918 

Also can you send me a raw copy of the csv file you are trying with. 

Thanks 

James

gael dompeyre commented privately
James Collings Support Agent
3 months ago

Hi Gael,

How did you change the site url, was it just a database change of url and is the same files, or is it a different site?

Do you have a login so i can see what you mean?

James

gael dompeyre commented privately
gael dompeyre
3 months ago

Hi,

After previous ticket, we succeed in having your plugin working properly. In two words, we receive on an ftp folder a zip file in which we have to transform the field delimiter from #! to & in a csv file which was then correctly parsed.

Once validated, we changed the siteurl from 2016.dompeyre-lestrade.com to dompeyre-lestrade.com and since this change, the file isn't parsed at all!

I tried to desactivate and re-activate the plugin but it's still not working.

So help: it's the last step.

Regards