Give 2.3.0 – Custom Comment Tables

Give 2.3.0 adds two new custom tables:

  • wp_give_comments
  • wp_give_commentmeta

Upon updating to 2.3.0, users will be asked to complete a backwards-compatible database migration that moves the following data types to the new custom comment tables:

  • Donation Notes (as seen in the Donation details screen in WP Admin)
  • Donor Notes (as seen in the Donor details screen in WP Admin)
  • Donor Comments (as seen in the donor walls of donation forms that have comments enabled)

Rationale for Change

Whenever possible, we try to leverage existing WordPress data structures in an effort to establish long-term compatibility with WordPress.

In previous versions of Give, it seemed appropriate to leverage WordPress comments for data types like donation notes, donor notes, and donor comments. After all, these data types have a lot in common with WordPress comments, and the wp_comments table appeared to be a natural location to store this type of data.

However, we recently became aware of some problems related to mixing WordPress post comments with custom data types like those used by Give.

  1. Mixing WordPress post comments with custom comments was throwing off comment counts used throughout WordPress Admin. This is a known issue with many plugins that leverage the wp_comments table. Typically these comment counts are filtered, however we observed that filters from multiple plugins can also override each other.
  2. The comment_parent column in the wp_comments table is only intended to store the ID of another comment, whereas Give was trying to store the ID of a donation post. This issue became obvious when we received reports of the Donor Wall appearing without comments.
  3. After GDPR took effect, we began receiving reports that the notes and comments created by Give were triggering false positives for GDPR-related plugins aimed at preventing comment spam.

As these conflicts piled up, it became obvious that we needed a more stable, long-term solution for comment-like data in Give. As a result, the two new custom tables were added and a backwards-compatible migration was developed.

Change Details

Full details behind the motivation and implementation of these changes can be found in the GitHub issue.

For clarity, the previous and current storage locations for the affected data types are described below.

Database Location Before Give 2.3.0

  • Donor Notes – Each donor note was being stored as a new line in the notes column of the wp_give_donors table.
  • Donation Notes – Each donation note was being stored in a new row in the wp_comments table.
  • Donor Comments – Each donor comment was being stored in a new row in the wp_comments table.

Database Location After Give 2.3.0

  • Donor Notes – Each donor note is stored in a new row in the wp_give_comments table.
  • Donation Notes – Each donation note is stored in a new row in the wp_give_comments table.
  • Donor Comments – Each donor comment is stored in a new row in the wp_give_comments table.

Summary

The changes regarding Give comment storage do not have any user-facing effects other than an admin notice for the database migration. While this is a relatively seamless change from the user’s perspective, these custom tables introduce a new level of stability, control, and performance optimization that will benefit Give developers and users well into the future.

 

Ravinder Kumar

Open source lover, the father of a daughter, continually improving developer, and Senior WordPress Engineer at GiveWP.

 

Leave a Comment