Commit b22ffba
Remove Associated Storage S3 Objects During Record Deletion (#2896)
* Add purge_post_storage_objects method to clean up S3 storage on post deletion
- Implemented a new private method to remove S3-backed storage objects associated with a post, including image fields in post meta, comment attachments, and user meta.
- Integrated this method into the delete_post function to ensure storage cleanup occurs during post deletion.
- Added checks for the availability of DT_Storage_API to prevent errors if the API is not enabled.
* Enhance error handling in S3 object deletion during post purging
- Updated the purge_post_storage_objects method to log failures when deleting S3 objects associated with posts, ensuring better tracking of issues during storage cleanup.
- Added checks for the result of DT_Storage_API::delete_file to log a message if the deletion fails, improving the robustness of the storage management process.
* add filter
* phpcs
* Refactor S3 object deletion handling in comment and post purging
- Enhanced the error handling for S3 object deletions in both the and comment processing methods, ensuring that failures are logged correctly.
- Introduced a filter for comment storage meta keys to streamline the deletion process for associated audio and image URLs.
- Improved code readability and maintainability by consolidating repeated logic for checking and deleting S3 objects.
* Refactor comment storage meta key retrieval and improve S3 object deletion logic
- Introduced a new method, get_comment_storage_meta_keys, to centralize the retrieval of comment meta keys backed by storage, enhancing code maintainability.
- Updated the purge_post_storage_objects method to utilize the new retrieval method, streamlining the process of deleting S3 objects associated with comments.
- Improved SQL query preparation for fetching comment storage keys, ensuring better performance and security.
* Refactor SQL query preparation for comment storage key retrieval
- Improved the SQL query construction for fetching comment storage keys by consolidating the query into a single prepared statement, enhancing performance and security.
- Added a PHPCS ignore comment to clarify the safety of the constructed placeholders.
* Update PHPCS comments for SQL query preparation in comment storage key retrieval
- Disabled PHPCS warning for interpolated SQL queries to clarify the safety of constructed placeholders.
- Re-enabled the warning after the SQL query preparation to maintain code quality standards.
---------
Co-authored-by: corsac <corsacca@gmail.com>1 parent cb42d59 commit b22ffba
2 files changed
Lines changed: 131 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1409 | 1409 | | |
1410 | 1410 | | |
1411 | 1411 | | |
1412 | | - | |
1413 | | - | |
1414 | | - | |
1415 | | - | |
1416 | | - | |
| 1412 | + | |
| 1413 | + | |
| 1414 | + | |
| 1415 | + | |
| 1416 | + | |
| 1417 | + | |
| 1418 | + | |
| 1419 | + | |
| 1420 | + | |
| 1421 | + | |
| 1422 | + | |
| 1423 | + | |
| 1424 | + | |
1417 | 1425 | | |
1418 | 1426 | | |
1419 | 1427 | | |
| |||
1536 | 1544 | | |
1537 | 1545 | | |
1538 | 1546 | | |
| 1547 | + | |
| 1548 | + | |
1539 | 1549 | | |
1540 | 1550 | | |
1541 | 1551 | | |
| |||
1563 | 1573 | | |
1564 | 1574 | | |
1565 | 1575 | | |
1566 | | - | |
| 1576 | + | |
1567 | 1577 | | |
1568 | 1578 | | |
1569 | 1579 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1472 | 1472 | | |
1473 | 1473 | | |
1474 | 1474 | | |
| 1475 | + | |
| 1476 | + | |
| 1477 | + | |
| 1478 | + | |
| 1479 | + | |
| 1480 | + | |
| 1481 | + | |
| 1482 | + | |
| 1483 | + | |
| 1484 | + | |
| 1485 | + | |
| 1486 | + | |
| 1487 | + | |
| 1488 | + | |
| 1489 | + | |
| 1490 | + | |
| 1491 | + | |
| 1492 | + | |
| 1493 | + | |
| 1494 | + | |
| 1495 | + | |
| 1496 | + | |
| 1497 | + | |
| 1498 | + | |
| 1499 | + | |
| 1500 | + | |
| 1501 | + | |
| 1502 | + | |
| 1503 | + | |
| 1504 | + | |
| 1505 | + | |
| 1506 | + | |
| 1507 | + | |
| 1508 | + | |
| 1509 | + | |
| 1510 | + | |
| 1511 | + | |
| 1512 | + | |
| 1513 | + | |
| 1514 | + | |
| 1515 | + | |
| 1516 | + | |
| 1517 | + | |
| 1518 | + | |
| 1519 | + | |
| 1520 | + | |
| 1521 | + | |
| 1522 | + | |
| 1523 | + | |
| 1524 | + | |
| 1525 | + | |
| 1526 | + | |
| 1527 | + | |
| 1528 | + | |
| 1529 | + | |
| 1530 | + | |
| 1531 | + | |
| 1532 | + | |
| 1533 | + | |
| 1534 | + | |
| 1535 | + | |
| 1536 | + | |
| 1537 | + | |
| 1538 | + | |
| 1539 | + | |
| 1540 | + | |
| 1541 | + | |
| 1542 | + | |
| 1543 | + | |
| 1544 | + | |
| 1545 | + | |
| 1546 | + | |
| 1547 | + | |
| 1548 | + | |
| 1549 | + | |
| 1550 | + | |
| 1551 | + | |
| 1552 | + | |
| 1553 | + | |
| 1554 | + | |
| 1555 | + | |
| 1556 | + | |
| 1557 | + | |
| 1558 | + | |
| 1559 | + | |
| 1560 | + | |
| 1561 | + | |
| 1562 | + | |
| 1563 | + | |
| 1564 | + | |
| 1565 | + | |
| 1566 | + | |
| 1567 | + | |
| 1568 | + | |
| 1569 | + | |
| 1570 | + | |
| 1571 | + | |
| 1572 | + | |
| 1573 | + | |
| 1574 | + | |
| 1575 | + | |
| 1576 | + | |
| 1577 | + | |
| 1578 | + | |
| 1579 | + | |
| 1580 | + | |
| 1581 | + | |
| 1582 | + | |
| 1583 | + | |
| 1584 | + | |
| 1585 | + | |
| 1586 | + | |
| 1587 | + | |
1475 | 1588 | | |
1476 | 1589 | | |
1477 | 1590 | | |
| |||
1481 | 1594 | | |
1482 | 1595 | | |
1483 | 1596 | | |
| 1597 | + | |
| 1598 | + | |
1484 | 1599 | | |
1485 | 1600 | | |
1486 | 1601 | | |
| |||
0 commit comments