fix(tests): guard error_log/wp_json_encode stubs + document idempotency limitation
- tests/unit/test-migration-0004.php: wrap error_log() stub in function_exists() guard -- prevents PHP fatal redeclaration on PHP Lint (8.1/8.2/8.3) which runs php -l on all .php files. - tests/bootstrap.php: update wp_json_encode stub to accept int $flags = 0 second arg (matches production call signature wp_json_encode($clean, JSON_UNESCAPED_UNICODE)); guard with function_exists(). - class-pr-core-migration-0004-backfill-peptide-meta.php: add code comment near idempotency check documenting the all-or-nothing limitation (post with legitimately empty aliases will re-run). - CONVENTIONS.md: one-line note under migration conventions item 5 documenting the idempotency caveat. - CHANGELOG.md: add Fixed section under v0.6.0 for CI/test-stub fix. Agent-Session: peptide-schema-backfill v0.6.0 P1 fix
This commit is contained in:
@@ -93,6 +93,11 @@ class PR_Core_Migration_0004_Backfill_Peptide_Meta {
|
||||
$existing_weight = (string) get_post_meta( $post_id, self::META_WEIGHT, true );
|
||||
$existing_aliases = (string) get_post_meta( $post_id, self::META_ALIASES, true );
|
||||
|
||||
// Idempotency limitation: this guard is all-or-nothing. A peptide that legitimately
|
||||
// has no aliases (e.g., a novel compound) will never satisfy all three conditions and
|
||||
// the migration will re-run on every manual re-invoke. This is safe because
|
||||
// write_meta_from_psa() / write_meta_from_pubchem() only overwrite with non-empty
|
||||
// values, but callers should be aware the 'skipped' result requires all three keys set.
|
||||
if ( '' !== $existing_formula && '' !== $existing_weight && '' !== $existing_aliases ) {
|
||||
return 'skipped';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user