PluginProbe
Import WP – CSV & XML Import Export for WordPress / 2.15.0
Import WP – CSV & XML Import Export for WordPress v2.15.0
2.15.1 2.15.0 2.14.24 2.14.23 2.7.0 2.7.1 2.7.10 2.7.11 2.7.12 2.7.13 2.7.14 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 2.7.9 2.8.0 2.8.1 2.8.2 2.8.3 2.9.0 2.9.1 All 144 releases
← All changes | class/Common/Importer/Mapper/AbstractMapper.php +15 -2 2.14.24 → 2.15.0 View file →
@@ -67,9 +67,10 @@
67 67 $has_unique_field = true;
68 68 $key = $this->importer->get_iwp_reference_meta_key();
69 69
70 70 $value = $data->getValue($key, 'iwp');
71 - if (!$value) {
71 + // 0 / "0" are valid identifiers — only treat missing/blank as empty.
72 + if (!$this->has_identifier_value($value)) {
72 73 $value = '';
73 74 }
74 75
75 76 $meta_args[] = array(
@@ -119,8 +120,20 @@
119 120 {
120 121 return $this->unique_indentifier_data;
121 122 }
122 123
124 + /**
125 + * Whether a unique identifier value is present.
126 + * Note: 0 and "0" are valid identifiers (PHP empty()/falsy checks treat them as empty).
127 + *
128 + * @param mixed $value
129 + * @return bool
130 + */
131 + public function has_identifier_value($value)
132 + {
133 + return !(null === $value || false === $value || '' === $value);
134 + }
135 +
123 136 public function getUniqueIdentifiers($unique_fields = [])
124 137 {
125 138
126 139 // set via importer interface
@@ -148,9 +161,9 @@
148 161 public function find_unique_field_in_data($data, $field)
149 162 {
150 163 // TODO: this should only be done once per update
151 164 $unique_value = $data->getValue($field, '*');
152 - if (empty($unique_value)) {
165 + if (!$this->has_identifier_value($unique_value)) {
153 166 $cf = $data->getData('custom_fields');
154 167 if (!empty($cf)) {
155 168 $cf_index = intval($cf['custom_fields._index']);
156 169 if ($cf_index > 0) {