Removes module versions

@param string $sModuleId Module id
426294
protected function _deleteModuleVersions($sModuleId)
    {
        $aVersions = (array) \OxidEsales\Eshop\Core\Registry::getConfig()->getConfigParam('aModuleVersions');
        unset($aVersions[$sModuleId]);

        $this->_saveToConfig('aModuleVersions', $aVersions);
    }
926718
protected static function _deactivateOldModule()
    {
        $sModule = self::OLD_MODULE_ID;

        /**
         * @var oxModule $oModule
         */
        $oModule = self::_getModule();

        if ($oModule->load($sModule) === false) {
            self::_getUtilsView()->addErrorToDisplay(new oxException('EXCEPTION_MODULE_NOT_LOADED'));
            return false;
        }

        try {
            $oModuleCache = self::_getModuleCache($oModule);
            $oModuleInstaller = self::_getModuleInstaller($oModuleCache);
            return $oModuleInstaller->deactivate($oModule);
        } catch (oxException $oEx) {
            self::_getUtilsView()->addErrorToDisplay($oEx);

            if (method_exists($oEx, 'debugOut')) {
                $oEx->debugOut();
            }
        }

        return false;
    }
660702
protected function _deleteModuleEvents($sModuleId)
    {
        $aEvents = (array) \OxidEsales\Eshop\Core\Registry::getConfig()->getConfigParam('aModuleEvents');
        unset($aEvents[$sModuleId]);

        $this->_saveToConfig('aModuleEvents', $aEvents);
    }
843825
public function deleteVersionById(string $modelId, string $versionId)
    {
        $deleteResult = $this->getRequest()->request(
            'DELETE',
            $this->getRequestUrl(sprintf('models/%s/versions/%s', $modelId, $versionId))
        );

        return $deleteResult['status'];
    }
176598
public function deleteFields($contentId, VersionInfo $versionInfo)
    {
        foreach ($this->contentGateway->getFieldIdsByType($contentId, $versionInfo->versionNo) as $fieldType => $ids) {
            $this->storageHandler->deleteFieldData($fieldType, $versionInfo, $ids);
        }
        $this->contentGateway->deleteFields($contentId, $versionInfo->versionNo);
    }
441422
public function isModuleActive($sModuleId, $sVersionFrom = null, $sVersionTo = null)
    {
        $blModuleIsActive = false;

        // use aModuleVersions instead of aModules, because aModules gives only modules which extend oxid classes
        $aModuleVersions = $this->getConfig()->getConfigParam('aModuleVersions');

        if (is_array($aModuleVersions)) {
            $blModuleIsActive = $this->_moduleExists($sModuleId, $aModuleVersions);

            if ($blModuleIsActive) {
                $blModuleIsActive = $this->_isModuleEnabled($sModuleId) && $this->_isModuleVersionCorrect($sModuleId, $sVersionFrom, $sVersionTo);
            }
        }

        return $blModuleIsActive;
    }
1201801
public function removeScriptVersion($src)
    {
        $siteUrlComponents = parse_url(get_site_url());
        $urlComponents = parse_url($src);
        // Check if the URL is internal or external
        if (!empty($siteUrlComponents['host'])
            && !empty($urlComponents['host'])
            && strcasecmp($urlComponents['host'], $siteUrlComponents['host']) === 0
            && !is_admin_bar_showing()) {
            $src = !empty($urlComponents['query']) ? str_replace('?' . $urlComponents['query'], '', $src) : $src;
            return $src;
        } else {
            return $src;
        }
    }
224348
public void unloadModule(ModuleIdentifier revisionId) {
        Objects.requireNonNull(revisionId, "revisionId");
        Module module = findLoadedModule(revisionId);
        if (module != null) {
            unloadModule(module);
        }
    }
90864
protected function _addModuleVersion($sModuleVersion, $sModuleId)
    {
        $aVersions = (array) $this->getConfig()->getConfigParam('aModuleVersions');
        $old =  isset($aVersions[$sModuleId]) ? $aVersions[$sModuleId] : '';
        if (is_array($aVersions)) {
            $aVersions[$sModuleId] = $sModuleVersion;
            if ($old !== $sModuleVersion) {
                $this->output->writeLn("$sModuleId fixing module version from $old to $sModuleVersion");
                $aEvents[$sModuleId] = $sModuleVersion;
                $this->_saveToConfig('aModuleVersions', $aVersions);
                $this->needCacheClear = true;
            }
        } else {
            if ($old) {
                $this->output->writeLn("$sModuleId unregister module version");
                $this->_deleteModuleVersions($sModuleId);
                $this->needCacheClear = true;
            }
        }

    }
884488
protected function _addModuleVersion($sModuleVersion, $sModuleId)
    {
        $aVersions = (array) \OxidEsales\Eshop\Core\Registry::getConfig()->getConfigParam('aModuleVersions');
        if (is_array($aVersions)) {
            $aVersions[$sModuleId] = $sModuleVersion;
        }

        $this->_saveToConfig('aModuleVersions', $aVersions);
    }
999661
public static function pruneByID($RecordID)
    {
        $keep_versions = Config::inst()->get(VersionTruncator::class, 'keep_versions');
        $keep_drafts = Config::inst()->get(VersionTruncator::class, 'keep_drafts');
        $keep_redirects = Config::inst()->get(VersionTruncator::class, 'keep_redirects');
        $keep_old_page_types = Config::inst()->get(VersionTruncator::class, 'keep_old_page_types');

        $query = new SQLSelect();
        $query->setFrom('SiteTree_Versions');
        $query->addWhere('RecordID = ' . $RecordID);
        $query->setOrderBy('LastEdited DESC');

        $result = $query->execute();

        $publishedCount = 0;
        $draftCount = 0;
        $seen_url_segments = [];
        $versionsToDelete = [];

        foreach ($result as $row) {
            $ID = $row['ID'];
            $RecordID = $row['RecordID'];
            $ClassName = $row['ClassName'];
            $Version = $row['Version'];
            $WasPublished = $row['WasPublished'];
            $URLSegment = $row['ParentID'] . $row['URLSegment'];

            $live_version = SiteTree::get()->byID($row['RecordID']);

            if ( // automatically delete versions of old page types
                !$keep_old_page_types &&
                $live_version &&
                $live_version->ClassName != $ClassName
            ) {
                array_push($versionsToDelete, [
                    'RecordID'  => $RecordID,
                    'Version'   => $Version,
                    'ClassName' => $ClassName,
                ]);
            } elseif (!$WasPublished && $keep_drafts) { // draft
                $draftCount++;
                if ($draftCount > $keep_drafts) {
                    array_push($versionsToDelete, [
                        'RecordID'  => $RecordID,
                        'Version'   => $Version,
                        'ClassName' => $ClassName,
                    ]);
                }
            } elseif ($keep_versions) { // published
                $publishedCount++;
                if ($publishedCount > $keep_versions) {
                    if (!$keep_redirects || in_array($URLSegment, $seen_url_segments)) {
                        array_push($versionsToDelete, [
                            'RecordID'  => $RecordID,
                            'Version'   => $Version,
                            'ClassName' => $ClassName,
                        ]);
                    }
                }
                // add page to "seen URLs" if $preserve_redirects
                if ($keep_redirects && !in_array($URLSegment, $seen_url_segments)) {
                    array_push($seen_url_segments, $URLSegment);
                }
            }
        }

        $affected_rows = 0;

        if (count($versionsToDelete) > 0) {
            $table_list = DB::table_list();
            $affected_tables = [];
            $doschema = new DataObjectSchema();
            foreach ($versionsToDelete as $d) {
                $subclasses = ClassInfo::dataClassesFor($d['ClassName']);
                foreach ($subclasses as $subclass) {
                    $table_name = strtolower($doschema->tableName($subclass));
                    if (!empty($table_list[$table_name . '_versions'])) {
                        DB::query('DELETE FROM "' . $table_list[$table_name . '_versions'] . '" WHERE
							"RecordID" = ' . $d['RecordID'] . ' AND "Version" = ' . $d['Version']);
                        $affected_rows = $affected_rows + DB::affected_rows();
                    }
                }
            }
        }

        return $affected_rows;
    }
1296711
public function invalidateModuleCache(string $moduleId)
    {
        /**
         * @TODO we have to implement it in ShopModuleCacheService or use ModuleCache::resetCache() method.
         */
        $module = oxNew(Module::class);

        $templates = $module->getTemplates($moduleId);
        $utils = Registry::getUtils();
        $utils->resetTemplateCache($templates);
        $utils->resetLanguageCache();
        $utils->resetMenuCache();

        ModuleVariablesLocator::resetModuleVariables();

        if (extension_loaded('apc') && ini_get('apc.enabled')) {
            apc_clear_cache();
        }
    }
810065
protected function suppressDeletedVersion($callback)
    {
        $original = $this->getDeleteWritesVersion();
        try {
            $this->setDeleteWritesVersion(false);
            return $callback();
        } finally {
            $this->setDeleteWritesVersion($original);
        }
    }
551377
function removeExcludedModules(modules, packageForceExcludes, log) {
  const excludedModules = _.remove(modules, externalModule => {   // eslint-disable-line lodash/prefer-immutable-method
    const splitModule = _.split(externalModule, '@');
    // If we have a scoped module we have to re-add the @
    if (_.startsWith(externalModule, '@')) {
      splitModule.splice(0, 1);
      splitModule[0] = '@' + splitModule[0];
    }
    const moduleName = _.first(splitModule);
    return _.includes(packageForceExcludes, moduleName);
  });

  if (log && !_.isEmpty(excludedModules)) {
    this.serverless.cli.log(`Excluding external modules: ${_.join(excludedModules, ', ')}`);
  }
}
1095081
function removeThis()
    {
        $contentobjectID = $this->attribute( 'contentobject_id' );
        $versionNum = $this->attribute( 'version' );

        $db = eZDB::instance();
        $db->begin();

        // Ensure no one else deletes this version while we are doing it.
        $db->query( 'SELECT * FROM ezcontentobject_version
                         WHERE id=' . $this->attribute( 'id' ) . ' FOR UPDATE' );

        $contentObjectTranslations = $this->translations();

        foreach ( $contentObjectTranslations as $contentObjectTranslation )
        {
            /** @var eZContentObjectAttribute $attribute */
            foreach ( $contentObjectTranslation->objectAttributes() as $attribute )
            {
                $attribute->removeThis( $attribute->attribute( 'id' ), $versionNum );
            }
        }
        $db->query( "DELETE FROM ezcontentobject_link
                         WHERE from_contentobject_id=$contentobjectID AND from_contentobject_version=$versionNum" );
        $db->query( "DELETE FROM eznode_assignment
                         WHERE contentobject_id=$contentobjectID AND contentobject_version=$versionNum" );

        $db->query( 'DELETE FROM ezcontentobject_version
                         WHERE id=' . $this->attribute( 'id' ) );

        $contentobject = $this->attribute( 'contentobject' );
        if ( is_object( $contentobject ) )
        {
            if ( !$contentobject->hasRemainingVersions() )
            {
                $contentobject->purge();
            }
            else
            {
                $version = $contentobject->CurrentVersion;
                if ( $contentobject->CurrentVersion == $versionNum ) //will assign another current_version in contentObject.
                {
                   //search for version that will be current after removing of this one.
                   $candidateToBeCurrent = $db->arrayQuery( "SELECT version
                                                     FROM ezcontentobject_version
                                                     WHERE contentobject_id={$contentobject->ID} AND
                                                           version!={$contentobject->CurrentVersion}
                                                     ORDER BY modified DESC",
                                                 array( 'offset' => 0, 'limit' => 1 ) );

                   if ( isset($candidateToBeCurrent[0]['version']) && is_numeric($candidateToBeCurrent[0]['version']) )
                   {
                       $contentobject->CurrentVersion = $candidateToBeCurrent[0]['version'];
                       $contentobject->store();
                   }
               }
            }
        }
        $db->query( "DELETE FROM ezcontentobject_name
                         WHERE contentobject_id=$contentobjectID AND content_version=$versionNum" );

        $db->commit();
    }
127573
protected function removeModule(): void
    {
        foreach (self::DIRECTORIES as $directory) {
            $this->remove($directory);
        }

        $this->installer->getIo()->write(
            sprintf(
                '  - Removed <comment>%s</comment> module from application',
                basename($this->packagePath)
            ),
            true
        );
    }
269184
static function removeURLlinkList( $contentObjectAttributeID, $contentObjectAttributeVersion )
    {
        $conditions = array( 'contentobject_attribute_id' => $contentObjectAttributeID );
        if ( $contentObjectAttributeVersion !== false )
            $conditions['contentobject_attribute_version'] = $contentObjectAttributeVersion;
        eZPersistentObject::removeObject( eZURLObjectLink::definition(),
                                          $conditions );
    }