Fix delete language and script notes field (#2392) - #2396
Open
melaniekung wants to merge 1 commit into
Open
Conversation
sevein
reviewed
Jul 23, 2026
Comment on lines
+83
to
+85
| if (0 == strlen($value)) { | ||
| if (0 == strlen($value) || (!$missingNote && is_countable($note))) { | ||
| // Delete note if it's available | ||
| if (!$missingNote && is_countable($note)) { | ||
| $note->delete(); | ||
| } | ||
| $note->delete(); |
Member
There was a problem hiding this comment.
I was testing this block from a new test file (test/phpunit/sfIsadPlugin/sfIsadPluginTest.php - feel free to use it!) and the last case listed in the table fails with this change, i.e. when the submitted value is empty and no note exists, $note contains the empty ArrayObject, so the call to the delete method produces:
Call to undefined method ArrayObject::delete()
Here's an alternative that passes in all four test cases. $note is consistently either a QubitNote or null, which I find a little easier to read:
case 'languageNotes':
$notes = $this->resource->getMemoryNotesByType(['noteTypeId' => QubitTerm::LANGUAGE_NOTE_ID]);
$note = $notes[0] ?? null;
// Clear the stored note when the field is empty; otherwise create the
// note if necessary and update its content.
if (0 === strlen($value)) {
if (null !== $note) {
$note->delete();
}
break;
}
if (null === $note) {
$note = new QubitNote();
$note->typeId = QubitTerm::LANGUAGE_NOTE_ID;
$note->userId = sfContext::getInstance()
->user
->getAttribute('user_id');
$this->resource->notes[] = $note;
}
$note->content = $value;
return $this;
melaniekung
force-pushed
the
dev/2392-fix-delete-lang-notes
branch
from
July 23, 2026 15:37
bdbabdb to
0d18b77
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.