MOON
Server: Apache
System: Linux res.emeff.ca 3.10.0-962.3.2.lve1.5.24.10.el7.x86_64 #1 SMP Wed Mar 20 07:36:02 EDT 2019 x86_64
User: accemeff (1004)
PHP: 7.0.33
Disabled: NONE
Upload Files
File: /home/accemeff/vendor/craftcms/cms/src/migrations/m180124_230459_fix_propagate_entries_values.php
<?php

namespace craft\migrations;

use Craft;
use craft\db\Migration;
use craft\db\Query;
use craft\db\Table;

/**
 * m180124_230459_fix_propagate_entries_values migration.
 */
class m180124_230459_fix_propagate_entries_values extends Migration
{
    /**
     * @inheritdoc
     */
    public function safeUp()
    {
        // Any sections with incorrect propagateEntries values?
        $sectionIds = (new Query())
            ->select(['id'])
            ->from([Table::SECTIONS])
            ->where(['type' => ['single', 'structure'], 'propagateEntries' => false])
            ->column();

        if (!empty($sectionIds)) {
            $sectionsService = Craft::$app->getSections();

            foreach ($sectionIds as $sectionId) {
                $section = $sectionsService->getSectionById($sectionId);
                $sectionsService->saveSection($section, false);
            }
        }
    }

    /**
     * @inheritdoc
     */
    public function safeDown()
    {
        echo "m180124_230459_fix_propagate_entries_values cannot be reverted.\n";
        return false;
    }
}