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

Update from 2.7.31 to 2.8.5 and image value from extended CPTs are not loaded #6325

Open cfaria opened 2 years ago

cfaria commented 2 years ago

Description

Hi,

I've created some custom fields to extend the WooCommerce Product Post type. Among them are relationships, images, plain text, WYSIWYG, etc... It works great in 2.7.31 but when I upgrade to 2.8.X (it doesn't matter wich 2.8 version) the image fields values are not returned as expected...

I'm getting the image field value with get_post_meta. If I inspect the database, the field is there with the correct value, so there shouldn't be any problem using get_post_meta.

Debugging a bit I've found out that Pods is using its own get_meta function to retrieve the value https://github.com/pods-framework/pods/blob/e3b805297b865c0788925991b74994be179b750e/classes/PodsMeta.php#L3356.

This is the callstack I've been looking at:

Captura de pantalla 2021-11-23 a las 13 17 28

When I'm trying to get the value of a custom image field using get_post_meta, that field function returns false here:

https://github.com/pods-framework/pods/blob/e3b805297b865c0788925991b74994be179b750e/classes/Pods.php#L1089

and that's because this lookup_related_items call returns an empty array:

$this->data->api->lookup_related_items( $current_field['id'], $current_field->get_parent_id(), $ids, $current_field );

https://github.com/pods-framework/pods/blob/e3b805297b865c0788925991b74994be179b750e/classes/Pods.php#L1082

Tell me if I can do anything else to help to fix this issue ;D. For the moment I'll stick with 2.7.31...

Version

2.8.5

Testing Instructions

No response

Screenshots / Screencast

No response

Possible Workaround

No response

Site Health Information

`
### wp-core ###

version: 5.8.1
site_language: es_ES
user_language: es_ES
timezone: Europe/Madrid
permalink: /%postname%/
https_status: false
multisite: false
user_registration: 0
blog_public: 1
default_comment_status: open
environment_type: production
user_count: 45898
dotorg_communication: true

### wp-paths-sizes ###

wordpress_path: /Users/carlos/Sites/domain.com/web/wp
wordpress_size: loading...
uploads_path: /Users/carlos/Sites/domain.com/web/app/uploads
uploads_size: loading...
themes_path: /Users/carlos/Sites/domain.com/web/app/themes
themes_size: loading...
plugins_path: /Users/carlos/Sites/domain.com/web/app/plugins
plugins_size: loading...
database_size: loading...
total_size: loading...

### wp-active-theme ###

name: hc
version: 2.20.1
author: Supermundano
author_website: https://supermudano.com/
parent_theme: none
theme_features: core-block-patterns, widgets-block-editor, post-thumbnails, soil-disable-trackbacks, soil-jquery-cdn, soil-js-to-footer, soil-nav-walker, soil-nice-search, soil-relative-urls, title-tag, menus, html5, woocommerce, widgets, editor-style
theme_path: /Users/carlos/Sites/domain.com/web/app/themes/domainv2

### wp-mu-plugins (5) ###

Bedrock Autoloader: version: 1.0.0, author: Roots
Disable plugins on development: version: 1.0.0, author: Supermundano
Disallow Indexing: version: 1.0.0, author: Roots
LearnDash LMS Multisite: version: 1.0.0, author: LearnDash
Register Theme Directory: version: 1.0.0, author: Roots

### wp-plugins-active (38) ###

Advanced Custom Fields PRO: version: 5.10.2, author: Delicious Brains
Advanced Order Export For WooCommerce: version: 3.1.9, author: AlgolPlus (latest version: 3.2.1)
AffiliateWP: version: 2.7.5, author: Sandhills Development, LLC
Akismet Anti-Spam: version: 4.2.1, author: Automattic
bbPress: version: 2.6.6, author: The bbPress Contributors (latest version: 2.6.8)
Boxzilla: version: 3.2.25, author: ibericode
Disable Gutenberg Autosave: version: 1.0.10, author: websevendev
Facebook for WooCommerce: version: 2.6.7, author: Facebook
GD bbPress Attachments: version: 4.3, author: Milan Petrovic
GDPR Cookie Consent: version: 2.3.7, author: WebToffee
Heartbeat Control by WP Rocket: version: 2.0, author: WP Rocket
LearnDash LMS: version: 3.5.1.2, author: LearnDash (latest version: 3.6.0)
LearnDash LMS - bbPress Integration: version: 2.2.1, author: LearnDash
LearnDash LMS - WooCommerce Integration: version: 1.9.3.3, author: LearnDash
MC4WP: Mailchimp for WordPress: version: 4.8.6, author: ibericode
MC4WP: Mailchimp for WordPress Premium: version: 4.8.19, author: ibericode
PixelYourSite: version: 8.2.8, author: PixelYourSite (latest version: 8.2.13)
PixelYourSite Pinterest: version: 3.2.2, author: PixelYourSite (latest version: 3.2.3)
Pods - Custom Content Types and Fields: version: 2.8.5, author: Pods Framework Team
PW Advanced Woo Reporting: version: 4.9, author: Proword
RedSys Gateway for WooCommerce Pro: version: 3.3.9, author: codection
Shortcake (Shortcode UI): version: 0.7.4, author: Fusion Engineering and community
Shortcake (Shortcode UI) Richtext: version: 1.3, author: XWP
Soil: version: 3.8.1, author: Roots
Supermundano ACF Blocks: version: 1.0.0, author: Supermundano
Tawk.to Live Chat: version: 0.5.5, author: Tawkto (latest version: 0.6.0)
WooCommerce: version: 5.8.0, author: Automattic (latest version: 5.9.0)
WooCommerce Gift Certificates Pro: version: 3.6.4, author: IgniteWoo.com
WooCommerce PayPal Checkout Gateway: version: 2.1.3, author: WooCommerce
WooCommerce PDF Invoices & Packing Slips: version: 2.10.1, author: Ewout Fernhout (latest version: 2.10.4)
WooCommerce PDF Invoices & Packing Slips Premium Templates: version: 2.7.1, author: Ewout Fernhout
WooCommerce PDF Invoices & Packing Slips Professional: version: 2.2.9, author: Ewout Fernhout
WooCommerce Smart Coupons: version: 4.8.0, author: StoreApps
WooCommerce Sponsor a Friend Plugin: version: 2.3.3, author: MB Création
WooCommerce Stripe Gateway: version: 5.7.0, author: WooCommerce (latest version: 5.8.0)
WooCommerce Waitlist: version: 1.8.8, author: WooCommerce
Woocommere Build Your Pack: version: 1.0.0, author: supermundano
Yoast SEO: version: 17.5, author: Team Yoast (latest version: 17.6)

### wp-plugins-inactive (12) ###

Autoptimize: version: 2.9.2, author: Frank Goossens (futtta)
Enable jQuery Migrate Helper: version: 1.3.0, author: The WordPress Team
Supermundano Custom Roles: version: 1.0, author: Supermundano
User Switching: version: 1.5.8, author: John Blackbourn & contributors
WooCommerce Google Analytics Integration: version: 1.5.3, author: WooCommerce (latest version: 1.5.4)
WooCommerce Servired/RedSys Spain Gateway: version: 16.0.1, author: José Conti
WooCommerce Waitlist: version: 1.8.8, author: WooCommerce
WP Crontrol: version: 1.11.0, author: John Blackbourn & crontributors (latest version: 1.12.0)
WP Mail SMTP: version: 3.1.0, author: WPForms (latest version: 3.2.1)
WP Maintenance Mode: version: 2.4.1, author: Designmodo
WP Migrate DB: version: 2.2.0, author: Delicious Brains (latest version: 2.2.1)
WP Super Cache: version: 1.7.4, author: Automattic

### wp-media ###

image_editor: WP_Image_Editor_GD
imagick_module_version: No disponible
imagemagick_version: No disponible
imagick_version: No disponible
file_uploads: File uploads is turned off
post_max_size: 128M
upload_max_filesize: 128M
max_effective_size: 128 MB
max_file_uploads: 20
gd_version: 2.3.2
gd_formats: GIF, JPEG, PNG, WebP, BMP, XPM
ghostscript_version: not available

### wp-server ###

server_architecture: Darwin 19.6.0 x86_64
httpd_software: nginx/1.17.10
php_version: 7.4.16 64bit
php_sapi: fpm-fcgi
max_input_variables: 1000
time_limit: 300
memory_limit: 2G
max_input_time: 60
upload_max_filesize: 128M
php_post_max_size: 128M
curl_version: 7.79.1 (SecureTransport) OpenSSL/1.1.1l
suhosin: false
imagick_availability: false
pretty_permalinks: true

### wp-database ###

extension: mysqli
server_version: 10.4.12-MariaDB
client_version: mysqlnd 7.4.16

### wp-constants ###

WP_HOME: http://domain.test
WP_SITEURL: http://domain.test/wp
WP_CONTENT_DIR: /Users/carlos/Sites/domain.com/web/app
WP_PLUGIN_DIR: /Users/carlos/Sites/domain.com/web/app/plugins
WP_MEMORY_LIMIT: 256M
WP_MAX_MEMORY_LIMIT: 2G
WP_DEBUG: true
WP_DEBUG_DISPLAY: true
WP_DEBUG_LOG: true
SCRIPT_DEBUG: true
WP_CACHE: false
CONCATENATE_SCRIPTS: false
COMPRESS_SCRIPTS: undefined
COMPRESS_CSS: undefined
WP_LOCAL_DEV: undefined
DB_CHARSET: utf8mb4
DB_COLLATE: undefined

### wp-filesystem ###

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

### pods ###

pods-server-software: nginx/1.17.10
pods-user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:94.0) Gecko/20100101 Firefox/94.0
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: Yes
pods-object-cache-memcache: No
pods-object-cache-memcached: No
pods-object-cache-redis: No
pods-memory-current-usage: 49,927M
pods-memory-current-usage-real: 18,000M
pods-network-wide: No
pods-install-location: /Users/carlos/Sites/domain.com/web/app/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

{
    "meta": {
        "version": "2.8.5",
        "build": 1637671001
    },
    "pods": [
        {
            "name": "product",
            "id": 90,
            "label": "Product",
            "description": "",
            "type": "post_type",
            "storage": "meta",
            "object": "product",
            "pfat_enable": "0",
            "pfat_run_outside_loop": "0",
            "pfat_append_single": "append",
            "pfat_filter_single": "the_content",
            "pfat_append_archive": "append",
            "pfat_filter_archive": "the_content",
            "rest_enable": "0",
            "rest_base": "product",
            "read_all": "0",
            "write_all": "0",
            "built_in_taxonomies_sm_banner_location": "0",
            "_migrated_28": "1",
            "groups": [
                {
                    "name": "mas_campos",
                    "id": 279668,
                    "label": "M\u00e1s campos",
                    "description": "",
                    "weight": 0,
                    "fields": [
                        {
                            "name": "teacher",
                            "id": 93,
                            "label": "Profesor",
                            "description": "",
                            "weight": 0,
                            "type": "text",
                            "required": "0",
                            "text_allow_shortcode": "0",
                            "text_allow_html": "0",
                            "text_allowed_html_tags": "strong em a ul ol li b i",
                            "text_max_length": "255",
                            "pick_post_status": [
                                "publish"
                            ],
                            "admin_only": "0",
                            "restrict_role": "0",
                            "restrict_capability": "0",
                            "hidden": "0",
                            "read_only": "0",
                            "roles_allowed": [
                                "administrator"
                            ],
                            "rest_read": "0",
                            "rest_write": "0",
                            "rest_pick_response": "array",
                            "rest_pick_depth": "2"
                        },
                        {
                            "name": "init_date",
                            "id": 94,
                            "label": "Fecha de inicio",
                            "description": "",
                            "weight": 1,
                            "type": "date",
                            "required": "0",
                            "date_format": "mdy",
                            "date_allow_empty": "1",
                            "date_html5": "0",
                            "pick_post_status": [
                                "publish"
                            ],
                            "admin_only": "0",
                            "restrict_role": "0",
                            "restrict_capability": "0",
                            "hidden": "0",
                            "read_only": "0",
                            "roles_allowed": [
                                "administrator"
                            ],
                            "rest_read": "0",
                            "rest_write": "0",
                            "rest_pick_response": "array",
                            "rest_pick_depth": "2"
                        },
                        {
                            "name": "list_image",
                            "id": 97,
                            "label": "Imagen listado",
                            "description": "",
                            "weight": 3,
                            "type": "file",
                            "required": "0",
                            "file_format_type": "single",
                            "file_uploader": "attachment",
                            "file_attachment_tab": "upload",
                            "file_edit_title": "1",
                            "file_linked": "0",
                            "file_limit": "0",
                            "file_restrict_filesize": "10MB",
                            "file_type": "images",
                            "file_add_button": "A\u00f1adir archivo",
                            "file_modal_title": "Inclu\u00edr un archivo",
                            "file_modal_add_button": "A\u00f1adir archivo",
                            "file_wp_gallery_output": "0",
                            "file_wp_gallery_link": "post",
                            "file_wp_gallery_columns": "1",
                            "file_wp_gallery_random_sort": "0",
                            "file_wp_gallery_size": "thumbnail",
                            "pick_post_status": [
                                "publish"
                            ],
                            "admin_only": "0",
                            "restrict_role": "0",
                            "restrict_capability": "0",
                            "hidden": "0",
                            "read_only": "0",
                            "roles_allowed": [
                                "administrator"
                            ],
                            "rest_read": "0",
                            "rest_write": "0",
                            "rest_pick_response": "array",
                            "rest_pick_depth": "2",
                            "unique": "0"
                        },
                        {
                            "name": "course_type",
                            "id": 98,
                            "label": "Tipo de curso",
                            "description": "",
                            "weight": 3,
                            "type": "pick",
                            "pick_object": "custom-simple",
                            "pick_custom": "capsula|C\u00e1psula\nediciones|Por ediciones",
                            "required": "0",
                            "pick_format_type": "single",
                            "pick_format_single": "dropdown",
                            "pick_format_multi": "checkbox",
                            "pick_taggable": "0",
                            "pick_limit": "0",
                            "pick_allow_html": "0",
                            "pick_post_status": [
                                "publish"
                            ],
                            "admin_only": "0",
                            "restrict_role": "0",
                            "restrict_capability": "0",
                            "hidden": "0",
                            "read_only": "0",
                            "roles_allowed": [
                                "administrator"
                            ],
                            "rest_read": "0",
                            "rest_write": "0",
                            "rest_pick_response": "array",
                            "rest_pick_depth": "2"
                        },
                        {
                            "name": "duracion",
                            "id": 122465,
                            "label": "Duraci\u00f3n",
                            "description": "Duraci\u00f3n del curso si es curso por ediciones",
                            "weight": 4,
                            "type": "text",
                            "required": "0",
                            "text_allow_shortcode": "0",
                            "text_allow_html": "0",
                            "text_allowed_html_tags": "strong em a ul ol li b i",
                            "text_max_length": "255",
                            "pick_post_status": [
                                "publish"
                            ],
                            "admin_only": "0",
                            "restrict_role": "0",
                            "restrict_capability": "0",
                            "hidden": "0",
                            "read_only": "0",
                            "roles_allowed": [
                                "administrator"
                            ],
                            "rest_read": "0",
                            "rest_write": "0",
                            "rest_pick_response": "array",
                            "rest_pick_depth": "2",
                            "unique": "0",
                            "text_repeatable": "0"
                        },
                        {
                            "name": "video",
                            "id": 122466,
                            "label": "Video",
                            "description": "Video del curso. Aparecer\u00e1 en lugar de la imagen destacada si existe en la ficha de producto",
                            "weight": 5,
                            "type": "website",
                            "required": "0",
                            "website_format": "normal",
                            "website_clickable": "0",
                            "website_new_window": "0",
                            "website_max_length": "255",
                            "website_html5": "0",
                            "pick_post_status": [
                                "publish"
                            ],
                            "admin_only": "0",
                            "restrict_role": "0",
                            "restrict_capability": "0",
                            "hidden": "0",
                            "read_only": "0",
                            "roles_allowed": [
                                "administrator"
                            ],
                            "rest_read": "0",
                            "rest_write": "0",
                            "rest_pick_response": "array",
                            "rest_pick_depth": "2",
                            "unique": "0",
                            "website_repeatable": "0",
                            "website_allow_port": "0"
                        },
                        {
                            "name": "contenido",
                            "id": 122473,
                            "label": "Contenido",
                            "description": "Contenido del curso. Se mostrar\u00e1 a continuaci\u00f3n de la descripci\u00f3n",
                            "weight": 6,
                            "type": "wysiwyg",
                            "required": "0",
                            "wysiwyg_editor": "tinymce",
                            "wysiwyg_media_buttons": "1",
                            "wysiwyg_oembed": "0",
                            "wysiwyg_wptexturize": "1",
                            "wysiwyg_convert_chars": "1",
                            "wysiwyg_wpautop": "1",
                            "wysiwyg_allow_shortcode": "0",
                            "pick_post_status": [
                                "publish"
                            ],
                            "admin_only": "0",
                            "restrict_role": "0",
                            "restrict_capability": "0",
                            "hidden": "0",
                            "read_only": "0",
                            "roles_allowed": [
                                "administrator"
                            ],
                            "rest_read": "0",
                            "rest_write": "0",
                            "rest_pick_response": "array",
                            "rest_pick_depth": "2",
                            "unique": "0",
                            "wysiwyg_repeatable": "0"
                        },
                        {
                            "name": "review",
                            "id": 122467,
                            "label": "Review",
                            "description": "Review asociada al curso que aparece en el sidebar",
                            "weight": 7,
                            "type": "pick",
                            "pick_object": "post_type",
                            "pick_val": "sm_review",
                            "required": "0",
                            "pick_format_type": "single",
                            "pick_format_single": "dropdown",
                            "pick_format_multi": "checkbox",
                            "pick_taggable": "0",
                            "pick_limit": "0",
                            "pick_allow_html": "0",
                            "pick_post_status": [
                                "publish"
                            ],
                            "admin_only": "0",
                            "restrict_role": "0",
                            "restrict_capability": "0",
                            "hidden": "0",
                            "read_only": "0",
                            "roles_allowed": [
                                "administrator"
                            ],
                            "rest_read": "0",
                            "rest_write": "0",
                            "rest_pick_response": "array",
                            "rest_pick_depth": "2",
                            "unique": "0",
                            "pick_allow_add_new": "1",
                            "pick_show_icon": "1",
                            "pick_show_edit_link": "1",
                            "pick_show_view_link": "1"
                        },
                        {
                            "name": "related_info",
                            "id": 122469,
                            "label": "Info relacionada",
                            "description": "Informaci\u00f3n relacionada que aparecer\u00e1 en el sidebar del curso",
                            "weight": 8,
                            "type": "wysiwyg",
                            "required": "0",
                            "wysiwyg_editor": "tinymce",
                            "wysiwyg_media_buttons": "1",
                            "wysiwyg_oembed": "0",
                            "wysiwyg_wptexturize": "1",
                            "wysiwyg_convert_chars": "1",
                            "wysiwyg_wpautop": "1",
                            "wysiwyg_allow_shortcode": "0",
                            "pick_post_status": [
                                "publish"
                            ],
                            "admin_only": "0",
                            "restrict_role": "0",
                            "restrict_capability": "0",
                            "hidden": "0",
                            "read_only": "0",
                            "roles_allowed": [
                                "administrator"
                            ],
                            "rest_read": "0",
                            "rest_write": "0",
                            "rest_pick_response": "array",
                            "rest_pick_depth": "2",
                            "unique": "0",
                            "wysiwyg_repeatable": "0"
                        },
                        {
                            "name": "regalo",
                            "id": 122475,
                            "label": "regalo",
                            "description": "Productos regalo relacionados con el producto actual",
                            "weight": 9,
                            "type": "pick",
                            "pick_object": "post_type",
                            "pick_val": "product",
                            "required": "0",
                            "pick_format_type": "multi",
                            "pick_format_single": "dropdown",
                            "pick_format_multi": "multiselect",
                            "pick_taggable": "0",
                            "pick_limit": "0",
                            "pick_allow_html": "0",
                            "pick_post_status": [
                                "publish",
                                "future",
                                "draft"
                            ],
                            "admin_only": "0",
                            "restrict_role": "0",
                            "restrict_capability": "0",
                            "hidden": "0",
                            "read_only": "0",
                            "roles_allowed": [
                                "administrator"
                            ],
                            "rest_read": "0",
                            "rest_write": "0",
                            "rest_pick_response": "array",
                            "rest_pick_depth": "2",
                            "unique": "0",
                            "pick_allow_add_new": "1",
                            "pick_show_icon": "1",
                            "pick_show_edit_link": "1",
                            "pick_show_view_link": "1"
                        },
                        {
                            "name": "simple_title",
                            "id": 122476,
                            "label": "T\u00edtulo simple",
                            "description": "T\u00edtulo utilizado en productos regalo para mostrarlos en el popup de productos regalo de productos principales",
                            "weight": 10,
                            "type": "text",
                            "required": "0",
                            "text_allow_shortcode": "0",
                            "text_allow_html": "0",
                            "text_allowed_html_tags": "strong em a ul ol li b i",
                            "text_max_length": "255",
                            "pick_post_status": [
                                "publish"
                            ],
                            "admin_only": "0",
                            "restrict_role": "0",
                            "restrict_capability": "0",
                            "hidden": "0",
                            "read_only": "0",
                            "roles_allowed": [
                                "administrator"
                            ],
                            "rest_read": "0",
                            "rest_write": "0",
                            "rest_pick_response": "array",
                            "rest_pick_depth": "2",
                            "unique": "0",
                            "text_repeatable": "0"
                        }
                    ]
                }
            ]
        }
    ]
}
sc0ttkclark commented 2 years ago

Let's retest on 2.8.6, there may be some tweaks in there that address this issue.

cfaria commented 2 years ago

This is still happening in 2.8.8.1. Maybe is related to #6326 If I can help in any way I'll do what you need.

JoryHogeveen commented 2 years ago

@sc0ttkclark I think this is related to meta vs podsrel tables. See #3614

@cfaria If you re-save a product, does it return a correct value then?

cfaria commented 2 years ago

@JoryHogeveen No, saving the product as it is doesn't return the correct value. But if you mean to save the product selecting the values first, then the value is saved again and then it does return it when I call get_post_meta, but the old values that are not changed are still there in the database and are not returned. It only returns the values that I change. That's not possible for me as I have a lot of custom fields in a lot of CPTs.

@sc0ttkclark and I were trying to fix the issue some weeks ago and we manage to recover the post custom fields types (we tested an extended WooCommerce Product), but the values are still not returned unless I change the value and save it.

Seems like #6326 would be fixed exporting all the fields with the Migrate Package component, updating the plugin to 2.10.0 and importing with the same component. But #6325 is still there...

madeincima commented 1 year ago

Hi everyone,

I see that this bug is months old but I still have the same issue with custom fields applied on media. When I save the media I can see the right values in the database but when I come back to the backend the custom field values are all wrong (so if I save again I save wrong values in the database too). This is happening for the custom fields type checkboxes yes/no.

Is there any workaround or fix for these?

Thank you!