Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The script encountered an error while running an AJAX request #130

Closed
Altcheb opened this issue Jun 2, 2015 · 40 comments

Comments

@Altcheb
Copy link

commented Jun 2, 2015

I'm sorry for my English))
I tried to move the blog to a new domain.
Gave an error:
"The script encountered an error while running an AJAX request.If you are using your hosts file to map a domain try browsing via the IP address directly.If you are still running into problems we recommend trying the CLI script bundled with this package.See the README for details."
What am I doing wrong? Where can I read about it?
Thank you!

@mrt-prodz

This comment has been minimized.

Copy link

commented Jun 19, 2015

I know it has been 17 days but maybe it could help someone running into a similar issue.

I just had this problem on a windows server where I had to migrate a WP install, I couldn't access a shell to run the script directly so I ended up making a backup of the database on the old server and made the changes from there, then exported the changed database and imported it to my new server.

If both servers won't let you run the script you can do the following:

  • make a backup of your database
  • install a LAMP / XAMP locally (or in a VM)
  • import the database
  • run Seach-Replace-DB from there
  • export your database
  • import it on your new server
@kalico1

This comment has been minimized.

Copy link

commented Aug 18, 2015

This is a great idea, and I almost tried it....but instead I found this solution: #51

I know it might not apply to everyone, but if anyone is looking for the fix, it just might be that simple.

@kalico1

This comment has been minimized.

Copy link

commented Jan 18, 2016

I encountered this problem again, on different site/server.

This time I was getting the AJAX error every time I hit a certain table in the database. None of the usual solutions made any difference.

Through a series of trials, I ultimately identified two tables (from one plugin, which were present in multiple sites of the multisite) that were "sticking points". The script would successfully process the table just prior to the "broken" one, and then it would throw the AJAX error.

By using the "select tables" radio button and deselecting the ones that were getting stuck (the table following the "last one" that had successfully processed), I was able to get the script to complete. I will have to review those tables manually.

Hopefully as this script continues to develop, improved error reporting will make this particular problem easier to identify; but in the mean time, this may help someone.

Many, many thanks to Interconnectit for the fantastic time-saver this script is for so many people. :)

@Bird87ZA

This comment has been minimized.

Copy link

commented Apr 6, 2016

For anybody else struggling.

My issue was caused by php-mbstring not being installed/activated on the server.

I realised this was the issue by setting WP_DEBUG to true. I then opened Network in Google Chrome Developer Tools, and did a dry run. In network, I selected the script called and checked the response.

If php-mbstring is not your problem, then do the above to check what the server response is and work from there.

@neilgee

This comment has been minimized.

Copy link

commented May 9, 2016

I got this error for the first time when changing the URL string from one to another.

"The script encountered an error while running an AJAX request. If you are using your hosts file to map a domain try browsing via the IP address directly."

I got it on a server that I have used the script with numerous times, it's running PHP 5.6.19 and MySQL 5.6.30 I l a'ready have mbstring loaded.

The widgets I had in WordPress got hosed not only from there location but completely erased.

Re-did the search and replace with WP Migrate Pro and all was ok, just make sure you back up your db before using the script, I was at the point where it never failed me and almost too comfortable with it.

@amiramix

This comment has been minimized.

Copy link

commented May 19, 2016

I got the same error on FreeBSD with a standard WordPress installation. Reason:
PHP message: PHP Fatal error: Call to undefined function mb_regex_encoding() in /usr/home/someuser/public_html/Search-Replace-DB-master/srdb.class.php on line 279" while reading response header from upstream...

@tdmalone

This comment has been minimized.

@amiramix

This comment has been minimized.

Copy link

commented May 21, 2016

Yeah, I googled and installed it and it worked fine. Thanks. I just wonder why the script uses a PHP library which is not used by a standard WordPress installation and why there isn't any mention of that in the installation steps on the Search-Replace-DB website.

@luke7980

This comment has been minimized.

Copy link

commented May 26, 2016

@amiramix
Hi im a newbie in this, i'm having the same issue with mb_regex_encoding. can i ask on what you did to fix it?
thanks.

@amiramix

This comment has been minimized.

Copy link

commented May 26, 2016

@luke7980 I installed the mbstring PHP module. The installation instruction will depend on your system, on FreeBSD it's the php-mbstring package

@luke7980

This comment has been minimized.

Copy link

commented May 26, 2016

@amiramix My website is on a webhost running on linux redhat server. Is there a way that i can install it myself via SSH or do i need to get the hosting probider to do this?

@amiramix

This comment has been minimized.

Copy link

commented May 26, 2016

@luke7980 Usually it's possible to install additional modules without root access or from some sort of management interface, it depends what access to your hosting you have. Maybe worth trying to ask them first.

@luke7980

This comment has been minimized.

Copy link

commented May 27, 2016

@amiramix I was told that php mbstring is already installed and we found that the old site home directory was /home and the new site is under /home8.

do you know where i can update this value?

@amiramix

This comment has been minimized.

Copy link

commented May 27, 2016

@luke7980 Which value? If the PHP module was installed than it would be available in PHP scripts running on the account. What error are you seeing exactly?

@elacasse

This comment has been minimized.

Copy link

commented May 27, 2016

If you're running this script under IIS, (Don't judge me, it's a client requirement) make sure that the Activity Timeout and Request Timeout is adequate. I had this error, but the query failed because it took longer than the Activity Timeout.

@luke7980

This comment has been minimized.

Copy link

commented May 27, 2016

@amiramix this is the error I'm getting when I run the srdb.cli.php from SSH
Fatal error: Call to undefined function mb_regex_encoding() in /home/someusers/public_html/snrscript/srdb.class.php on line 279

@amiramix

This comment has been minimized.

Copy link

commented May 27, 2016

@luke7980 It means the PHP module isn't installed or is not available for the script. Maybe you can show your hosting provider the error to convince them that the module isn't installed? I am afraid I can't help much above that. I had the exact same error and it was solved as soon as I installed the missing module mbstring.

@Akamaozu

This comment has been minimized.

Copy link

commented Jul 3, 2016

@kalico1 having the identical situation happen.

The script isn't timing out for me; specific tables are causing it to trigger the AJAX error.

Also a multisite WordPress installation I'm working with. I believe the plugin causing the faulty data is BuddyPress. Specifically the BuddyPress activity table.

@kalico1

This comment has been minimized.

Copy link

commented Jul 5, 2016

@Akamaozu - I have a multisite with BuddyPress and none of my BuddyPress tables has ever caused the problem. Caveat: since I don't know what "the problem" actually is, I do not have any grounds to assure you that your BuddyPress tables are not the cause in your case. For me, the problem was caused by an as-yet-unknown "something" in Watu (a quiz plugin) tables.

The BuddyPress "activity" table may contain all sorts of stuff that could be breaking this script, since it's user-generated content. It would be pretty tough to guess at the root cause -- I'll leave that to the developer.

Here is my solution, as noted above. Every time I run the script on this site (and I've done it enough to get pretty good at it now....) I just deselect the tables that are problematic.

Through a series of trials, I ultimately identified two tables (from one plugin, which were present in multiple sites of the multisite) that were "sticking points". The script would successfully process the table just prior to the "broken" one, and then it would throw the AJAX error.

By using the "select tables" radio button and deselecting the ones that were getting stuck (the table following the "last one" that had successfully processed), I was able to get the script to complete. I will have to review those tables manually.

For me, the clue was the table that got processed just prior -- I can see that table in the list as completed -- then the script hangs. So I identified the NEXT table in the database as the problem child, and skipped it on the next dry run. Eventually I had a list of problem tables -- all from Watu, in my case -- and by skipping those for each site in the multisite, I could get through the entire run.

Note that in multisite, you may have identical tables in several sites, so you'll have to de-select those same tables several times in the process of setting up this script to run. It's a bear at first, but once you figure out which ones to skip, you'll get the hang of it.

You'll start with selecting all tables, then deselect the one that you think is the culprit. Do a dry run, and see if the script gets past that point. It might hang again on another table, but each time it goes farther, you've identified ONE problematic table. Note each one, and skip those each time.

Also, I had a red herring throwing me off for a while. I was getting an error like this:

The table "wpXX_wangguardreportqueue" has no primary key. Changes will have to be made manually.

just before the AJAX error. I tried skipping those tables, because I thought they were causing the AJAX error. As it turned out, they are unrelated. The script will process just fine past tables without a primary key.

For me, this injected a point of confusion and distraction to my logical process of troubleshooting, because WangGuard and Watu tables are right next to each other alphabetically. The primary key error would occur just before the AJAX error, causing me to think they were related.

@Akamaozu

This comment has been minimized.

Copy link

commented Jul 5, 2016

@kalico1 Thanks for that. I found the same things after dealing with a huge data migration.

  1. It wasn't specifically Buddypress data causing the script to fail. I found all sorts of tables breaking it.
  2. Like you, I ended up unselecting any problematic tables I run into then run the script again. I had over 1000 tables so it was tiresome to do manually. Ended up writing a little bit of JavaScript to automatically update tables, unselect the bad ones (and the known good ones) then do another dry run til I had a list of all bad tables. I'd probably still be trying to migrate if I hadn't done that.

I'm really curious about what type of data is causing Search and Replace to have an AJAX error.

Did you notice anything about the contents of the tables that caused the errors?

@robaxelsen

This comment has been minimized.

Copy link

commented Jul 22, 2016

@Bird87ZA Thanks! Installing php-mbstring module solved it for me too.

@kalico1

This comment has been minimized.

Copy link

commented Sep 10, 2016

@Akamaozu - as you can guess by my lack of a timely reply, I really haven't had time to dig into those tables and figure it out. Interestingly, the more recent versions of Watu don't seem to cause the same problem. Next time I run it (will be soon) I'll see if anything is different or interesting. :)

PS Nice job making a script!

@luke7980

This comment has been minimized.

Copy link

commented Sep 10, 2016

Hi no problem, I've manage to get it fixed manually.

On 10 Sep 2016, at 10:00 AM, kalico notifications@github.com wrote:

@Akamaozu - as you can guess by my lack of a timely reply, I really haven't had time to dig into those tables and figure it out. Interestingly, the more recent versions of Watu don't seem to cause the same problem. Next time I run it (will be soon) I'll see if anything is different or interesting. :)


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

@MisterWP

This comment has been minimized.

Copy link

commented Sep 26, 2016

Hello,

I just spend 1 day to experiment this error : The script encountered an error while running an AJAX request.

For me, it looks like a corrupted table but all infos in my server / phpmyadmin etc. stay the DB is OK, and I can dump any table of my DB.

Finally, I have check all my wp_options fields one by one to find the culprit.

I found the « corrupted field » ! Or the field which contained the illegal character.

I read it, but I cannot find which kind of character can make the problem so, I give you the MySQL export for further investigation : https://www.mister-wp.com/wp-content/uploads/2016/09/corrupted-field-sql.zip

If you import this field in wp_options you will not be able anymore to use search and replace export with :

  • Better Search and Replace
  • WP Migrate DB
  • Search and Replace for WordPress Databases Script by interconnectit

So no more solution to migrate a WP website.

It’s not stable to need one day (or more) when you need to migrate a website. It could be nice to find a way to detect quickly the wrong characters.

My server run mysql throught MariaDB.

Thanks.

@zanzix

This comment has been minimized.

Copy link
Contributor

commented Nov 17, 2016

@MisterWP - Have you tried installing mbstring? The problem should go away after.

Everyone else - I am sorry that you've encountered this problem. I have added a check to the new version of SR to warn the user if the mbstring module is not installed.

@zanzix zanzix closed this Nov 17, 2016

@peterborghard

This comment has been minimized.

Copy link

commented Jan 13, 2017

mbstring worked for me 100%.

@dalenguyen

This comment has been minimized.

Copy link

commented Sep 7, 2017

Or you can do it by using command:

php srdb.cli.php -h [ip address] -n [db name] -u [database user] -p [pw] -s [old string] -r [new string]

@ghost

This comment has been minimized.

Copy link

commented Dec 15, 2017

temporary setting define('MULTISITE', true); fixed the issue for me

@zartgesotten

This comment has been minimized.

Copy link

commented Jan 30, 2018

Hey there, I could fix this by first converting the database to utf4mb4_unicode!

@maddisondesigns

This comment has been minimized.

Copy link

commented Apr 16, 2018

Just encountered the same issue on a client site. The script was crashing on the wp_options table every time. I checked the collation on the tables and they were set to utf8_swedish_ci. I converted all tables to utf8mb4_unicode_ci and retried, and the script ran perfectly.

@kampiamodikuesto

This comment has been minimized.

Copy link

commented Oct 9, 2018

Some Wordfence (if installed) database tables can cause this issue.

wilsonww added a commit to wilsonww/Search-Replace-DB that referenced this issue Dec 5, 2018
Update README with php-mbstring troubleshooting
Symptoms: AJAX error from web UI, "Call to undefined function mb_regex_encoding()" error from srdb.cli

interconnectit#130 (comment) had the fix already, but I had to poke around to figure this out on a new server setup. After php-mbstring install, web UI worked
@sserbest

This comment has been minimized.

Copy link

commented Dec 5, 2018

Installing php-mbstring will solve the issue.

sudo apt-get install php-mbstring
@grex22

This comment has been minimized.

Copy link

commented Jan 11, 2019

Skipping the Wordfence tables solved this for me as well. Not sure why, but those tables don't like SearchReplace :)

@bkwdesign

This comment has been minimized.

Copy link

commented Mar 20, 2019

While I also had some utf8_swedish_ci collations, converting them to utf8mb4_unicode_ci didn't work for me (and I also found the wp_config setting and tried updating that so it would default to utf8mb4_unicode_ci - didn't work either)

@bkwdesign

This comment has been minimized.

Copy link

commented Mar 20, 2019

I already had mbstring installed on my server (GoDaddy Managed WordPress) but it still failed.

So, I had to shell into the sever with PuTTy and run the CLI script: srdb.cli.php

it printed a lot of ugly stuff to the screen about errors with paritally loaded classes.. but at the end of my dry run it did say it found 33 things to replace

so, I took a chance, and it worked.

@r1si

This comment has been minimized.

Copy link

commented May 22, 2019

If you run in cli mode system show the error.
in my case:
Call to undefined function utf8_encode()

@gitdavidhunter

This comment has been minimized.

Copy link

commented Aug 19, 2019

I changed all the database tables that had been assigned a MyISAM storage, and converted them to InnoDB.
Then the application worked perfectly.

MyISAM provides table locking - so that's my best guess to why the script was successful after making this change.

@mstudioIL

This comment has been minimized.

Copy link

commented Sep 12, 2019

It happen to my also, what is "Wordfence tables"?

@grex22

This comment has been minimized.

Copy link

commented Sep 12, 2019

@mstudioIL - If you have the WordFence plugin installed in WordPress, then I've found issues running the search and replace on those tables. Thankfully, you can skip (deselect) those tables and the site should work fine. The tables that WordFence runs on all start with wp_wf.... , where "wp" is your table prefix

@mstudioIL

This comment has been minimized.

Copy link

commented Sep 15, 2019

@grex22 , thanks, it is temp site on sub folder on site that have WordFence, but I don't have it on the new site, how WordFence influencing this?
Can this be the problem with all the URL replacement and the "page not found error" I getting now?
or WPML cause all the problems?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.