Fix accidental deletion of extended properties.

Was mostly fixed by 8b51c37b98 (see ),
but which missed 03cc73d77e and the other
older code before the foreach() loop.
Later on, 7fe8d91bc2 did the check for
'propertyform' the wrong way around.

Cherry-picked from master branch.

1.41.4 has *not* been backported.

Signed-off-by: Thomas Hochstein <thh@inter.net>
This commit is contained in:
Thomas Hochstein 2020-04-18 22:33:20 +02:00
parent ef1279fbec
commit 62543dbd28
3 changed files with 21 additions and 7 deletions
docs
plugins/serendipity_event_entryproperties

@ -1,6 +1,10 @@
Version 2.3.5-beta1 ()
------------------------------------------------------------------------
* Fix: Don't delete extend properties from the entryproperties
plugin when publishing from dashboard (or sending
delayed trackbacks).
* Fix: SQL error in serendipity_plugin_history present since we
"don't allow requesting an archive page that doesn't exist"
(2.3.3).
@ -9,7 +13,7 @@ Version 2.3.5-beta1 ()
* Fix: Don't drop upgraded_version from local plugin cache.
* Fix: Regular expression in functions_routing.incx.php
* Fix: Regular expression in functions_routing.inc.php
* Fix: Truncate extension of media items to 5 chars (which ist the
max length of the corresponding database field).

@ -1,3 +1,9 @@
1.41.5:
-------
* Fix accidental deletion of extended properties.
[1.41.4 not backported]
1.41.3:
-------
* Add missing English language constant.
@ -9,4 +15,4 @@
1.37:
-----
* Added image preview to extended properties if value is image format (Don Chambers)
* Added image preview to extended properties if value is image format (Don Chambers)

@ -19,7 +19,7 @@ class serendipity_event_entryproperties extends serendipity_event
$propbag->add('description', PLUGIN_EVENT_ENTRYPROPERTIES_DESC);
$propbag->add('stackable', false);
$propbag->add('author', 'Garvin Hicking');
$propbag->add('version', '1.41.3');
$propbag->add('version', '1.41.5');
$propbag->add('requirements', array(
'serendipity' => '1.6',
'smarty' => '2.6.27',
@ -244,8 +244,12 @@ class serendipity_event_entryproperties extends serendipity_event
$property = serendipity_fetchEntryProperties($eventData['id']);
$supported_properties = serendipity_event_entryproperties::getSupportedProperties();
// serendipity_updertEntry may have been called from a plugin so $serendipity['POST']['properties']
// is not completely filled, so we_ always_ have to check that $serendipity['POST']['propertyform']
// is set (which will only happen if the form has been submitted) - not just in the foreach() below
// Cleanup properties first, if none disable_markups plugins were set, or a previous selected one was re-set
if (is_array($serendipity['POST']['properties']) && !is_array($serendipity['POST']['properties']['disable_markups'])) {
if (isset($serendipity['POST']['propertyform']) && is_array($serendipity['POST']['properties']) && !is_array($serendipity['POST']['properties']['disable_markups'])) {
$q = "DELETE FROM {$serendipity['dbPrefix']}entryproperties WHERE entryid = " . (int)$eventData['id'] . " AND property LIKE 'ep_disable_markup_%'";
serendipity_db_query($q);
}
@ -253,14 +257,14 @@ class serendipity_event_entryproperties extends serendipity_event
// Special case for input type checkbox entryproperties
$reset_properties = array('is_sticky', 'no_frontpage', 'hiderss');
foreach($reset_properties AS $property) {
if (!isset($serendipity['POST']['propertyform']) && is_array($serendipity['POST']['properties']) && !in_array($property, $serendipity['POST']['properties'])) {
if (isset($serendipity['POST']['propertyform']) && is_array($serendipity['POST']['properties']) && !in_array($property, $serendipity['POST']['properties'])) {
$q = "DELETE FROM {$serendipity['dbPrefix']}entryproperties WHERE entryid = " . (int)$eventData['id'] . " AND property = 'ep_{$property}'";
serendipity_db_query($q);
}
}
// Special case for disable markups.
if (is_array($properties['disable_markups'])) {
if (isset($serendipity['POST']['propertyform']) && is_array($properties['disable_markups'])) {
$q = "DELETE FROM {$serendipity['dbPrefix']}entryproperties WHERE entryid = " . (int)$eventData['id'] . " AND property LIKE 'ep_disable_markup_%'";
serendipity_db_query($q);
@ -1034,4 +1038,4 @@ class serendipity_event_entryproperties extends serendipity_event
}
/* vim: set sts=4 ts=4 expandtab : */
?>
?>