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

Create an Object Relationships Database Table #1429

Merged
merged 24 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
e74d47f
Create object-relationships.php
KTS915 May 4, 2024
dd09333
Update schema.php to add object-relationships and related meta tables
KTS915 May 4, 2024
7a02b16
Update wp-settings.php to include object-relationships.php
KTS915 May 4, 2024
ecd8003
Update schema.php to mirror syntax of current tables
KTS915 May 7, 2024
dcede41
Coding Standards
mattyrob May 7, 2024
3ead9d4
Declare new tables
mattyrob May 7, 2024
ef0dfe2
Merge branch 'object-relationships' of https://github.com/KTS915/Clas…
mattyrob May 7, 2024
373b9e0
Update multisite tests
mattyrob May 7, 2024
e233a72
Update object-relationships.php to improve and document 'cp_recognize…
KTS915 May 13, 2024
c763405
Update object-relationships.php to comply with coding standards
KTS915 May 13, 2024
dd53e3b
Update object-relationships.php to meet coding standards
KTS915 May 13, 2024
5b6d8db
Update object-relationships.php to add documentation
KTS915 May 14, 2024
432be68
Update object-relationships.php to address coding standards
KTS915 May 14, 2024
4121031
Update object-relationships.php to address more standards issues
KTS915 May 14, 2024
e794bf8
Update object-relationships.php to delete whitespace at the end of a …
KTS915 May 14, 2024
3bdebad
Update object-relationships.php to correct labeling of some parameters
KTS915 May 14, 2024
cf21840
Update object-relationships.php to simplify code
KTS915 May 14, 2024
e782ffb
Update object-relationships.php to improve naming of variable
KTS915 May 15, 2024
210ccfa
Merge branch 'ClassicPress:develop' into object-relationships
KTS915 May 16, 2024
767b6eb
Update object-relationships.php to improve and simplify code
KTS915 May 16, 2024
35bdd60
Update object-relationships.php to correct first argument in meta fun…
KTS915 May 17, 2024
a8dae7e
Update schema.php to correct field in meta database table
KTS915 May 17, 2024
7c800a7
Fix database key
xxsimoxx May 17, 2024
0410c7f
Merge branch 'ClassicPress:develop' into object-relationships
KTS915 Jun 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 42 additions & 22 deletions src/wp-admin/includes/schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,27 @@ function wp_get_db_schema( $scope = 'all', $blog_id = null ) {
$max_index_length = 191;

// Blog-specific tables.
$blog_tables = "CREATE TABLE $wpdb->termmeta (
$blog_tables = "CREATE TABLE $wpdb->object_relationshipmeta (
meta_id bigint(20) unsigned NOT NULL auto_increment,
object_relationship_id bigint(20) unsigned NOT NULL default '0',
meta_key varchar(255) default NULL,
meta_value longtext,
PRIMARY KEY (meta_id),
KEY object_relationship_id (object_relationship_id),
KEY meta_key (meta_key($max_index_length))
) $charset_collate;
CREATE TABLE $wpdb->object_relationships (
relationship_id bigint(20) unsigned NOT NULL auto_increment,
left_object_id bigint(20) unsigned NOT NULL default 0,
left_object_type varchar(255) NOT NULL default '',
right_object_type varchar(255) NOT NULL default '',
right_object_id bigint(20) unsigned NOT NULL default 0,
PRIMARY KEY (relationship_id),
KEY left_object_id (left_object_id),
KEY left_object_type (left_object_type($max_index_length)),
KEY right_object_type (right_object_type($max_index_length))
) $charset_collate;
CREATE TABLE $wpdb->termmeta (
meta_id bigint(20) unsigned NOT NULL auto_increment,
term_id bigint(20) unsigned NOT NULL default '0',
meta_key varchar(255) default NULL,
Expand All @@ -63,31 +83,31 @@ function wp_get_db_schema( $scope = 'all', $blog_id = null ) {
KEY meta_key (meta_key($max_index_length))
) $charset_collate;
CREATE TABLE $wpdb->terms (
term_id bigint(20) unsigned NOT NULL auto_increment,
name varchar(200) NOT NULL default '',
slug varchar(200) NOT NULL default '',
term_group bigint(10) NOT NULL default 0,
PRIMARY KEY (term_id),
KEY slug (slug($max_index_length)),
KEY name (name($max_index_length))
term_id bigint(20) unsigned NOT NULL auto_increment,
name varchar(200) NOT NULL default '',
slug varchar(200) NOT NULL default '',
term_group bigint(10) NOT NULL default 0,
PRIMARY KEY (term_id),
KEY slug (slug($max_index_length)),
KEY name (name($max_index_length))
) $charset_collate;
CREATE TABLE $wpdb->term_taxonomy (
term_taxonomy_id bigint(20) unsigned NOT NULL auto_increment,
term_id bigint(20) unsigned NOT NULL default 0,
taxonomy varchar(32) NOT NULL default '',
description longtext NOT NULL,
parent bigint(20) unsigned NOT NULL default 0,
count bigint(20) NOT NULL default 0,
PRIMARY KEY (term_taxonomy_id),
UNIQUE KEY term_id_taxonomy (term_id,taxonomy),
KEY taxonomy (taxonomy)
term_taxonomy_id bigint(20) unsigned NOT NULL auto_increment,
term_id bigint(20) unsigned NOT NULL default 0,
taxonomy varchar(32) NOT NULL default '',
description longtext NOT NULL,
parent bigint(20) unsigned NOT NULL default 0,
count bigint(20) NOT NULL default 0,
PRIMARY KEY (term_taxonomy_id),
UNIQUE KEY term_id_taxonomy (term_id,taxonomy),
KEY taxonomy (taxonomy)
) $charset_collate;
CREATE TABLE $wpdb->term_relationships (
object_id bigint(20) unsigned NOT NULL default 0,
term_taxonomy_id bigint(20) unsigned NOT NULL default 0,
term_order int(11) NOT NULL default 0,
PRIMARY KEY (object_id,term_taxonomy_id),
KEY term_taxonomy_id (term_taxonomy_id)
object_id bigint(20) unsigned NOT NULL default 0,
term_taxonomy_id bigint(20) unsigned NOT NULL default 0,
term_order int(11) NOT NULL default 0,
PRIMARY KEY (object_id,term_taxonomy_id),
KEY term_taxonomy_id (term_taxonomy_id)
) $charset_collate;
CREATE TABLE $wpdb->commentmeta (
meta_id bigint(20) unsigned NOT NULL auto_increment,
Expand Down
21 changes: 21 additions & 0 deletions src/wp-includes/class-wpdb.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ class wpdb {
* List of WordPress per-site tables.
*
* @since 2.5.0
* @since CP-2.2.0 - Added `object_relationships` and `object_relationshipmeta`
*
* @see wpdb::tables()
* @var string[]
Expand All @@ -300,6 +301,8 @@ class wpdb {
'term_relationships',
'termmeta',
'commentmeta',
'object_relationships',
'object_relationshipmeta',
);

/**
Expand Down Expand Up @@ -441,6 +444,24 @@ class wpdb {
*/
public $termmeta;

/**
* ClassicPress Object Relationships table.
*
* @since CP-2.2.0
*
* @var string
*/
public $object_relationships;

/**
* ClassicPress Object Relationship Meta table.
*
* @since CP-2.2.0
*
* @var string
*/
public $object_relationshipmeta;

//
// Global and Multisite tables
//
Expand Down
Loading
Loading