I'm using code I've been using to update existing entries for a while now and it's failing to fire following the 2.5 upgrade. Trying to figure out what might have changed, or if there's something I'm overlooking. I'm consistently getting the "not saved" response and seeing no update in the entry. showInInvestmentAdvisersReference
is the new field I'm setting. I've got limit=1
set for testing purposes.
$entries = craft()->elements->getCriteria(ElementType::Entry);
$entries->section = 'referenceMaterials';
$entries->limit = 1;
$existingEntries = $entries->find();
foreach ($existingEntries as $existingEntry) {
echo 'id: ' . $existingEntry->id . '<br />';
$entryToSave = new EntryModel();
$entryToSave = $existingEntry;
// Setting these in case they're required to be set for saveEntry()
$entryToSave->sectionId = 9;
$entryToSave->typeId = 9;
$entryToSave->authorId = 1;
$entryToSave->enabled = true;
$entryToSave->getContent()->title = $existingEntry->title;
$entryToSave->getContent()->showInInvestmentAdvisersReference = 1;
if ( craft()->entries->saveEntry($entryToSave) )
{
echo 'saved<br />';
}
else {
echo 'not saved<br />';
}
}
Is it me? Did something change? Happy to file a bug report but thought I'd start here first where code formatting is supported.