pods-framework / pods

The Pods Framework is a Content Development Framework for WordPress - It lets you create and extend content types that can be used for any project. Add fields of various types we've built in, or add your own with custom inputs, you have total control.
https://pods.io/
GNU General Public License v2.0
1.07k stars 265 forks source link

$pod->add($data) Doesn't Update Bi-Directional Relationships #7018

Closed BabalonMotherOfAbominations closed 1 year ago

BabalonMotherOfAbominations commented 1 year ago

Description

Up to PODS 2.9.9 using $pod->add($data) will properly take any values assigned in the $data array, and create a pod with the correct bi-directional fields.

Any subsequent PODS version however, will ONLY create a wp_podsrel row for the "current direction" of the relationship.

So for example, if I add a Book with 2 authors, the Book will properly be related with the authors through wp_podsrel, but the authors won't have any wp_podsrel entries of their own.

Sometimes bi-directional fields can get "stuck", and updating them through Pods -> Edit Pods fixes the issue, however this doesn't work here.

There is a possibility this issue only affects Advanced Content Types. I can't properly test this because 99% of our custom forms operate with ACTs.

Version

2.9.11.1

Testing Instructions

  1. Attempt to create a pod item with $pod->add($data), and using at least 1 bi-directional relationship field.
  2. Inspect wp_podsrel to discover that only the Created pod has a corresponding row for the relationship. The related pod doesn't have one.

Screenshots / Screencast

No response

Possible Workaround

The only workaround I found is removing any relationship fields from the $data array, and doing separate calls to each one, with $pod->add_to, instead of $pod->add.

Working example:

$new_pod_id = pods( 'pod' )->add( $data ); pods('pod', $new_pod_id)->add_to('relationship_field', $relationship_field_array_of_values);

Site Health Information

`
### wp-core ###

version: 6.1.1
site_language: en_US
user_language: en_US
timezone: Europe/London
permalink: /%postname%/
https_status: true
multisite: false
user_registration: 0
blog_public: 1
default_comment_status: open
environment_type: production
user_count: 33
dotorg_communication: true

### wp-paths-sizes ###

wordpress_path: /home/altarofgaming/public_html
wordpress_size: 2.28 GB (2449028030 bytes)
uploads_path: /home/altarofgaming/public_html/wp-content/uploads
uploads_size: 33.48 GB (35954006894 bytes)
themes_path: /home/altarofgaming/public_html/wp-content/themes
themes_size: 9.18 MB (9624311 bytes)
plugins_path: /home/altarofgaming/public_html/wp-content/plugins
plugins_size: 130.20 MB (136524423 bytes)
database_size: 1.03 GB (1101594624 bytes)
total_size: 36.93 GB (39650778282 bytes)

### wp-dropins (2) ###

advanced-cache.php: true
object-cache.php: true

### wp-active-theme ###

name: Altar of Gaming WP Theme (aog)
version: 0.0.2
author: Babalon, Mother of Abominations
author_website: https://altarofgaming.com/author/babalon-aog/
parent_theme: none
theme_features: core-block-patterns, post-thumbnails, title-tag, admin-bar, widgets-block-editor
theme_path: /home/altarofgaming/public_html/wp-content/themes/aog
auto_update: Disabled

### wp-themes-inactive (2) ###

Altar of Gaming: version: 1.0.0, author: Babalon, Mother of Abominations, Auto-updates disabled
Altar of Gaming NEW: version: 1.0.0, author: Babalon, Mother of Abominations, Auto-updates disabled

### wp-plugins-active (23) ###

AdThrive Ads: version: 3.1.0, author: AdThrive, Auto-updates disabled
Ajax Search Pro: version: 4.26.1, author: Ernest Marcinko, Auto-updates disabled
Classic Editor: version: 1.6.2, author: WordPress Contributors, Auto-updates disabled
FacetWP: version: 4.1.5, author: FacetWP, LLC, Auto-updates disabled
FacetWP - A-Z Listing: version: 1.3.9, author: FacetWP, LLC, Auto-updates disabled
FacetWP - Cache: version: 1.6.2, author: FacetWP, LLC, Auto-updates disabled
FacetWP - Conditional Logic: version: 1.4.2, author: FacetWP, LLC, Auto-updates disabled
FacetWP - Hierarchy Select: version: 0.5.3, author: FacetWP, LLC, Auto-updates disabled
Imagify: version: 2.1.1, author: Imagify – Optimize Images & Convert WebP, Auto-updates disabled
Login IP & Country Restriction: version: 6.3.0, author: Iulia Cazan, Auto-updates disabled
OPcache Manager: version: 2.9.0, author: Pierre Lannoy / PerfOps One (latest version: 2.9.1), Auto-updates disabled
Pods - Custom Content Types and Fields: version: 2.9.9, author: Pods Framework Team (latest version: 2.9.11.1), Auto-updates disabled
Post SMTP: version: 2.4.3, author: Post SMTP, Auto-updates disabled
Post Views Counter: version: 1.3.12, author: Digital Factory, Auto-updates disabled
Query Monitor: version: 3.11.2, author: John Blackbourn, Auto-updates disabled
Redis Object Cache: version: 2.2.4, author: Till Krüss, Auto-updates disabled
Shortcode Star Rating: version: 0.2, author: modshrink, Auto-updates disabled
Simple Local Avatars: version: 2.7.4, author: 10up, Auto-updates disabled
Topic: version: 1.0.19, author: Topic, Auto-updates disabled
Wordfence Security: version: 7.9.1, author: Wordfence, Auto-updates disabled
WP Rocket: version: 3.12.5.3, author: WP Media, Auto-updates disabled
Yoast SEO: version: 20.2, author: Team Yoast (latest version: 20.2.1), Auto-updates disabled
Yoast SEO Premium: version: 20.2, author: Team Yoast (latest version: 20.2.1), Auto-updates disabled

### wp-plugins-inactive (6) ###

APCu Manager: version: 3.5.0, author: Pierre Lannoy / PerfOps One (latest version: 3.5.1), Auto-updates disabled
CIO Custom Fields Importer Pro: version: 1.3.1, author: <a href="http://vipp.com.au">VisualData</a>, Auto-updates disabled
Pods - Custom Content Types and Fields: version: 2.9.11.1, author: Pods Framework Team, Auto-updates disabled
Table of Contents Plus: version: 2302, author: Michael Tran, Auto-updates disabled
Theme Switcha: version: 3.1, author: Jeff Starr, Auto-updates disabled
WP All Import Pro: version: 4.7.6, author: Soflyy, Auto-updates disabled

### wp-media ###

image_editor: WP_Image_Editor_Imagick
imagick_module_version: 1692
imagemagick_version: ImageMagick 6.9.12-73 Q16 x86_64 17646 https://legacy.imagemagick.org
imagick_version: 3.7.0
file_uploads: File uploads is turned off
post_max_size: 100M
upload_max_filesize: 100M
max_effective_size: 100 MB
max_file_uploads: 80
imagick_limits: 
    imagick::RESOURCETYPE_AREA: 125 GB
    imagick::RESOURCETYPE_DISK: 9.2233720368548E+18
    imagick::RESOURCETYPE_FILE: 49152
    imagick::RESOURCETYPE_MAP: 125 GB
    imagick::RESOURCETYPE_MEMORY: 62 GB
    imagick::RESOURCETYPE_THREAD: 1
imagemagick_file_formats: 3FR, 3G2, 3GP, AAI, AI, APNG, ART, ARW, AVI, AVS, BGR, BGRA, BGRO, BIE, BMP, BMP2, BMP3, BRF, CAL, CALS, CANVAS, CAPTION, CIN, CIP, CLIP, CMYK, CMYKA, CR2, CR3, CRW, CUR, CUT, DATA, DCM, DCR, DCX, DDS, DFONT, DNG, DOT, DPX, DXT1, DXT5, EPDF, EPI, EPS, EPS2, EPS3, EPSF, EPSI, EPT, EPT2, EPT3, ERF, EXR, FAX, FILE, FITS, FRACTAL, FTP, FTS, G3, G4, GIF, GIF87, GRADIENT, GRAY, GRAYA, GROUP4, GV, H, HALD, HDR, HISTOGRAM, HRZ, HTM, HTML, HTTP, HTTPS, ICB, ICO, ICON, IIQ, INFO, INLINE, IPL, ISOBRL, ISOBRL6, J2C, J2K, JBG, JBIG, JNG, JNX, JP2, JPC, JPE, JPEG, JPG, JPM, JPS, JPT, JSON, K25, KDC, LABEL, M2V, M4V, MAC, MAGICK, MAP, MASK, MAT, MATTE, MEF, MIFF, MKV, MNG, MONO, MOV, MP4, MPC, MPEG, MPG, MRW, MSL, MSVG, MTV, MVG, NEF, NRW, NULL, ORF, OTB, OTF, PAL, PALM, PAM, PANGO, PATTERN, PBM, PCD, PCDS, PCL, PCT, PCX, PDB, PDF, PDFA, PEF, PES, PFA, PFB, PFM, PGM, PGX, PICON, PICT, PIX, PJPEG, PLASMA, PNG, PNG00, PNG24, PNG32, PNG48, PNG64, PNG8, PNM, POCKETMOD, PPM, PREVIEW, PS, PS2, PS3, PSB, PSD, PTIF, PWP, RADIAL-GRADIENT, RAF, RAS, RAW, RGB, RGBA, RGBO, RGF, RLA, RLE, RMF, RW2, SCR, SCT, SFW, SGI, SHTML, SIX, SIXEL, SPARSE-COLOR, SR2, SRF, STEGANO, SUN, SVG, SVGZ, TEXT, TGA, THUMBNAIL, TIFF, TIFF64, TILE, TIM, TTC, TTF, TXT, UBRL, UBRL6, UIL, UYVY, VDA, VICAR, VID, VIDEO, VIFF, VIPS, VST, WBMP, WEBM, WEBP, WMF, WMV, WMZ, WPG, X, X3F, XBM, XC, XCF, XPM, XPS, XV, XWD, YCbCr, YCbCrA, YUV
gd_version: 2.3.3
gd_formats: GIF, JPEG, PNG, WebP, BMP, AVIF, XPM
ghostscript_version: not available

### wp-server ###

server_architecture: Linux 5.15.0-2.52.3.el8uek.x86_64 x86_64
httpd_software: nginx/1.22.1
php_version: 8.1.14 64bit
php_sapi: fpm-fcgi
max_input_variables: 50000
time_limit: 900
memory_limit: 9216M
max_input_time: 600
upload_max_filesize: 100M
php_post_max_size: 100M
curl_version: 7.61.1 OpenSSL/1.1.1k
suhosin: false
imagick_availability: true
pretty_permalinks: true
htaccess_extra_rules: true

### wp-database ###

extension: mysqli
server_version: 5.7.40-43
client_version: mysqlnd 8.1.14
max_allowed_packet: 524288000
max_connections: 460

### wp-constants ###

WP_HOME: undefined
WP_SITEURL: undefined
WP_CONTENT_DIR: /home/altarofgaming/public_html/wp-content
WP_PLUGIN_DIR: /home/altarofgaming/public_html/wp-content/plugins
WP_MEMORY_LIMIT: 4096M
WP_MAX_MEMORY_LIMIT: 9216M
WP_DEBUG: false
WP_DEBUG_DISPLAY: true
WP_DEBUG_LOG: false
SCRIPT_DEBUG: false
WP_CACHE: true
CONCATENATE_SCRIPTS: undefined
COMPRESS_SCRIPTS: undefined
COMPRESS_CSS: undefined
WP_ENVIRONMENT_TYPE: Undefined
DB_CHARSET: utf8mb4
DB_COLLATE: undefined

### wp-filesystem ###

wordpress: writable
wp-content: writable
uploads: writable
plugins: writable
themes: writable
mu-plugins: writable

### perfopsone_objectcache ###

product: APCu
directive_enabled: 1
directive_shm_segments: 1
directive_shm_size: 32M
directive_entries_hint: 4096
directive_ttl: 0
directive_gc_ttl: 3600
directive_mmap_file_mask: /tmp/apc.XXXXXX
directive_slam_defense: 0
directive_enable_cli: 0
directive_use_request_time: 0
directive_serializer: php
directive_coredump_unmap: 0
directive_preload_path: undefined
status_num_seg: 1
status_seg_size: 33554312
status_avail_mem: 33518712
status_num_slots: 4099
status_ttl: undefined
status_num_hits: 1174
status_num_misses: 2350
status_num_inserts: 1176
status_num_entries: 2
status_expunges: undefined
status_start_time: 1677679838
status_mem_size: 2544
status_memory_type: mmap

### perfopsone_opcache ###

product: Zend OPcache 8.1.14
directive_opcache.enable: true
directive_opcache.enable_cli: true
directive_opcache.use_cwd: true
directive_opcache.validate_timestamps: true
directive_opcache.validate_permission: false
directive_opcache.validate_root: false
directive_opcache.dups_fix: false
directive_opcache.revalidate_path: false
directive_opcache.log_verbosity_level: 1
directive_opcache.memory_consumption: 805306368
directive_opcache.interned_strings_buffer: 48
directive_opcache.max_accelerated_files: 1000000
directive_opcache.max_wasted_percentage: 0.4
directive_opcache.consistency_checks: undefined
directive_opcache.force_restart_timeout: 180
directive_opcache.revalidate_freq: 2
directive_opcache.preferred_memory_model: undefined
directive_opcache.blacklist_filename: /etc/php.d/opcache*.blacklist
directive_opcache.max_file_size: undefined
directive_opcache.error_log: undefined
directive_opcache.protect_memory: false
directive_opcache.save_comments: true
directive_opcache.record_warnings: false
directive_opcache.enable_file_override: false
directive_opcache.optimization_level: 2147401727
directive_opcache.lockfile_path: /tmp
directive_opcache.file_cache: undefined
directive_opcache.file_cache_only: false
directive_opcache.file_cache_consistency_checks: true
directive_opcache.file_update_protection: 2
directive_opcache.opt_debug_level: undefined
directive_opcache.restrict_api: undefined
directive_opcache.huge_code_pages: false
directive_opcache.preload: undefined
directive_opcache.preload_user: undefined
directive_opcache.jit: tracing
directive_opcache.jit_buffer_size: undefined
directive_opcache.jit_debug: undefined
directive_opcache.jit_bisect_limit: undefined
directive_opcache.jit_blacklist_root_trace: 16
directive_opcache.jit_blacklist_side_trace: 8
directive_opcache.jit_hot_func: 127
directive_opcache.jit_hot_loop: 64
directive_opcache.jit_hot_return: 8
directive_opcache.jit_hot_side_exit: 8
directive_opcache.jit_max_exit_counters: 8192
directive_opcache.jit_max_loop_unrolls: 8
directive_opcache.jit_max_polymorphic_calls: 2
directive_opcache.jit_max_recursive_calls: 2
directive_opcache.jit_max_recursive_returns: 2
directive_opcache.jit_max_root_traces: 1024
directive_opcache.jit_max_side_traces: 128
directive_opcache.jit_prof_threshold: undefined
status_opcache_enabled: true
status_cache_full: false
status_restart_pending: false
status_restart_in_progress: false
status_used_memory: 13077408
status_free_memory: 28865168
status_wasted_memory: 138296
status_current_wasted_percentage: 0.017173091570536
status_buffer_size: undefined
status_number_of_strings: 172956
status_num_cached_scripts: 4813
status_num_cached_keys: 7443
status_max_cached_keys: 1048793
status_hits: 220507054
status_start_time: 1677679838
status_last_restart_time: 1677756750
status_oom_restarts: undefined
status_hash_restarts: undefined
status_manual_restarts: 2
status_misses: 8458
status_blacklist_misses: undefined
status_blacklist_miss_ratio: undefined
status_opcache_hit_rate: 99.996164442164
status_enabled: false
status_on: false
status_kind: 5
status_opt_level: 4
status_opt_flags: 6
status_buffer_free: undefined

### opcache-manager ###

version: 2.9.0
use_cdn: undefined
use_apcu: 1
script_in_footer: undefined
display_nag: 1
reset_frequency: never
analytics: 1
history: 30
metrics: 1
warmup: undefined
flash_invalidate: undefined
flash_warmup: undefined
adminbar: 1

### pods ###

pods-server-software: nginx/1.22.1
pods-user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36
pods-session-save-path: /var/lib/php/session
pods-session-save-path-exists: Yes
pods-session-save-path-writable: Yes
pods-session-max-lifetime: 14400
pods-opcode-cache-apc: No
pods-opcode-cache-memcached: No
pods-opcode-cache-opcache: Yes
pods-opcode-cache-redis: No
pods-object-cache-apc: No
pods-object-cache-apcu: Yes
pods-object-cache-memcache: No
pods-object-cache-memcached: Yes
pods-object-cache-redis: Yes
pods-memory-current-usage: 23.835M
pods-memory-current-usage-real: 30.582M
pods-network-wide: No
pods-install-location: /wp-content/plugins/pods/
pods-developer: No
pods-tableless-mode: No
pods-relationship-table-enabled: Yes
pods-light-mode: No
pods-strict: No
pods-allow-deprecated: Yes
pods-api-cache: Yes
pods-shortcode-allow-evaluate-tags: No
pods-sessions: Disable sessions
pods-can-use-sessions: Yes
pods-relationship-table-status: 351,721

`

Pods Package

No response

sc0ttkclark commented 1 year ago

Confirmed the issue here, a save() will solve it too.

Digging into this further to figure out where the issue is caused from.

sc0ttkclark commented 1 year ago

Fixed via df24e212792ffeb98fbb9eab3fcc8ea6e399b54d