setData Function for deleting article settings (sponsor, copyrightHolder) does not work

I try to delete existing article settings like sponsor or CopyrightHolder from table article_settings. However, this does not work:

$article->setData('sponsor',null, null);



Any idea, what’s the right way to delete such settings? I am using OJS

Hi @aguen,

Are you using the DAO to update the database record after setting the field? Also, there’s $article->setSponsor(), which is preferable to using setData.

Alec Smecher
Public Knowledge Project Team

1 Like

Hi Alec,

Thank you for your reply! I did not realize that setSponsor() or setData() does not actually execute the SQL but only configures/sets it. Now I see that $articleDao->updateSetting() is required to execute the update for individual settings or $articleDao->updateArticle() to execute all settings. Something like the code below did the job (= deleting all existing sponsors and inserting a new one).


$existingSponsors = $article->getSponsor(null);
if($existingSponsors) {
	foreach (array_keys($existingSponsors) as $locale) {
        $articleDao->updateSetting($article->getId(),'sponsor',array($locale=>null),'string',true );
$newSponsor = 'The new sponsor';
$locale = 'en_US';
$articleDao->updateSetting($article->getId(),'sponsor',array($locale=>$newSponsor),'string',true );
1 Like