User tests: Successful: Unsuccessful:
When you do something like:
$articleModel = new \Joomla\Component\Content\Administrator\Model\ArticleModel;
$articles = [
[
'id' => 0,
'title' => 'bla',
'alias' => 'bla'
'catid' => 1,
'ordering' => 1
],
[
'id' => 0,
'title' => 'foobar',
'alias' => 'foobar',
'catid' => 1,
'ordering' => 2
]
];
foreach ($articles as $article)
{
$articleModel->save($article);
var_dump($articleModel->getState($articleModel->getName() . '.new'));
}
You will get:
true
false
Because giving the save method directly the ID does create a new article but does not reset the internal ID state in the model. So e.g. plugins which rely on this $isNew
get the wrong information.
This happens e.g. heavily in the sample data plugin: https://github.com/joomla/joomla-cms/blob/4.0-dev/plugins/sampledata/blog/blog.php#L220-L298 So plugins which hear on "onContentAfterSave" could act the wrong way.
var_dump($articleModel->getState($articleModel->getName() . '.new'));
(Adding this test/debug code will break the installation of the sample datas, but that's ok, as we're testing a specific part and not the whole sample data)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
Status | New | ⇒ | Pending |
Category | ⇒ | Libraries |
Labels |
Added:
?
|
Title |
|
Category | Libraries | ⇒ | Libraries Front End Plugins |
After a talk with @richard67 we decided to update this PR, because the sample data (at least for the blog) uses a wrong approach in loading the model (e.g. no ignore_request parameter, no proper cleanup after each saving).
This is directly linked with this bug fix itself. So if we do it in two PR (which was the plan), we have a small moment of broken sample data.
I have tested this item
I have tested this item
Tested on fresh 4.0 dev following testinstructions.
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2020-05-30 17:11:08 |
Closed_By | ⇒ | bembelimen | |
Labels |
Added:
Information Required
|
@bembelimen Why did you close this?
I have tested this item✅ successfully on a980c17
Tested following instructions.
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/28899.