Closed waltercruz closed 4 years ago
Hi @waltercruz,
you have to add support for your plugins and theme to avoid problems with IDs. For example icon
postmeta has to be defined as entity (value reference), see docs.
For example thumbnail_id
(WordPress post thumbnail) has to be linked to post
, see our schema.yml file.
I can help you with adding support, but I am not sure if icon
postmeta is related to theme or any plugin?
it's an acf field.
Reading the docs and trying to figure out!
Right, support for Advanced Custom Fields (ACF) can be tricky (especially when using custom postmeta names), I started similar issue with Pods Framework, see https://github.com/pods-framework/pods/issues/4341.
Please let us know if you create VP files for ACF or if you need more help.
OK, using the dumbest method, I did a backup (mysqldump) and my co-worker restores it, so, by now, we have the same ids on posts and images and acf is still working well.
And now reading the docs about schema.yml!
Hum, acf doesn't create tables, but uses tables from wp itself (postmeta, posts, termmeta). the definitions for serialized fields in these tables should be in acf side or in versionpress itself?
Yes, default WordPress tables are tracked without problems, but VP does not know if icon
postmeta value "231" is only some number (integer, for example image width or something else) or ID of any related entity (post, attachment, user, etc) as in your case. And that is why you have to specify it.
Create custom schema.yml
file in wp-content/.versionpress/plugins/advanced-custom-fields
directory and add following:
postmeta:
value-references:
meta_key@meta_value:
icon: post
Now, VP understands that every icon
postmeta value contains ID of related post (no need to specify particular post_type
). And you can change any icon
value and you should see, that there will be no integer in related .ini
file, but our VPID (used for synchronization).
This is only quick and dirty fix, there should be some general function for ACF like getMenuReference() which could recognize it automatically. Example from WP core is postmeta _menu_item_object_id
with ID value related to post, term, etc.
Nice!
Well, so there's two things that are needed to teach versionpress how to handle in acf: first is the fields definition, and second are the fields values.
By example, this:
Generate 3 rows that define the post fields (first is group, the other two are the fields itself).
INSERT INTO `wp_posts` (`ID`, `post_author`, `post_date`, `post_date_gmt`, `post_content`, `post_title`, `post_excerpt`, `post_status`, `comment_status`, `ping_status`, `post_password`, `post_name`, `to_ping`, `pinged`, `post_modified`, `post_modified_gmt`, `post_content_filtered`, `post_parent`, `guid`, `menu_order`, `post_type`, `post_mime_type`, `comment_count`)
VALUES
(170, 1, '2017-08-01 10:32:16', '2017-08-01 13:32:16', 'a:7:{s:8:\"location\";a:1:{i:0;a:1:{i:0;a:3:{s:5:\"param\";s:4:\"page\";s:8:\"operator\";s:2:\"==\";s:5:\"value\";s:2:\"28\";}}}s:8:\"position\";s:6:\"normal\";s:5:\"style\";s:7:\"default\";s:15:\"label_placement\";s:3:\"top\";s:21:\"instruction_placement\";s:5:\"label\";s:14:\"hide_on_screen\";s:0:\"\";s:11:\"description\";s:0:\"\";}', 'Test Group', 'test-group', 'publish', 'closed', 'closed', '', 'group_598082b9c6cb3', '', '', '2017-08-01 10:44:51', '2017-08-01 13:44:51', '', 0, 'http://antman.local./oncodev/?post_type=acf-field-group&p=170', 0, 'acf-field-group', '', 0);
INSERT INTO `wp_posts` (`ID`, `post_author`, `post_date`, `post_date_gmt`, `post_content`, `post_title`, `post_excerpt`, `post_status`, `comment_status`, `ping_status`, `post_password`, `post_name`, `to_ping`, `pinged`, `post_modified`, `post_modified_gmt`, `post_content_filtered`, `post_parent`, `guid`, `menu_order`, `post_type`, `post_mime_type`, `comment_count`)
VALUES
(171, 1, '2017-08-01 10:32:16', '2017-08-01 13:32:16', 'a:10:{s:4:\"type\";s:4:\"text\";s:12:\"instructions\";s:0:\"\";s:8:\"required\";i:0;s:17:\"conditional_logic\";i:0;s:7:\"wrapper\";a:3:{s:5:\"width\";s:0:\"\";s:5:\"class\";s:0:\"\";s:2:\"id\";s:0:\"\";}s:13:\"default_value\";s:0:\"\";s:11:\"placeholder\";s:0:\"\";s:7:\"prepend\";s:0:\"\";s:6:\"append\";s:0:\"\";s:9:\"maxlength\";s:0:\"\";}', 'Test Field', 'test_field', 'publish', 'closed', 'closed', '', 'field_598082bfc690f', '', '', '2017-08-01 10:44:51', '2017-08-01 13:44:51', '', 170, 'http://antman.local./oncodev/?post_type=acf-field&p=171', 0, 'acf-field', '', 0);
INSERT INTO `wp_posts` (`ID`, `post_author`, `post_date`, `post_date_gmt`, `post_content`, `post_title`, `post_excerpt`, `post_status`, `comment_status`, `ping_status`, `post_password`, `post_name`, `to_ping`, `pinged`, `post_modified`, `post_modified_gmt`, `post_content_filtered`, `post_parent`, `guid`, `menu_order`, `post_type`, `post_mime_type`, `comment_count`)
VALUES
(174, 1, '2017-08-01 10:44:51', '2017-08-01 13:44:51', 'a:10:{s:4:\"type\";s:4:\"text\";s:12:\"instructions\";s:0:\"\";s:8:\"required\";i:0;s:17:\"conditional_logic\";i:0;s:7:\"wrapper\";a:3:{s:5:\"width\";s:0:\"\";s:5:\"class\";s:0:\"\";s:2:\"id\";s:0:\"\";}s:13:\"default_value\";s:0:\"\";s:11:\"placeholder\";s:0:\"\";s:7:\"prepend\";s:0:\"\";s:6:\"append\";s:0:\"\";s:9:\"maxlength\";s:0:\"\";}', 'Another Field', 'another_field', 'publish', 'closed', 'closed', '', 'field_598085c218aa4', '', '', '2017-08-01 10:44:51', '2017-08-01 13:44:51', '', 170, 'http://antman.local./oncodev/?post_type=acf-field&p=174', 1, 'acf-field', '', 0);
And they're displayed like this on the defined page:
As they are saved like this on postmeta database:
INSERT INTO `wp_postmeta` (`meta_id`, `post_id`, `meta_key`, `meta_value`)
VALUES
(616, 28, 'test_field', 'field'),
(617, 28, '_test_field', 'field_598082bfc690f'),
(618, 28, 'another_field', 'another field'),
(619, 28, '_another_field', 'field_598085c218aa4');
they're easily handled by versionpress, I think.
If I understood correctly, a schema.yml for versionpress to associate the field definition with the correct post should be like this:
post:
value-references:
meta_key@meta_value:
location[/\d+/][/\d+/]["value"]: post
For reference, the serialized value saved in database is: http://www.unserialize.com/s/7599cf98-9f32-77a9-6bd7-00005ff0482b
But in the following case (http://www.unserialize.com/s/25aa39ed-2de0-64a8-3a1e-0000775ece6c) the post type is not associated with a particular page, but with all the post objects of type post (the default wordpress post type).
So, the best way to handle these cases would be creating a function crafted for that, right? Like you suggest in your last paragraph.
What is your ACF version? I tried latest 4.4.11 and I have different database structure? You have post types acf-field-group
and acf-field
, but I can see only acf
and fields are handled as postmeta? I also did not notice any location
parameter in postmeta value, so I am not able to test it.
If you have some rule that particular page is equal to some specific ID, then there should be some kind of following code (for your database structure):
post:
references:
post_content["location"][/\d+/][/\d+/]["value"]: post
But handling serialized data in post_content
is not possible for now because VersionPress supports serialized data only for value references (for example postmeta), see related issue. VP should support basic serialized data (and also JSON) in basic references hopefully soon.
For my database structure, there is a postmeta rule
and it is much more easier:
postmeta:
value-references:
meta_key@meta_value:
rule["value"]: post
When you have only general rule post_type
= page
, it is not a problem for VP because there is no number in value field, that means no ID to replace and everything should work fine.
Special function would be helpfull for general ACF support to handle situations when we do not know if ID is related to post type, term, user, etc. When you know that all your rules will be related to post types (post, page, etc), you can end with post
without problem for now. But when some group is related to post type and another to category, then we have a problem, because we need to specify if value = 5
is ID of post type or category. I will try to prepare some example of similar function in coming days.
ACF, Pods and similar plugins are the most complex plugins for VersionPress support, many other plugins simply work or only small changes are needed, for example Contact Form 7, etc.
Humm, I'm using acf pro 5 (last update is 5.6.0).
https://www.advancedcustomfields.com/resources/whats-new-version-5/
Field Settings
ACF5 uses a new way to save field settings. Please don’t confuse this with field values (which are saved in the same way as before).
Previously, the field settings were saved in the wp_postmeta table. The lack of columns in this table made it impossible to relate child and parent fields and resulted in a less than ideal nested approach to saving data. This made many sub field related activities difficult and prevented functionality such as the new ‘drag / drop field between parents’.
Now, the field settings live in the wp_posts table as a post_type called acf-field. This allows for relationships, larger nested repeater fields, and faster database querying.
Please note that the tutorial for creating a field type has been updated with ACF5 compatibility. If you are a developer of a field type, please be sure to read the updated article as the changes should only take a few minutes to implement.
I can provide you a copy of my pro plugin if you wish to study it. Maybe we can talk to ACF Pro creator so that he provides the copy to you?
Right, mystery solved :-)
It would be helpfull, if you can inform plugin authors and get any testing licence. Maybe they will be interested in adding general support for VP also for other users. Otherwise we can test it if you send us source files (without official licence for updates). But currently it is not possible to reference IDs in serialized data in post_content
:-( I will try to raise priority for this issue.
I will contact ACF Pro support right now!
ACF Pro has support to a json storage in the theme.
https://www.advancedcustomfields.com/resources/local-json/
you create a folder acf-json inside your theme, and when your save the fields on the screen, it saves on the filesystem too (so, you can track it with git too).
Maybe it's less problematic try to find these files and parse them to build the relations?
An example of these files: https://gist.github.com/waltercruz/af8c40f0c273237a85ce069fec2c80c3
Sorry, but data references in files are not supported by VersionPress yet.
Hi there,
Sorry to reopen this issue but i'm testing versionpress in remote workflows too (It's been a long way from beginning). Now, I've managed to work with versionpress in dockerized wordpress with remotes worlfklows. But I have some issues like @waltercruz mentioned.
First of all, we have some custom fields meta_key / meta_values which specify media IDs (ACF plugin IMAGE field). I've tried to create a .versionpress fodler inside plugin root folder and put inside it some specific advanced-custom-fields custom configuration schema:
I put this inside my schema to tell versionpress that the value inside those fields references post (Attachment ids) like this:
postmeta: value-references: meta_key@meta_value: imagen_cuadrado_listado: post imagen_proyecto_destacado: post imagen_fondo_portada: post contenido_1_1_contenido_1_1_imagen: post contenido_1_2_contenido_1_2_imagen: post
The thing is that when I sync from devel in remote I don't get an assigned value to those fields. And I don't know if I'm doing something wrong.
THe other plugin I would like to work around on its versionpress configuration is Polylang. Maybe this plugins has a little tricky way of defining its references, but for me and our projects it's compulsory to get it to work. Polylang it doesn't work outside wordpress scheme. It does two things, assign a post to its language (the language is managed by term creation). And in the other hand we have the references of a given post with its translations. The thing is that this references posts translations over serialized value in postmeta like this:
'45', '45', 'term_translations', 'a:2:{s:2:\"en\";i:26;s:2:\"es\";i:14;}', '0', '1' '49', '49', 'post_translations', 'a:2:{s:2:\"es\";i:269;s:2:\"en\";i:264;}', '0', '2'
And I have no clue about how the hell configure schemas for this. Actually, I didn't get to work the simplest configuration (ACF attachment ID value fields) so I'm guessing I'm doing something wrong, so that I'm asking for advice.
¿Could someone of you guys guide me over this configuration? I'm a little bit lost. It's been weeks working on remote configuration over Docker and we don't want to send all the work to the trash now we are so close to get it working.
Thanks in advance !!
Well, I realize that my .versionpress configuration filder was wrong situated.
I re-locate the folder in its correct position as @borekb told me: WP_CONTENT_DIR/.versionpress/plugins/
With ACF I'm having some problems:
After adding meta_key_meta_value post references in the schema.yml for Advanced Custom Fields, I'm having an Error in the wp vp apply-changes command:
Success: Maintenance mode turned on
Error You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')' at line 1 de la base de datos de WordPress para la consulta SELECT `` FROM wp_postmeta WHERE NOT () realizada por include('phar:///bin/wp-cli.phar/php/boot-phar.php'), include('phar:///bin/wp-cli.phar/php/wp-cli.php'), WP_CLI\bootstrap, WP_CLI\Bootstrap\LaunchRunner->process, WP_CLI\Runner->start, WP_CLI\Runner->_run_command_and_exit, WP_CLI\Runner->run_command, WP_CLI\Dispatcher\Subcommand->invoke, call_user_func, WP_CLI\Dispatcher\CommandFactory::WP_CLI\Dispatcher\{closure}, call_user_func, VersionPress\Cli\VPCommand->applyChanges, VersionPress\Synchronizers\SynchronizationProcess->synchronizeAll, VersionPress\Synchronizers\SynchronizationProcess->runSynchronizationTasks, VersionPress\Synchronizers\Synchronizer->synchronize, VersionPress\Synchronizers\Synchronizer->updateDatabase, VersionPress\Synchronizers\Synchronizer->deleteEntitiesWhichAreNotInStorage, VersionPress\Database\Database->__call, call_user_func_array
Success: Database updated
Success: Maintenance mode turned off
Success: All done
Attatchment id's still not machin between enviroments and no versionpress mapping happenned. No attachment id assigned on remote.
Hi @juanitopons,
yes, custom schema.yml
file should be located in wp-content/.versionpress/plugins/advanced-custom-fields
directory.
Could you please share your current schema.yml
file for ACF? I will try to reproduce your issue. What is your workflow? You have main site, created staging, changed staging (or main) and then running wp vp pull
to sync changes?
Support for Polylang should not be too hard, I am testing it now. You can try to create schema.yml
in wp-content/.versionpress/plugins/polylang
with following content:
term_taxonomy:
value-references:
taxonomy@description:
post_translations[/\w+/]: post
term_translations[/\w+/]: term
Hi @pavelevap I was expecting your answer. Thanks. I have preproduction site (remote one, git repository sharing changes with versionpress) dockerized. Then we have a local repository (each developer) who is binded with this remote one.
Local repositories are "devel" enviroment for versionpress. Remote one is "preproduction" enviroment. Changes are registered well, I c an see different colors and automatic commit done by versionpress.
I do changes in local and then sync repositories (push) with remote. In the remote side, I pull the changes and the run wp vp apply-changes inside docker machine. No problem with that, we have got the data almost correctly synced.
I was following this schema with ACF:
postmeta:
value-references:
meta_key@meta_value:
imagen_cuadrado_listado: post
Lets say "imagen_cuadrado_listado" is the name of my IMAGE ACF field for a given post, which it has a post (attachment) ID binded. I'ven working with that aproximation, but I was unable to correctly run the "wp vp apply-changes" command. As I told you, once I introduce this configuration file to versionpress, I get SQL SINTAX errors in the syncing process.
Success: Maintenance mode turned on Error You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')' at line 1 de la base de datos de WordPress para la consulta SELECT `` FROM wp_postmeta WHERE NOT () realizada por include('phar:///bin/wp-cli.phar/php/boot-phar.php'), include('phar:///bin/wp-cli.phar/php/wp-cli.php'), WP_CLI\bootstrap, WP_CLI\Bootstrap\LaunchRunner->process, WP_CLI\Runner->start, WP_CLI\Runner->_run_command_and_exit, WP_CLI\Runner->run_command, WP_CLI\Dispatcher\Subcommand->invoke, call_user_func, WP_CLI\Dispatcher\CommandFactory::WP_CLI\Dispatcher{closure}, call_user_func, VersionPress\Cli\VPCommand->applyChanges, VersionPress\Synchronizers\SynchronizationProcess->synchronizeAll, VersionPress\Synchronizers\SynchronizationProcess->runSynchronizationTasks, VersionPress\Synchronizers\Synchronizer->synchronize, VersionPress\Synchronizers\Synchronizer->updateDatabase, VersionPress\Synchronizers\Synchronizer->deleteEntitiesWhichAreNotInStorage, VersionPress\Database\Database->__call, call_user_func_array Success: Database updated Success: Maintenance mode turned off Success: All done
I also tried with almost the same configuration for polylang:
term_taxonomy:
value-references:
taxonomy@description:
post_translations[/\d+/]: post
term_translations[/\d+/]: term
Getting also other SQL sintax errors:
Success: Maintenance mode turned on Error Unknown column '' in 'field list' de la base de datos de WordPress para la consulta SELECT
FROM `wp_term_taxonomy` WHERE
= 'DA86553F28F84B69AEC2AD887C1F9C64' realizada por include('phar:///bin/wp-cli.phar/php/boot-phar.php'), include('phar:///bin/wp-cli.phar/php/wp-cli.php'), WP_CLI\bootstrap, WP_CLI\Bootstrap\LaunchRunner->process, WP_CLI\Runner->start, WP_CLI\Runner->_run_command_and_exit, WP_CLI\Runner->run_command, WP_CLI\Dispatcher\Subcommand->invoke, call_user_func, WP_CLI\Dispatcher\CommandFactory::WP_CLI\Dispatcher{closure}, call_user_func, VersionPress\Cli\VPCommand->applyChanges, VersionPress\Synchronizers\SynchronizationProcess->synchronizeAll, VersionPress\Synchronizers\SynchronizationProcess->runSynchronizationTasks, VersionPress\Synchronizers\Synchronizer->synchronize, VersionPress\Synchronizers\Synchronizer->updateDatabase, VersionPress\Synchronizers\Synchronizer->addOrUpdateEntities, VersionPress\Synchronizers\Synchronizer->existsInDatabase, VersionPress\Database\Database->call, call_user_func_array Error Unknown column '' in 'field list' de la base de datos de WordPress para la consulta INSERT INTO wp_term_taxonomy (taxonomy
,description
,) VALUES ("nav_menu", "", "DA86553F28F84B69AEC2AD887C1F9C64" ); realizada por include('phar:///bin/wp-cli.phar/php/boot-phar.php'), include('phar:///bin/wp-cli.phar/php/wp-cli.php'), WP_CLI\bootstrap, WP_CLI\Bootstrap\LaunchRunner->process, WP_CLI\Runner->start, WP_CLI\Runner->_run_command_and_exit, WP_CLI\Runner->run_command, WP_CLI\Dispatcher\Subcommand->invoke, call_user_func, WP_CLI\Dispatcher\CommandFactory::WP_CLI\Dispatcher\{closure}, call_user_func, VersionPress\Cli\VPCommand->applyChanges, VersionPress\Synchronizers\SynchronizationProcess->synchronizeAll, VersionPress\Synchronizers\SynchronizationProcess->runSynchronizationTasks, VersionPress\Synchronizers\Synchronizer->synchronize, VersionPress\Synchronizers\Synchronizer->updateDatabase, VersionPress\Synchronizers\Synchronizer->addOrUpdateEntities, VersionPress\Synchronizers\Synchronizer->createEntityInDatabase, VersionPress\Database\Database->query Error You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ') AND
NOT IN ("Array")' at line 1 de la base de datos de WordPress para la consulta SELECTFROM wp_term_taxonomy WHERE NOT () AND
NOT IN ("Array") realizada por include('phar:///bin/wp-cli.phar/php/boot-phar.php'), include('phar:///bin/wp-cli.phar/php/wp-cli.php'), WP_CLI\bootstrap, WP_CLI\Bootstrap\LaunchRunner->process, WP_CLI\Runner->start, WP_CLI\Runner->_run_command_and_exit, WP_CLI\Runner->run_command, WP_CLI\Dispatcher\Subcommand->invoke, call_user_func, WP_CLI\Dispatcher\CommandFactory::WP_CLI\Dispatcher{closure}, call_user_func, VersionPress\Cli\VPCommand->applyChanges, VersionPress\Synchronizers\SynchronizationProcess->synchronizeAll, VersionPress\Synchronizers\SynchronizationProcess->runSynchronizationTasks, VersionPress\Synchronizers\Synchronizer->synchronize, VersionPress\Synchronizers\Synchronizer->updateDatabase, VersionPress\Synchronizers\Synchronizer->deleteEntitiesWhichAreNotInStorage, VersionPress\Database\Database->call, call_user_func_array
We usually also do some changes in preproduction, and try to sync from preproduction to devel. It works well, the problem is the IDs of the attachments and the polylang post IDs.
The references are not being understanding by versionpress. I found different post binded to a given translation (even attachment were considered as post translations). And I guess it's because versionpress, literally, is not mapping these IDS between enviroments.
Hi @pavelevap I've tried your configuration for Polylang:
term_taxonomy:
value-references:
taxonomy@description:
post_translations[/\w+/]: post
term_translations[/\w+/]: term
Now I don't have any error when I apply de "apply-changes", but the translation post references is removed from the pages and posts.
In devel enviroment:
But when I sync I get the commits, but no references is binded:
This way is how Polylang references pages, when you select the page which is the translated page of a given one, imagine (actually you don't have to imagine nothing because it's how I have it in my wordpress) a "Contact" page with ID 244 and its translation "Contacto" with ID 239 (in this case, the ids are equal in both enviroments). Polylang builds this in the database:
SELECT * FROM wp_docker.wp_term_taxonomy AS tx
JOIN wp_docker.wp_term_relationships AS tr
ON tx.term_taxonomy_id = tr.term_taxonomy_id
JOIN wp_docker.wp_terms AS t
ON t.term_id = tx.term_id
WHERE object_id = 239 OR object_id = 244;
term_taxonomy_id,term_id,taxonomy,description,parent,count,object_id,term_taxonomy_id,term_order,term_id,name,slug,term_group
4,3,language,"a:3:{s:6:""locale"";s:5:""es_ES"";s:3:""rtl"";i:0;s:9:""flag_code"";s:2:""es"";}",0,5,239,4,0,3,Español,es,1
50,50,post_translations,"a:2:{s:2:""en"";i:244;s:2:""es"";i:239;}",0,2,239,50,0,50,pll_5a2fac1a6b221,pll_5a2fac1a6b221,0
7,5,language,"a:3:{s:6:""locale"";s:5:""en_US"";s:3:""rtl"";i:0;s:9:""flag_code"";s:2:""us"";}",0,11,244,7,0,5,English,en,0
50,50,post_translations,"a:2:{s:2:""en"";i:244;s:2:""es"";i:239;}",0,2,244,50,0,50,pll_5a2fac1a6b221,pll_5a2fac1a6b221,0
Can you guide me in some way?
I have just one other question. I have an Options Page for my theme. In that page I have a select option as Page ID option reference. It is possible to build an schema.yml for a theme, isn't it? Like "plugins" folder in .versionpress but with "theme" --> "theme-name-folder" -> schema.yml, right?
I put here the ini data in vpdb versionpress folder as kind of guidance:
term_taxonomy: [403AB83FB424401CB31922558237AA0A]
[403AB83FB424401CB31922558237AA0A]
taxonomy = "post_translations"
description = <<<serialized>>> <array>
description["en"] = "1FC323E819EC4A2182B0B9F903CC6690"
description["es"] = "3BB93F23BACD4F739BAD4CBB16519F81"
vp_parent = 0
vp_term_id = "6EE0864EAB504800B469FC63F66086C5"
vp_post[0] = "1FC323E819EC4A2182B0B9F903CC6690"
vp_post[1] = "3BB93F23BACD4F739BAD4CBB16519F81"
vp_term_id: [6EE0864EAB504800B469FC63F66086C5]
[6EE0864EAB504800B469FC63F66086C5]
name = "pll_5a2fac1a6b221"
slug = "pll_5a2fac1a6b221"
term_group = "0"
vp_post[0]: [1FC323E819EC4A2182B0B9F903CC6690]
[1FC323E819EC4A2182B0B9F903CC6690]
post_date = "2017-10-24 00:00:00"
post_date_gmt = "2017-10-23 22:00:00"
post_content = ""
post_title = "Contact"
post_excerpt = ""
post_status = "publish"
comment_status = "closed"
ping_status = "closed"
post_password = ""
post_name = "contact"
to_ping = ""
pinged = ""
post_modified = "2017-12-12 11:14:50"
post_modified_gmt = "2017-12-12 10:14:50"
post_content_filtered = ""
guid = "http://C7DC4BE3-7A50-413C-A76C-44A7A9B9C801"
menu_order = "0"
post_type = "page"
post_mime_type = ""
vp_post_author = "507055218F8144E28A5DC1F5E6B0DCC1"
vp_post_parent = 0
_wp_page_template#A9EFDF11DDF04B619548A3E9EBDFD4B5 = "default"
_yoast_wpseo_content_score#0A462CDF086D4259AC8DA01CC3ABC718 = "30"
vp_term_taxonomy[0] = "91AEF2A0D94B4E3E94CF678457E991C3"
vp_term_taxonomy[1] = "8A8CA1F404194929A2764C3D9F8568DA"
vp_post[1]: [3BB93F23BACD4F739BAD4CBB16519F81]
[3BB93F23BACD4F739BAD4CBB16519F81]
post_date = "2017-10-24 00:00:00"
post_date_gmt = "2017-10-23 22:00:00"
post_content = ""
post_title = "Contacto"
post_excerpt = ""
post_status = "publish"
comment_status = "closed"
ping_status = "closed"
post_password = ""
post_name = "contacto"
to_ping = ""
pinged = ""
post_modified = "2017-12-12 10:16:44"
post_modified_gmt = "2017-12-12 09:16:44"
post_content_filtered = ""
guid = "http://AA6DFA6C-C7AB-4617-8147-1F3E94093F43"
menu_order = "0"
post_type = "page"
post_mime_type = ""
vp_post_author = "507055218F8144E28A5DC1F5E6B0DCC1"
vp_post_parent = 0
_wp_page_template#81975637AF21467190B7D3B96E61607F = "default"
vp_term_taxonomy[0] = "F244E6C504D146518F048B37B93FEAB9"
vp_term_taxonomy[1] = "8A8CA1F404194929A2764C3D9F8568DA"
vp_term_taxonomy[0] = [F244E6C504D146518F048B37B93FEAB9] (this seems to be the own post language)
[F244E6C504D146518F048B37B93FEAB9]
taxonomy = "language"
description = <<<serialized>>> <array>
description["locale"] = "es_ES"
description["rtl"] = "0"
description["flag_code"] = "es"
vp_parent = 0
vp_term_id = "FF285453AA5D47A7B4479A693F2935D5"
vp_post[0] = "D24A247C1B7347B1B6F2691E032FFE79"
vp_term_id: [FF285453AA5D47A7B4479A693F2935D5] (this seems to work well I think)
[FF285453AA5D47A7B4479A693F2935D5]
name = "Español"
slug = "es"
term_group = "1"
vp_term_taxonomy[1]: [8A8CA1F404194929A2764C3D9F8568DA] (maybe here we have a problem)
[8A8CA1F404194929A2764C3D9F8568DA]
taxonomy = "post_translations"
description = <<<serialized>>> <array>
description["en"] = "2237036D026A49DA858F4FE62978A2DC"
description["es"] = "266"
vp_parent = 0
vp_term_id = "15C72BF58C3244659C7446A4F80285B1"
vp_term_id: [15C72BF58C3244659C7446A4F80285B1]
[15C72BF58C3244659C7446A4F80285B1]
name = "pll_5a29176377c3e"
slug = "pll_5a29176377c3e"
term_group = "0"
Do you get something in clear? I don't actually understand why versionpress is creating the term. It's supposed that the language term is already created, I think.
/**
* Used to create a translations groups in mass
*
* @since 1.6.3
*
* @param string $type either 'post' or 'term'
* @param array $translations array of translations arrays
*/
public function set_translation_in_mass( $type, $translations ) {
global $wpdb;
$taxonomy = $type . '_translations';
foreach ( $translations as $t ) {
$term = uniqid( 'pll_' ); // the term name
$terms[] = $wpdb->prepare( '( %s, %s )', $term, $term );
$slugs[] = $wpdb->prepare( '%s', $term );
$description[ $term ] = serialize( $t );
$count[ $term ] = count( $t );
}
// Insert terms
if ( ! empty( $terms ) ) {
$terms = array_unique( $terms );
$wpdb->query( "INSERT INTO $wpdb->terms ( slug, name ) VALUES " . implode( ',', $terms ) );
}
// Get all terms with their term_id
$terms = $wpdb->get_results( "SELECT term_id, slug FROM $wpdb->terms WHERE slug IN ( " . implode( ',', $slugs ) . ' )' );
// Prepare terms taxonomy relationship
foreach ( $terms as $term ) {
$term_ids[] = $term->term_id;
$tts[] = $wpdb->prepare( '( %d, %s, %s, %d )', $term->term_id, $taxonomy, $description[ $term->slug ], $count[ $term->slug ] );
}
// Insert term_taxonomy
if ( ! empty( $tts ) ) {
$tts = array_unique( $tts );
$wpdb->query( "INSERT INTO $wpdb->term_taxonomy ( term_id, taxonomy, description, count ) VALUES " . implode( ',', $tts ) );
}
// Get all terms with term_taxonomy_id
$terms = get_terms( $taxonomy, array( 'hide_empty' => false ) );
// Prepare objects relationships
foreach ( $terms as $term ) {
$t = unserialize( $term->description );
if ( in_array( $t, $translations ) ) {
foreach ( $t as $object_id ) {
if ( ! empty( $object_id ) ) {
$trs[] = $wpdb->prepare( '( %d, %d )', $object_id, $term->term_taxonomy_id );
}
}
}
}
// Insert term_relationships
if ( ! empty( $trs ) ) {
$wpdb->query( "INSERT INTO $wpdb->term_relationships ( object_id, term_taxonomy_id ) VALUES " . implode( ',', $trs ) );
$trs = array_unique( $trs );
}
clean_term_cache( $term_ids, $taxonomy );
}
@pavelevap I found that in Polylang the section "string tanslations" are also serielized over "postmeta" table, like so:
Array
(
[0] => Array
(
[0] => »
[1] => »
)
[1] => Array
(
[0] => Home
[1] => Inicio
)
[2] => Array
(
[0] => Archives for
[1] => Archivos para
)
[3] => Array
(
[0] => You searched for
[1] => You searched for
)
)
The first index of the deepest arrays is the default language string, the next are the translations. Those postmeta serielized data are binded to some "magic" polylang_mo post type, as far as I can see in the database:
ID, post_title, post_name, post_type
'33', 'polylang_mo_5', 'polylang_mo_5', 'polylang_mo'
As far as I could undestand, the NUMBER after the "polylangmo" references the language term. But there are two terms for every language, and I have two rows (two polylang post type posts), just for the default language (english):
wp_terms:
'2', 'English', 'pll_en', '0'
'5', 'English', 'en', '0'
Hey, for versionpress developers: maybe you can try the new free 5 early access, with different way of handle to database, to adapt the code:
https://www.advancedcustomfields.com/resources/upgrade-guide-version-5/
Hi. Me and a co-worker are trying to setup a Remote Workflow as described here (https://blog.versionpress.net/2016/11/remote-workflows/).
The first setup (using my wordpress as the 'source') worked well, but there's some issues, mainly regarding to ID, I guess.
It seems that our post IDs are different between machines (and image IDs too). By example:
http://imgur.com/a/NnQYR
img 231 and 106 are the same, 231 is the id on mu machine, 106 on his.
When he loaded the version press using the remote workflow described in the post, the attached image was 231, but he didn't had image 231 on his database. So, he edit the post and changed the image to correct image, 106 on his machine, but this time, I don't have a image 106 on my machine.
So... there's a way to force the same ID between machines?
Syncing acf fields will be a problem too (problem with IDs)
Please be specific when describing the issue. Also, these details will help:
You can get more details from your system info page: http://docs.versionpress.net/en/troubleshooting/system-info-page