Minor correctness bugs: loadArticle null-cache, zero-date OG timestamps, batch JS premature halt #106
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Three small, independent correctness bugs
loadArticle()per-request cache never caches misses —plg_system_mokoog/src/Extension/MokoOG.php:669-692. A miss storesnullin$cache[$id], but the guard isisset($cache[$id])(false fornull), so a missing/unpublished article is re-queried on every call within the request. Usearray_key_exists()(or a sentinel) so negative lookups are cached.Zero-dates emitted as invalid OG timestamps —
getArticleDate()(~:220-221).publish_up/modifiedof0000-00-00 00:00:00are output verbatim asarticle:published_time/article:modified_time, producing invalid metadata. Skip/normalise zero dates.Batch JS stops on a fully-skipped chunk —
tmpl/tags/default.php:230. The loop continues onlyif (resp.data.created > 0 && processed < total). If an entire chunk inserts nothing (e.g. all unique-key conflicts →created = 0) while eligible articles remain, progress halts before 100%. Continue based onprocessed < total, notcreated > 0.Each is small; bundled for convenience but can be split.
Branch created:
feature/106-minor-correctness-bugs-loadarticle-null-Partially fixed in PR #109 (merged to
dev):loadArticle()now cachesnullmisses viaarray_key_exists()— no more per-call re-query.getArticleDate()skips0000-00-00dates (no more invalidarticle:published_time/modified_time).Still open — #3 (batch JS premature halt): investigating it revealed the guard is load-bearing.
BatchController::process()always queries from offset 0 and relies on theIS NULLjoin to exclude done rows; a row that fails to insert is never excluded, so it's re-fetched every chunk. The currentcreated > 0stop condition is what prevents an infinite loop on a persistently-failing row. A correct fix requires cursor-based pagination (e.g.WHERE c.id > :lastId) inBatchControllerso failed rows are skipped — leaving this open for that redesign.All three items now resolved. The batch-JS halt (#3) is fixed in PR #116 (merged to
dev):BatchController::process()paginates by id cursor (WHERE c.id > :lastId ORDER BY c.id), so a row that fails to insert falls behind the cursor and is never re-fetched — the batch is provably terminating and reaches 100% even with persistent failures. The JS drives the cursor and stops when a chunk examines 0 rows. (Items #1 loadArticle null-cache and #2 zero-date were fixed earlier in PR #109.) Closing.