New Blog Templates Plugin creates Error when Affiliate WP is enabled in Template

Hi guys,

this is a Repost of my reply to https://premium.wpmudev.org/forums/topic/blog-templates-create-site-raise-error#post-1056662 where I haven't got any reply...

It happens when trying to create a new site based of a template where Affiliate WP enabled (https://affiliatewp.com/).

The issue in more detail:

2016/03/30 20:46:43 [error] 10522#10522: *5266 FastCGI sent in stderr: "PHP message: WordPress-Datenbank-Fehler Incorrect table name 'wp_2_affiliate_wp_visits' für Abfrage CREATE TABLE IF NOT EXISTS wp_21_affiliate_wp_campaigns ('wp_2_affiliate_wp_visits'.'url') AS 'visits',count(distinct 'wp_2_affiliate_wp_visits'.'url') AS 'unique_visits',sum(if(('wp_2_affiliate_wp_visits'.'referral_id' <> 0),1,0)) AS 'referrals',round(((sum(if(('wp_2_affiliate_wp_visits'.'referral_id' <> 0),1,0)) / count('wp_2_affiliate_wp_visits'.'url')) * 100),2) von wpmu_create_blog, do_action('wpmu_new_blog'), call_user_func_array, blog_templates->set_blog_defaults, NBT_Template_copier->execute, NBT_Template_copier->copy_additional_tables" while reading response header from upstream, client: IP, server: DOMAIN.de, request: "POST /wp-admin/network/site-new.php?action=add-site HTTP/1.1", upstream: "fastcgi://unix:/var/lib/php5-fpm/site.sock:", host: "DOMAIN.de", referrer: "DOMAIN/wp-admin/network/site-new.php"
The table "wp_21_affiliate_wp_campaigns" is a SQL VIEW. So it's no real table.

Let me know if you need anything in addition.

Brgds,

Jan

  • Sajid
    • DEV MAN’s Sidekick

    Hi Jan,
    Hope you are doing good today :slight_smile:

    That's seems to be issue with database query while creating the clone of tables. I am flagging developer of this plugin for his invaluable feedback on this matter.

    Either myself or plugin developer will post back a reply here as soon as possible.

    Take care and have a nice day :slight_smile:
    Cheers, Sajid

  • Sajid
    • DEV MAN’s Sidekick

    Hi Jan,
    Hope you are doing good today :slight_smile:

    I am really sorry for delay on this ticket. I have been on vacations for a week and it seems this get missed from the backfeed of my colleagues.

    However, I heard back from the developer and he said. Since this is a paid plugin so neither myself or my developer could test it. Is there a way you could send us the plugin for testing purposes only.

    If its okay for you then please send in the downloadable plugin file link (e.g Google Drive or Dropbox) using our private contact form in following format.

    Subject: "Attn: Sajid Javed"
    -WordPress admin username
    -WordPress admin password
    -login url
    -FTP credentials (host/username/password)
    -link back to this thread for reference
    -any other relevant urls
    
    Select "I have a different question" for your topic - this and the subject line ensure that it gets assigned to me :simple_smile:
    
    https://premium.wpmudev.org/contact/

    Look forward towards your response :slight_smile:
    Cheers, Sajid

  • Sajid
    • DEV MAN’s Sidekick

    Hello Jan,
    Hope you are doing good today :slight_smile:

    Thanks for sending in the Affiliates WP plugin. I have forwarded the plugin to our developer. Either myself or developer will post a reply here as soon as possible.

    Take care and have a nice day :slight_smile:
    Cheers, Sajid

  • Sajid
    • DEV MAN’s Sidekick

    Hi Jan,
    Hope you are doing good today :slight_smile:

    I can see that Panos is working on your issue and have requested the FTP credentials to make the changes on your website directly.

    I can see there are no response from your side since then. Please send in credentials as requested in your other thread if you still need further assistance.

    Take care and have a nice day :slight_smile:

    Best Regards,
    Sajid

  • Panos
    • SLS

    Hey Jan ,

    Thank you for your cooperation so far and thanks for getting into the trouble and sending credentials asked :slight_smile:

    I ended up not using them I was able to reproduce this error in my new installation (in my previous installation I might had probably altered the problematic db table at some point during several tests so I couldn't reproduce it).

    I have attached a file which seems to be solving this issue in my installation. Please download and unzip attached file and replace at

    wp-content/plugins/blogtemplates/blogtemplatesfiles/copier.php

    After replacing file, create a new template and on new blog creation select this new template and let us know how it works for you:slight_smile:

    Cheers!
    Panos

  • Jan
    • Design Lord, Child of Thor

    Hi Panos : How comes that the recent update still doesn't ship the fix? Just updated to 2.8.3 to find out that the fix is still not included and the update reverted the file...

    Any particular reason for that I should know about?

    It was pure coincidence that I rechecked the copier.php due to another issue after the recent update.

    Best Regards,
    Jan

  • Panos
    • SLS

    Hi Jan,

    I also didn't notice this.

    The way the plugin handles this is based on WP functions, which is the right way. It only fails in specific custom tables, and this failure is not caused by plugin's issue. My fix adds another layer, so if everything else fails it uses more raw SQL. Without being sure, I assume it didn't make it as it's not considered as a bug not a new feature , but I'll ask the dev regarding this.

    Did you manage to replace file again after updating?

    Cheers!
    Panos

  • Jan
    • Design Lord, Child of Thor

    Sure I was able to handle this easy bit of code replacement :slight_smile:.

    Can you please urge your dev team to incorporate this fix? Would not like to see, that it will be overwritten by the next fix.

    Besides it is quite confusing, that solutions that are discussed here are ignored by your Dev guys. It simply can't be your goal to supply "one time" solutions that will not even survive an update. I agree that SQL Views do not exist in WordPress core, but as you now are aware that they do exist for plugins, and the code is already provided by yourself, I do not get the point not to add this to the code. Maybe you can optimize internal communication a bit out of this learning.
    At least I would have expected some kind of feedback stating, that it will *not* be included in the plugin for whatsoever reasons.

    Have a great night!

    Jan

  • Sajid
    • DEV MAN’s Sidekick

    Hi Jan,

    Hope you are doing good today :slight_smile:

    I am sorry for inconvenience. As stated by Panos above, due to its not reported as a bug or considered as a featured request so that is why its get missed. However, I have forwarded this request to our developer again for consideration.

    Take care and have a nice day :slight_smile:

    Best Regards,
    Sajid

  • blue
    • Design Lord, Child of Thor

    Jan , johnsonleee

    Did you guys ever fully resolve this? I know this thread tracked off into a private communication, just wondering if if any progress had been made on this issue since this was posted a couple years ago.

    I'm having this problem as well (https://premium.wpmudev.org/forums/topic/new-blog-templates-new-blog-templates-error-after-woocommerce).

    Panos you mentioned that you were able to reproduce this issue and wrote a script to fix it ( I haven't tested that yet, but plan to). Can you explain a bit about what you found was the issue and what code in that file did you change so I can compare it?

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.