Blogger Import - odd a2a {} code now showing

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Blogger Import - odd a2a {} code now showing

Post by simonmlewis »

We have using Blogger Import Extended to import a Blog site to Wordpress.
It took hours. But now on each blog we are seeing this code:

[text]var a2a_config = a2a_config || {};
a2a_config.linkurl = "www.sitename.blogspot.com";[/text]
With "sitename" being the name of the blogspot.

Any ideas what it might be? I've looked it up and there is some sort of "addtoany" script, but I don't want that to be there, because we are moving the site away from blogspot.

The only other thing I can think of, is to look it up int he database, see how it is shown, and do a replace all of that for nothing.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Blogger Import - odd a2a {} code now showing

Post by Celauran »

If this is saved in the post content in the database, then yeah, large scale find and replace is probably the fastest option.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Blogger Import - odd a2a {} code now showing

Post by simonmlewis »

Damn thing has variants. I did try that, but it removed the odd one.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Blogger Import - odd a2a {} code now showing

Post by simonmlewis »

If I did a search for it, it found it if I just searched for a portion of it. But because maybe one has a space, or something like that, it just finds 1, 2 and that's it. Not all of them.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Blogger Import - odd a2a {} code now showing

Post by Celauran »

Having only the two lines above to go on, couldn't you simply remove any line containing 'a2a_' ?
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Blogger Import - odd a2a {} code now showing

Post by simonmlewis »

No, because that is a 2% portion of what's in the Post.
Think of it like a big Blog site. maybe 200-300 words, and that tiny portion in the head or the base of the code that's in the DB.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Blogger Import - odd a2a {} code now showing

Post by Celauran »

Right, that's how I was thinking of it, but your example showed them each on their own line. If that's not the case, maybe you need to look at building a regex to match those segments.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Blogger Import - odd a2a {} code now showing

Post by simonmlewis »

Sorry how do you mean? I want to remove them from the DB, as this is a Wordpress site, and dont' want to mess up the Post pages.
Bizarrely, when you run a query for how many have the full code, it's around 588, but when you do a Replace, it finds 1 or 2. How is that possible?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Blogger Import - odd a2a {} code now showing

Post by simonmlewis »

Code: Select all

SELECT * FROM `wp_posts` WHERE post_content LIKE '%var a2a_config = a2a_config || {};
a2a_config.linkurl = "www.site.blogspot.com";%'

UPDATE wp_posts
SET post_content = REPLACE(post_content, 'var a2a_config = a2a_config || {};
a2a_config.linkurl = "www.site.blogspot.com";', '')
The top one finds over 580 entries.
The second script replaces just 8! How is that possible???
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Blogger Import - odd a2a {} code now showing

Post by Celauran »

simonmlewis wrote:this is a Wordpress site, and dont' want to mess up the Post pages.
WP isn't really relevant here. You have a DB table with some contents you need to alter.
simonmlewis wrote:Bizarrely, when you run a query for how many have the full code, it's around 588, but when you do a Replace, it finds 1 or 2. How is that possible?
I don't really have enough information to answer that.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Blogger Import - odd a2a {} code now showing

Post by simonmlewis »

I thought you meant use that code in the page. I want to remove them from the database tables.

A post_content field might contain something like this:

Code: Select all

var a2a_config = a2a_config || {};
a2a_config.linkurl = "www.website.blogspot.com";


Having just returned from my first skiing holiday I am now belatedly aware how family-friendly the sport is and how, if children learn early, you can look forward to many happy hours on the slopes in future years. <br />
<br />
If youcontent content bla bla
<b><i><br /></i></b>
<b><i><br /></i></b>
I need shot of that var..... "; text. They are all the same, but oddly, as I said, doing a SELECT finds them all. Doing a REPLACE, doesn't.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Blogger Import - odd a2a {} code now showing

Post by Celauran »

Might be easiest at this point to pull the pages down, fix them in PHP, either by removing those lines -- they do appear to be on separate lines in this example -- or with regex, and then writing the results back to the DB.
Post Reply