referral_id = 0

Hi I upgradede my Version and reinstalled. We use Event-Manager to generate the affiliates.

What I see is, that the transactions are stores in the table wp_aff_referrals,
There for some reason all new wether thy come trough event_manager or Manual are generated with
referral_id = 0.

So I checked the table and didnt see, that thre is an Autoincrement on the Field nor a primary key. Maybe that ok and you are handling the ID internaly.

What i see in the DEBUG LOg is the following:

[24-May-2022 12:57:00 UTC] PHP Notice: Undefined offset: 0 in /home/fk641nap/www/home/blog/wp-content/plugins/affiliates-pro/lib/ext/wordpress/class-affiliates-admin-referral-ext.php on line 35

so please help. I have to correct these malfunction every day during phpmyadmin

Please help
MIchael

2 Responses to referral_id = 0

  1. George May 25, 2022 at 6:43 pm #

    Hey Michael,

    Following-up on my previous comment regarding the issue you have with referrals table.
    First of all please make sure to take a full backup of your database and site files.

    Then take a note of the database name and table prefix you use and proceed with altering the referrals table, making referral_id as the PRIMARY KEY and set it to AUTO_INCREMENT using either phpMyAdmin or mysql client.

    In the following queries I’m using the default wp_ prefix but you should change it to your own.

    First select the correct database
    USE your_database_name;
    Then set the the primary key
    ALTER TABLE wp_aff_referrals
    DROP PRIMARY KEY,
    ADD PRIMARY KEY(
    referral_id
    );

    Finally make it auto_increment
    ALTER TABLE wp_aff_referrals CHANGE referral_id referral_id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT;
    If something goes wrong with any of these queries or the whole operation, you should check the errors occurring and you can always revert back using your recent working backup.

    Normally after these actions you should be good, but I would recommend you to run a couple of tests, add some referrals either manually or automatically or both using an affiliate link and check the referral records created. If there are further issues with your database this is still uncertain but just in case, always check your debug.log file for any issues. However, it is still important to try and locate the source of this issue, altering a table can lead to a corrupted db and loss of your data.

    In general and beyond this support request it is always good to keep frequent backups of your database and files.

    Kind regards,
    George

  2. George May 24, 2022 at 6:47 pm #

    Hi Michael,

    Thanks for sharing further details on your issue, which is exactly why you get referrals with id=0.
    The referrals table PRIMARY KEY is indeed the referral_id which also auto-increments. Please have a look at the following:
    https://github.com/itthinx/affiliates/blob/master/lib/core/wp-init.php
    this is the table creation query and shows exactly what the table structure should normally be.

    However, your table structure is obviously not correct at the moment and you should check what might have caused that issue, ie a third-party intervention altering tables in the database. This is definitely the most important point at the moment in order to avoid having the same issue again in the future. Apart from that you should also check your debug.log thoroughly for any other entries just in case you have further issues on your database apart from the referrals table.

    In the meantime, please allow me to have a look at all the possible options you have to fix it and I’ll follow-up on this thread.

    Kind regards,
    George

We use cookies to optimize your experience on our site and assume you're OK with that if you stay.
OK, hide this message.

Affiliates · Contact · Jobs · Terms & Conditions · Privacy Policy · Documentation · Downloads · Useful Plugins · My Account

Share