Support Forum
Hi,
This isn't the page the issue is happening on. It's only on wp-admin/post.php?post=280&action=edit
With just Meta Box, Meta Box AIO, and Advanced Scripts (this is where the code you gave me is added), I'm still having the issue.
EDIT: Re-ordering won't save either:
https://imgur.com/wweB3n4
Checking server logs, a few minutes ago I got this:
[24-Mar-2022 22:11:00 UTC] PHP Notice: Undefined index: to in /var/www/htdocs/wp-content/plugins/meta-box-aio/vendor/meta-box/mb-relationships/inc/query/normalizer.php on line 78
[24-Mar-2022 22:11:00 UTC] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')) WHERE 1=1 AND ((wp_posts.post_type = 'course' AND (wp_posts.post_status = '' at line 1 for query SELECT wp_posts.* , mbr.to AS <code>mbr_event-to-course-relationship_to</code> FROM wp_posts INNER JOIN wp_mb_relationships AS mbr ON (mbr.from = wp_posts.ID AND mbr.type = 'event-to-course-relationship' AND mbr.to IN ()) WHERE 1=1 AND ((wp_posts.post_type = 'course' AND (wp_posts.post_status = 'publish'))) GROUP BY <code>mbr_event-to-course-relationship_to</code>, wp_posts.ID ORDER BY mbr.order_to made by include('phar:///usr/local/bin/wp/php/boot-phar.php'), include('phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/wp-cli.php'), WP_CLI\bootstrap, WP_CLI\Bootstrap\LaunchRunner->process, WP_CLI\Runner->start, WP_CLI\Runner->load_wordpress, require('wp-settings.php'), do_action('init'), WP_Hook->do_action, WP_Hook->apply_filters, RWMB_Core->register_meta_boxes, apply_filters('rwmb_meta_boxes'), WP_Hook->apply_filters, qrsi_select_adv_repeater, WP_Query->__construct, WP_Query->query, WP_Query->get_posts
And this from another:
Thu Mar 24 22:10:59 UTC 2022
Configuring /var/www/secure-debug.php
Configuring /var/www/wp-config.php for secure debug...
Installing Query Monitor Plugin...
Notice: Undefined index: to in /var/www/htdocs/wp-content/plugins/meta-box-aio/vendor/meta-box/mb-relationships/inc/query/normalizer.php on line 78
Warning: query-monitor: Plugin already installed.
Activating 'query-monitor'...
Plugin 'query-monitor' activated.
Success: Plugin already installed.
Notice: Undefined index: to in /var/www/htdocs/wp-content/plugins/meta-box-aio/vendor/meta-box/mb-relationships/inc/query/normalizer.php on line 78
Success: The cache was flushed.
And this from the NGINX logs:
https://pastebin.com/0MUUD94D
And this from the query monitor plugin:
SELECT wp_posts.* , mbr.to AS<code>mbr_event-to-course-relationship_to</code>
FROM wp_posts
INNER JOIN wp_mb_relationships AS mbr
ON (mbr.from = wp_posts.ID
AND mbr.type = 'event-to-course-relationship'
AND mbr.to IN ())
WHERE 1=1
AND ((wp_posts.post_type = 'course'
AND (wp_posts.post_status = 'publish'
OR wp_posts.post_status = 'future'
OR wp_posts.post_status = 'draft'
OR wp_posts.post_status = 'pending'
OR wp_posts.post_status = 'private')))
GROUP BY <code>mbr_event-to-course-relationship_to</code>, wp_posts.ID
ORDER BY mbr.order_to
WP_Query->get_posts()
wp-includes/class-wp-query.php:3111
WP_Query->query()
wp-includes/class-wp-query.php:3542
WP_Query->__construct()
wp-includes/class-wp-query.php:3653
qrsi_select_adv_repeater()
/tmp/46-schedule-repeater.php:24
apply_filters('rwmb_meta_boxes')
wp-includes/plugin.php:189
RWMB_Core->register_meta_boxes()
wp-content/plugins/meta-box/inc/core.php:49
do_action('init')
wp-includes/plugin.php:474
When viewing an event page, the error changes to this:
Only variables should be passed by reference
wp-content/plugins/meta-box/inc/fields/file-input.php:38
RWMB_File_Input_Field::html()
wp-content/plugins/meta-box/inc/field.php:580
RWMB_Field::call()
wp-content/plugins/meta-box/inc/field.php:48
RWMB_Field::show()
wp-content/plugins/meta-box/inc/field.php:580
RWMB_Field::call()
wp-content/plugins/meta-box/inc/meta-box.php:259
RW_Meta_Box->show()
wp-admin/includes/template.php:1395
do_meta_boxes()
wp-admin/includes/post.php:2296
the_block_editor_meta_boxes()
wp-admin/edit-form-blocks.php:309
The code it's referencing might be the one you helped me with here: https://support.metabox.io/topic/query-advanced-select-field-by-relationship/
Fully updated code here: https://pastebin.com/eSPQmuzH
Hi Ryan,
Please check this screen record if it works as your expectation?
https://monosnap.com/file/AupgEXyOiCCzkMK0IcdwOmUyKzOwD4
Thank you very much – that looks like it's working correctly. The most important thing is that the relationships don't disappear.
Was there anything wrong with the code I was using, or is there anything I should be cautious of in the future?
Thank you again. I appreciate it.
Hi,
It looks like there is a conflict between MB Relationships and another plugin or a snippet code on your site. What I've done:
- Deactivate all plugins except Meta Box and MB AIO
- Assign the field group from Event to Post to avoid the issue with the setting max_input_vars (too many inputs when submitting)
- Disable other snippets in the Advanced Script board.
Unfortunately the site is broken entirely now.
The Events field group shouldn't be appearing on every post, just events. Was it confirmed that it was an issue with max_input_vars? How does moving it from the Events circumvent that?
From some testing, it looks like the error is with the other code you helped me with in the other thread:
https://support.metabox.io/topic/query-advanced-select-field-by-relationship/
https://pastebin.com/eSPQmuzH
What part of this would be causing the error?
Hi,
Sorry, as I said above, I've just assigned the field group Event to (default) Post to re-check the issue. Now, assign it back to Event and the relationships still works as well, screen record https://monosnap.com/file/1QNR2s5GewCEbnRHzXWam0oT5dSMaz
So we can confirm it's not the problem with the PHP setting max_input_vars, I see you increase this value to 500k.
You can try to deactivate all plugins then activate them one-by-one to find the conflicting plugin.
Regarding the issue with the code on this topic https://support.metabox.io/topic/query-advanced-select-field-by-relationship/, please check it after resolving this issue. Just to make sure MB Relationships works properly.
Hi,
Sorry, just for clarity, the conflict is because of that code snippet. I tested it by enabling plug-ins one by one and updating the post three times for each one I enabled. None of the plug-ins triggered it; but, the code snippet did. The glitch is fairly inconsistent; so, I can't be 100% sure. I want to say I'm 80% sure the error is there when the code snippet from the other thread is active. It works except for when it doesn't, which has made troubleshooting difficult. This is the first time it's persisted long enough to actually investigate.
In the thread where I requested help with that snipped, you'd asked me why I needed it set up that way and I didn't have time to explain. But, every year, the event has 9-30+ courses. Each course is organized by day, in alphabetical order. Some courses are reused in later events. And no event is deleted - just archived, so the past schedules have to remain unaffected. That was the trickiest part.
My options were a custom field on each course or setting up a cloneable group with select advanced fields populated from the relationship. The custom field on each course option, honestly, just isn't compatible with my brain. I have ADHD and trying to keep track of what courses go on what years would be borderline impossible for me.
The cloneable group approach lets me immediately see what courses are on what day, and that they're in the right order. It also doesn't mess with the archived versions of the events.
If there's another way to do this, I'm very open to suggestions. Otherwise, figuring out what part of the code is causing this the best option.
Sorry for the wall of text. I know there are many tickets you're working through and I appreciate your time and help with this.
Hi,
I've checked your site again with two scripts that you've added. But do not see the issue, I also made a screen record, check it here https://youtu.be/RmRO7Peas1U
There is one note, I've added the condition to check the post ID existed before creating the query, in the script Course Schedule.
if( $post_id ) { //here
$course_args = array(
'post_type' => 'course',
'relationship' => array(
'id' => 'event-to-course-relationship',
'from' => $post_id,
),
'nopaging' => true,
);
$course_query = new WP_Query($course_args);
$course_post_id = array();
if ($course_query->have_posts()) {
while ($course_query->have_posts()) {
$course_query->the_post();
array_push($course_post_id, get_the_ID());
}
}
}