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

Error messages: Updating failed. Could not update the meta value of _filled in database. #2827

Open
GER32467 opened this issue Jun 12, 2024 · 14 comments
Assignees

Comments

@GER32467
Copy link

GER32467 commented Jun 12, 2024

"Updating failed. Could not update the meta value of _filled in database." Continue to receive this error when updating jobs.

@GER32467 GER32467 changed the title Error messages Error messages: Updating failed. Could not update the meta value of _filled in database. Jun 12, 2024
@GER32467 GER32467 reopened this Jun 12, 2024
@masteradhoc
Copy link
Contributor

masteradhoc commented Jun 27, 2024

Hi there
We have the same issue on several sites so we want to give a bigger insight on why could happen.
As we see the issue can be reproduced if these two plugins are active:

  • wpjobmanager
  • acf

As soon as a custom field is added and linked to the job posttype and an existing job gets edited this error sometimes appears
image

Console Log looks like this then
POST https://xxxxx/wp-json/wp/v2/job-listings/26?_locale=user
500 (Internal Server Error)

Seems like it only happens if existing jobs get edited / duplicated (f.e. over yoast duplicate post plugin). New Posts that are created are not affected. Also if fields are added over code - not acf - it works fine.

Thanks for checking this

@masteradhoc
Copy link
Contributor

@thedebian any idea? Thanks for your help

@AnthonerMonzon
Copy link

@thedebian. Any idea or fix for this, I have same issue here. Thanks.

@thedebian
Copy link
Contributor

Hi there,
Would you happen to have logs of the error happening on the server by any chance? (when you see the 500 happening)

@masteradhoc
Copy link
Contributor

masteradhoc commented Jul 17, 2024

@thedebian what i can see is in the server logs:
Error 500 - POST /wp-json/wp/v2/job-listings/3382?_locale=user HTTP/1.0

https://eschercare.digicube.dev/wp-json/wp/v2/job-listings/3382?_locale=user

With all debug options enabled i can also see this in the console:

{
    "code": "rest_meta_database_error",
    "message": "Could not update the meta value of _filled in database.",
    "data": {
        "key": "_featured",
        "status": 500
    },
    "additional_data": [
        {
            "key": "_filled",
            "status": 500
        }
    ],
    "additional_errors": [
        {
            "code": "rest_meta_database_error",
            "message": "Could not update the meta value of _featured in database.",
            "data": {
                "key": "_featured",
                "status": 500
            },
            "additional_data": [
                {
                    "key": "_filled",
                    "status": 500
                }
            ]
        }
    ]
}

@fjorgemota fjorgemota self-assigned this Jul 17, 2024
@fjorgemota
Copy link
Member

I tested here and I could confirm that the issue seems to happy when a job is cloned using yoast duplicate post with a custom field added via ACF to the Jobs post type and using latest WPJM on a clean WP 6.6 site running PHP 8.3.

If you only clone a plugin without having the ACF custom field added it seems like it works fine. The same thing applies if you just have the ACF added to Job post type without cloning it. It's the combination that's breaking everything.

Checking at ACF's source code I couldn't identify anything that would conflict with WPJM, but this definitely does need more investigation to get fixed. Thanks for the report!

@GER32467
Copy link
Author

GER32467 commented Jul 17, 2024 via email

@masteradhoc
Copy link
Contributor

masteradhoc commented Jul 21, 2024

@fjorgemota upon further checking here is what i was able to find.

  1. a job gets created, thats how the database entries look from wpjobmanager
    image

  2. duplicate a job with yoast duplicate post - looks like this

image

So seems like entries are duplicated inside (_filled, _featured). When i try to save the job now with an ACF value set i get these errors:
image

When i went ahead and deleted 513 and 514 the post was able to be updated again without an issue.

Edit: maybe a link to their developer docs where you might have the chance to influence that this doesnt get copied: https://developer.yoast.com/duplicate-post/overview/

@yscik
Copy link
Contributor

yscik commented Jul 22, 2024

Looks like we are calling add_post_meta with $unique = true, which exits early if the meta key already exists. So I imagine it's WPJM adding the metas first, and then the Duplicate plugins adding the meta again regardless.

We could move adding the default metas to a later hook, like wp_after_insert_post.

Right now this is called on wp_after_insert_post:

public function maybe_add_default_meta_data( $post_id, $post ) {
if ( empty( $post ) || self::PT_LISTING === $post->post_type ) {
add_post_meta( $post_id, '_filled', 0, true );
add_post_meta( $post_id, '_featured', 0, true );
}
}

And we have another one called on save_post (via job_manager_save_job_listing):

public function save_job_listing_data( $post_id, $post ) {
global $wpdb;
// These need to exist.
add_post_meta( $post_id, '_filled', 0, true );
add_post_meta( $post_id, '_featured', 0, true );

@masteradhoc
Copy link
Contributor

@yscik sounds good! If you have a PR ready let me know please - happy to help you guys test this.
What will happen to all jobs that already have these duplicate postmeta entries? anything on your side so this can be cleaned?
Would be great to make sure even existing jobs work again that were duplicated once.

@masteradhoc
Copy link
Contributor

@yscik any idea to fix this one? happy to test the PR

@fjorgemota
Copy link
Member

@masteradhoc We are still thinking about how to fix this properly in WPJM. Please give us more time.

In the meantime, feel free to include both _featured and _filled as meta fields for Yoast Duplicate Post to NOT duplicate on the Settings page, in Settings -> Duplicate Post, by informing both fields in a comma separated way:

image

Regarding the already duplicated posts, feel free to delete the duplicated meta fields for each duplicated post with the lowest meta_id. Those are added by WPJM by default, before the Duplicate Post plugin adds the new meta fields with the value.

If possible, please use the "Duplicate Job" already present in the Job Dashboard (it is not available in wp-admin), it also doesn't have this issue.

I hope this helps.

@masteradhoc
Copy link
Contributor

@fjorgemota any news on this? the issue still is here.

@fjorgemota
Copy link
Member

@masteradhoc Not yet. It's on the roadmap to be worked on in the future, but we don't have any specific deadline on when this will be worked on and released to the public, especially given that technically, the workaround above should work well, and that the "Duplicate Job" feature present in the Job Dashboard doesn't have this issue.

As mentioned on the docs here: https://wpjobmanager.com/document/getting-started/adding-jobs-via-admin/

Warning! Adding jobs via the backend, wp-admin dashboard is not recommended. This is because several verification steps are not taken when adding a job this way. WP Job Manager is designed in such a way that all jobs should be submitted via the frontend job submission form.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants