@KK,
I could say that 99% of examples in the forum with db_persist tag involve condition on k_success / k_error variables.
If a third-party code sets a custom error on 'page_saved' event, it can be surprising that k_error would not have anything set in it.
My experience today -
I did not see any constraint on what we can set as $errors. I passed a string 'Readonly!', but could be anything, right? I am sure we can improve the situation. Stuffing 'k_error' with something should allow to trigger error handling in commonly-written code. By 'commonly-written' I mean code that does not use k_error_count or k_persist_error_count at all.
I could say that 99% of examples in the forum with db_persist tag involve condition on k_success / k_error variables.
If a third-party code sets a custom error on 'page_saved' event, it can be surprising that k_error would not have anything set in it.
- Code: Select all
(excerpt from data-bound-form.php)
// Save..
$errors = $pg->save( $node->name );
..
if( $errors ){
..
$str_err = '';
..
$CTX->set( 'k_success', '' );
$CTX->set( 'k_error', $str_err );
$CTX->set( 'k_error_count', $errors );
$CTX->set( 'k_persist_error', $str_err );
$CTX->set( 'k_persist_error_count', $errors );
// HOOK: db_xxx_savefailed
..
}
My experience today -
I did not see any constraint on what we can set as $errors. I passed a string 'Readonly!', but could be anything, right? I am sure we can improve the situation. Stuffing 'k_error' with something should allow to trigger error handling in commonly-written code. By 'commonly-written' I mean code that does not use k_error_count or k_persist_error_count at all.