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 264 forks source link

Import method on the Pods class imports to the wrong pods type #6404

Closed LN-MDeRuscio closed 2 years ago

LN-MDeRuscio commented 2 years ago

Description

When attempting to call import on a pods object, the provided data ends up getting assigned to the first pods type found sorted by title.

On line 10172 of the PodsAPI class, it attempts to load the pod using the value stored in $this->pod. The problem I found is that the value of $this->pod is null, as it appears that the pod variable is never assigned inside the api class. Instead of loading the desired pod type, it grabs the first one it finds. https://github.com/pods-framework/pods/blob/2b6e56a7e175bcb61e0b21664fc1064edf0ab5c2/classes/PodsAPI.php#L10172

Version

2.8.8.1

Testing Instructions

  1. Create at least two pod types. ex: a-pod, b-pod
  2. Add code in a custom plugin or theme for importing some sample data into one of the custom pod types.
  3. Call pods('b-pod')->import($my_test_data); a. If debugging, line 10172 of the PodsAPI class should show the value of $this->pod being equal to null.
  4. Data meant for b-pod will instead end up in a-pod

Screenshots / Screencast

No response

Possible Workaround

For a workaround i found that assigning the name of the desired pod directly to $my_pod->data->api->pod allows the data to be imported into the correct pod.

Example:

$my_pod = pods('b-pod');
$my_pod->data->api->pod = 'b-pod';
$my_pod->import($my_data);

Site Health Information

`
### wp-core ###

version: 5.8.3
site_language: en_US
user_language: en_US
timezone: +00:00
permalink: /%postname%/
https_status: false
multisite: false
user_registration: 0
blog_public: 0
default_comment_status: open
environment_type: production
user_count: 1
dotorg_communication: true

### wp-paths-sizes ###

wordpress_path: /var/www/html
wordpress_size: 48.40 MB (50750235 bytes)
uploads_path: /var/www/html/wp-content/uploads
uploads_size: 0.00 B (0 bytes)
themes_path: /var/www/html/wp-content/themes
themes_size: 54.37 MB (57011961 bytes)
plugins_path: /var/www/html/wp-content/plugins
plugins_size: 11.70 MB (12265294 bytes)
database_size: 3.83 MB (4014080 bytes)
total_size: 118.30 MB (124041570 bytes)

### wp-active-theme ###

name: Child theme
version: 1.0.0
parent_theme: Divi (Divi)
theme_features: core-block-patterns, widgets-block-editor, custom-background, automatic-feed-links, post-thumbnails, menus, title-tag, post-formats, woocommerce, wc-product-gallery-zoom, wc-product-gallery-lightbox, wc-product-gallery-slider, customize-selective-refresh-widgets, editor-style, widgets
theme_path: /var/www/html/wp-content/themes/lfl-theme
auto_update: Disabled

### wp-parent-theme ###

name: Divi (Divi)
version: 4.14.5
author: Elegant Themes
author_website: http://www.elegantthemes.com
theme_path: /var/www/html/wp-content/themes/Divi
auto_update: Disabled

### wp-themes-inactive (1) ###

Twenty Twenty-One: version: 1.4, author: the WordPress team, Auto-updates disabled

### wp-plugins-active (1) ###

Pods - Custom Content Types and Fields: version: 2.8.8.1, author: Pods Framework Team, Auto-updates disabled

### wp-media ###

image_editor: WP_Image_Editor_Imagick
imagick_module_version: 1691
imagemagick_version: ImageMagick 6.9.11-60 Q16 x86_64 2021-01-25 https://imagemagick.org
imagick_version: 3.5.0
file_uploads: File uploads is turned off
post_max_size: 64M
upload_max_filesize: 64M
max_effective_size: 64 MB
max_file_uploads: 20
imagick_limits: 
    imagick::RESOURCETYPE_AREA: 122 MB
    imagick::RESOURCETYPE_DISK: 1073741824
    imagick::RESOURCETYPE_FILE: 786432
    imagick::RESOURCETYPE_MAP: 512 MB
    imagick::RESOURCETYPE_MEMORY: 256 MB
    imagick::RESOURCETYPE_THREAD: 1
imagemagick_file_formats: 3FR, 3G2, 3GP, AAI, AI, APNG, ART, ARW, AVI, AVIF, 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, DPX, DXT1, DXT5, EPDF, EPI, EPS, EPS2, EPS3, EPSF, EPSI, EPT, EPT2, EPT3, ERF, FAX, FILE, FITS, FRACTAL, FTP, FTS, G3, G4, GIF, GIF87, GRADIENT, GRAY, GRAYA, GROUP4, H, HALD, HDR, HEIC, 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, MPG, MRW, MSL, MTV, MVG, NEF, NRW, NULL, ORF, OTB, OTF, PAL, PALM, PAM, 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, TEXT, TGA, THUMBNAIL, TIFF, TIFF64, TILE, TIM, TTC, TTF, TXT, UBRL, UBRL6, UIL, UYVY, VDA, VICAR, VID, VIDEO, VIFF, VIPS, VST, WBMP, WEBM, WEBP, WMV, WPG, X, X3F, XBM, XC, XCF, XPM, XPS, XV, XWD, YCbCr, YCbCrA, YUV
gd_version: bundled (2.1.0 compatible)
gd_formats: GIF, JPEG, PNG, BMP
ghostscript_version: 9.53.3

### wp-server ###

server_architecture: Linux 5.10.60.1-microsoft-standard-WSL2 x86_64
httpd_software: Apache/2.4.48 (Debian)
php_version: 7.4.23 64bit
php_sapi: apache2handler
max_input_variables: 1000
time_limit: 30
memory_limit: 64M
admin_memory_limit: 256M
max_input_time: -1
upload_max_filesize: 64M
php_post_max_size: 64M
curl_version: 7.74.0 OpenSSL/1.1.1k
suhosin: false
imagick_availability: true
pretty_permalinks: true
htaccess_extra_rules: false

### wp-database ###

extension: mysqli
server_version: 5.7.35
client_version: mysqlnd 7.4.23

### wp-constants ###

WP_HOME: undefined
WP_SITEURL: undefined
WP_CONTENT_DIR: /var/www/html/wp-content
WP_PLUGIN_DIR: /var/www/html/wp-content/plugins
WP_MEMORY_LIMIT: 40M
WP_MAX_MEMORY_LIMIT: 256M
WP_DEBUG: true
WP_DEBUG_DISPLAY: true
WP_DEBUG_LOG: false
SCRIPT_DEBUG: false
WP_CACHE: false
CONCATENATE_SCRIPTS: undefined
COMPRESS_SCRIPTS: undefined
COMPRESS_CSS: undefined
WP_LOCAL_DEV: undefined
DB_CHARSET: utf8
DB_COLLATE: undefined

### wp-filesystem ###

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

### pods ###

pods-server-software: Apache/2.4.48 (Debian)
pods-user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36
pods-session-save-path: undefined
pods-session-save-path-exists: No
pods-session-save-path-writable: No
pods-session-max-lifetime: 1440
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: No
pods-object-cache-memcache: No
pods-object-cache-memcached: No
pods-object-cache-redis: No
pods-memory-current-usage: 5.883M
pods-memory-current-usage-real: 4.000M
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: No

`

Pods Package

No response

sc0ttkclark commented 2 years ago

Fixed via https://github.com/pods-framework/pods/commit/aac7594e5ec1e43c763636e5bddb8c7c4a3b4687 and it will be included in Pods 2.8.9