-
Notifications
You must be signed in to change notification settings - Fork 571
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
Custom field files get deleted when upgrading CMB2 included as Composer package #1492
Comments
Have you checked in the database directly to see if the meta fields are actually gone? Or is it just visually in the editor screen that it looks gone? Asking because Also, unless you're saving at the same time, simply upgrading CMB2 via composer shouldn't be causing any file loss unless the files are stored in a spot where the upgrade process replaces the same folder. Line 44 in question: https://github.com/CMB2/CMB2/blob/develop/includes/helper-functions.php#L44 |
Actually that's probably exactly why it's getting lost, you're adding things to the place where it would be getting updated and thus lost. The 3rd party code shouldn't be getting added to the cmb2 folder directly. It should be getting loaded on its own. |
I implemented that and what happens is... it works BUT |
I found another "bug". If I write my own CMB_Type_XXXX or a REST piece, the I have found a relatively simple solution: to transform the Example:
$cmb_includes = array( cmb2_dir( 'includes' ));
|
Part of what I was getting at yesterday is that you should not be editing or adding any custom files to any CMB2 core folders. Leave those alone and load your customized code elsewhere. I don't believe the helper-functions.php file necessarily needs to be aware of your file that's loading your custom code, as long as it gets loaded correctly. Also something to note is that we have a pretty interesting way to handle loading of the latest CMB2 even if other plugins are also bundling CMB2. It can be seen at https://github.com/CMB2/CMB2/blob/develop/init.php#L108-L132 |
Describe the bug
helper-functions.php line 44 tries to autoload 3rd party custom field files from the
includes
sub-directory even when CMB2 is being included as Composer package.This is quite bad, because when a new CMB2 release is out, it can erase the 3rd party files and break the website.
Steps to reproduce (I have confirmed I can reproduce this issue on the
develop
branch):Possible Solution
Add an override constant in the init file or some way to specify a path, for example in composer.json.
Possible Solution's Risk Level
Having multiple plugins including the same 3rd party field types could lead to conflicts.
Screenshots
If applicable, add screenshots to help explain your problem.
CMB2 Field Registration Code:
Your Environment
Browser name and version: Firefox latest version
Operating System and version (desktop or mobile): Windows 10 Pro
Additional context
The text was updated successfully, but these errors were encountered: