Merge pull request #113 from th-h/thh-fixentryprop

Fix accidental deletion of extended properties.
This commit is contained in:
Thomas Hochstein 2020-04-18 22:41:20 +02:00 committed by GitHub
commit 8c11320820
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 3 deletions

View file

@ -1,3 +1,7 @@
0.15.6:
-------
* DELETE only properties that are submitted with an empty value.
0.15.4 & 0.15.5:
----------------
* Fix logic for INSERT/UPDATE/DELETE of properties.

View file

@ -25,7 +25,7 @@ class serendipity_event_metadesc extends serendipity_event {
$propbag->add('description', PLUGIN_METADESC_DESC);
$propbag->add('stackable', false);
$propbag->add('author', 'Garvin Hicking, Judebert, Don Chambers');
$propbag->add('version', '0.15.5');
$propbag->add('version', '0.15.6');
$propbag->add('requirements', array(
'serendipity' => '0.8',
'php' => '4.1.0'
@ -242,7 +242,7 @@ class serendipity_event_metadesc extends serendipity_event {
$q = "INSERT INTO {$serendipity['dbPrefix']}entryproperties (entryid, property, value) VALUES (" . (int)$eventData['id'] . ", '" . serendipity_db_escape_string($prop_key) . "', '" . serendipity_db_escape_string($prop_val) . "')";
} elseif ($property[$propkey] != $prop_val && !empty($prop_val)) {
$q = "UPDATE {$serendipity['dbPrefix']}entryproperties SET value = '" . serendipity_db_escape_string($prop_val) . "' WHERE entryid = " . (int)$eventData['id'] . " AND property = '" . serendipity_db_escape_string($prop_key) . "'";
} elseif (!empty($property[$prop_key]) && empty($prop_val)) {
} elseif (!empty($property[$prop_key]) && isset($prop_val) && empty($prop_val)) {
$q = "DELETE FROM {$serendipity['dbPrefix']}entryproperties WHERE entryid = " . (int)$eventData['id'] . " AND property = '" . serendipity_db_escape_string($prop_key) . "'";
} else {
// nothing to do

View file

@ -1,3 +1,6 @@
0.14.1
* Don't change entry image if entry_image is not set.
0.14
* Add per-entry social media image.

View file

@ -16,7 +16,7 @@ class serendipity_event_social extends serendipity_event {
$propbag->add('description', PLUGIN_EVENT_SOCIAL_DESC);
$propbag->add('stackable', false);
$propbag->add('author', 'onli, Matthias Mees, Thomas Hochstein');
$propbag->add('version', '0.14');
$propbag->add('version', '0.14.1');
$propbag->add('requirements', array(
'serendipity' => '2.0'
));
@ -267,6 +267,11 @@ class serendipity_event_social extends serendipity_event {
$entry_image = $serendipity['POST']['properties']['entry_image'];
// don't change anything if entry_image is not set
if (!isset($entry_image)) {
return true;
}
// delete old entry, if any
$q = "DELETE FROM {$serendipity['dbPrefix']}entryproperties WHERE entryid = " . (int)$eventData['id'] . " AND property = 'entry_image'";
serendipity_db_query($q);