Skip to content

Commit

Permalink
performance improvements:
Browse files Browse the repository at this point in the history
- don't delete object_text from cache. They will be removed
  automatically since Object_Text also uses trait Delete
- use function to retrieve the cache key
  • Loading branch information
christopheg committed Dec 2, 2024
1 parent ad96201 commit c266351
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions lib/Skeleton/Object/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,11 @@ public function delete() {
$object_texts = \Skeleton\I18n\Object\Text::get_by_object($this);
foreach ($object_texts as $object_text) {
$object_text->delete();

if (self::trait_cache_enabled()) {
$key = get_called_class() . '_' . $object_text->object_id . '_' . $object_text->label . '_' . $object_text->language->name_short;
self::cache_delete($key);
}
}
}

if (self::trait_cache_enabled()) {
self::cache_delete(get_called_class() . '_' . $this->id);
self::cache_delete(get_called_class()::trait_get_cache_key($this));
}

$db->query('DELETE FROM ' . $db->quote_identifier($table) . ' WHERE ' . self::trait_get_table_field_id() . '=?', [$this->id]);
Expand Down

0 comments on commit c266351

Please sign in to comment.