Deletes all orphaned keywords.

Keyword is orphaned if it is not linked to a content attribute through
ezkeyword_attribute_link table.
428804
protected function deleteOrphanedKeywords()
    {
        $query = $this->connection->createQueryBuilder();
        $query
            ->select($this->connection->quoteIdentifier('kwd.id'))
            ->from($this->connection->quoteIdentifier(self::KEYWORD_TABLE), 'kwd')
            ->leftJoin(
                'kwd',
                $this->connection->quoteIdentifier(self::KEYWORD_ATTRIBUTE_LINK_TABLE),
                'attr',
                $query->expr()->eq(
                    $this->connection->quoteIdentifier('attr.keyword_id'),
                    $this->connection->quoteIdentifier('kwd.id')
                )
            )
            ->where($query->expr()->isNull('attr.id'));

        $statement = $query->execute();
        $ids = $statement->fetchAll(\PDO::FETCH_COLUMN);

        if (empty($ids)) {
            return;
        }

        $deleteQuery = $this->connection->createQueryBuilder();
        $deleteQuery
            ->delete($this->connection->quoteIdentifier(self::KEYWORD_TABLE))
            ->where(
                $deleteQuery->expr()->in($this->connection->quoteIdentifier('id'), ':ids')
            )
            ->setParameter(':ids', $ids, Connection::PARAM_INT_ARRAY);

        $deleteQuery->execute();
    }
73748
def _clearLists(self):
        
        self.feedsById      = {}
        self.feeds          = []
        self.categoriesById = {}
        self.categories     = []
        self.orphanFeeds    = []
1354551
private function cleanTarget(): void
    {
        foreach ($this->targetDictionary->keys() as $key) {
            if (!$this->sourceDictionary->has($key) || $this->sourceDictionary->get($key)->isSourceEmpty()) {
                $this->logger->log($this->logLevel, 'Removing obsolete {key}.', ['key' => $key]);
                if ($this->dryRun) {
                    continue;
                }

                $this->targetDictionary->remove($key);
            }
        }
    }
518908
public function removeAttrArticle()
    {
        $aChosenCat = $this->_getActionIds('oxobject2attribute.oxid');

        if (\OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('all')) {
            $sO2AttributeView = $this->_getViewName('oxobject2attribute');

            $sQ = parent::_addFilter("delete $sO2AttributeView.* " . $this->_getQuery());
            \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->Execute($sQ);
        } elseif (is_array($aChosenCat)) {
            $sChosenCategories = implode(", ", \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->quoteArray($aChosenCat));
            $sQ = "delete from oxobject2attribute where oxobject2attribute.oxid in (" . $sChosenCategories . ") ";
            \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->Execute($sQ);
        }
    }
411540
protected function purgeAttributes()
    {
        $attributes = $this->getPurgeAttributes();

        if ( ! empty($attributes) )
        {
            foreach ( $attributes as $attribute )
            {
                unset($this->attributes[$attribute]);
            }
        }
    }
594648
def clean(self):
        
        super().clean()
        if self.forum.is_category or self.forum.is_link:
            raise ValidationError(
                _('A topic can not be associated with a category or a link forum')
            )
64243
public void clear() {

        if (hashIndex.modified) {
            accessCount  = 0;
            accessMin    = accessCount;
            hasZeroKey   = false;
            zeroKeyIndex = -1;

            clearElementArrays(0, hashIndex.linkTable.length);
            hashIndex.clear();

            if (minimizeOnEmpty) {
                rehash(initialCapacity);
            }
        }
    }
257027
def remove_unused_links(self, used):
        
        unused = []

        self._execute("SELECT * FROM {}".format(self.LINK_STATE_TABLE))
        for row in self.cursor:
            relpath, inode, mtime = row
            inode = self._from_sqlite(inode)
            path = os.path.join(self.root_dir, relpath)

            if path in used:
                continue

            if not os.path.exists(path):
                continue

            actual_inode = get_inode(path)
            actual_mtime, _ = get_mtime_and_size(path)

            if inode == actual_inode and mtime == actual_mtime:
                logger.debug("Removing '{}' as unused link.".format(path))
                remove(path)
                unused.append(relpath)

        for relpath in unused:
            cmd = 'DELETE FROM {} WHERE path = "{}"'
            self._execute(cmd.format(self.LINK_STATE_TABLE, relpath))
21646
def delete(self):
        
        # Delete each field
        for field_name in self._fields:
            field = self.get_field(field_name)
            if not isinstance(field, PKField):
                # pk has no stored key
                field.delete()
        # Remove the pk from the model collection
        self.connection.srem(self.get_field('pk').collection_key, self._pk)
        # Deactivate the instance
        delattr(self, "_pk")
218442
public function purgeUnreachableWeakInstances() {
		foreach ($this->declaredInstances as $key=>$instance) {
			if (!isset($instance['weak']) || $instance['weak'] == false) {
				$this->walkForGarbageCollection($key);
			}
		}

		// At this point any instance with the "noGarbageCollect" attribute should be kept. Others should be eliminated.
		$keptInstances = array();
		foreach ($this->declaredInstances as $key=>$instance) {
			if (isset($instance['noGarbageCollect']) && $instance['noGarbageCollect'] == true) {
				// Let's clear the flag
				unset($this->declaredInstances[$key]['noGarbageCollect']);
			} else {
				// Let's delete the weak instance
				unset($this->declaredInstances[$key]);
			}
		}


	}
415913
def remove(self, _query=None, **kwargs):
        
        for entry in self._find_entries(_query=_query, **kwargs):
            self._service.DeleteRow(entry)
68939
public function cleanKeywordLinks(AbstractClassContent $content, $keywords)
    {
        if (!is_array($keywords)) {
            $keywords = [$keywords];
        }

        $keywordUids = [];
        foreach ($keywords as $keyword) {
            if (
                $keyword instanceof Keyword
                && !empty($keyword->value)
                && (null !== $realKeyword = $this->_em->find('BackBee\NestedNode\KeyWord', $keyword->value))
            ) {
                $keywordUids[] = $realKeyword->getUid();
            }
        }

        $query = $this->_em
            ->getConnection()
            ->createQueryBuilder()
            ->select('c.keyword_uid')
            ->from('keywords_contents', 'c')
        ;
        $query->where($query->expr()->eq('c.content_uid', $query->expr()->literal($content->getUid())));
        $savedKeywords = $query->execute()->fetchAll(\PDO::FETCH_COLUMN);

        $linksToBeRemoved = array_diff($savedKeywords, $keywordUids);
        if (count($linksToBeRemoved)) {
            $query = $this->_em
                ->getConnection()
                ->createQueryBuilder()
                ->delete('keywords_contents')
            ;

            array_walk(
                $linksToBeRemoved,
                function(&$value, $key, $query) {
                    $value = $query->expr()->literal($value);
                },
                $query
            );

            $query
                ->where($query->expr()->eq('content_uid', $query->expr()->literal($content->getUid())))
                ->andWhere($query->expr()->in('keyword_uid', $linksToBeRemoved))
                ->execute()
            ;
        }
    }
106570
def clear(**kwargs):
    

    database = kwargs.pop('database', False)
    expression = lambda target, table: table.drop(target)
    test = lambda x, tab: not database_exists(x.url) or not tab.exists(x)

    # TODO: Iterate through all engines in name set.
    if database and database_exists(engine['default'].url):
        drop_database(engine['default'].url)
        clear_cache()

    op(expression, reversed(metadata.sorted_tables), test=test,
       primary='clear', secondary='drop', **kwargs)
212481
def clear_content(self):
        
        if self.sectPr is not None:
            content_elms = self[:-1]
        else:
            content_elms = self[:]
        for content_elm in content_elms:
            self.remove(content_elm)
515268
def removeIndexOnAttribute(self, attributeName):
        '''
            
        '''
        attributeName = attributeName.lower()
        if attributeName in self.otherAttributeIndexFunctions:
                del self.otherAttributeIndexFunctions[attributeName]
        if attributeName in self._otherAttributeIndexes:
                del self._otherAttributeIndexes[attributeName]
1000215
def clear(self):
        """"""

        # Create set of candidate_subclasses associated with each mention_subclass
        cand_subclasses = set()
        for mentions, tablename in [
            (_[1][0], _[1][1]) for _ in candidate_subclasses.values()
        ]:
            for mention in mentions:
                if mention in self.mention_classes:
                    cand_subclasses.add(tablename)

        # First, clear all the Mentions. This will cascade and remove the
        # mention_subclasses and corresponding candidate_subclasses.
        for mention_class in self.mention_classes:
            logger.info(f"Clearing table: {mention_class.__tablename__}")
            self.session.query(Mention).filter_by(
                type=mention_class.__tablename__
            ).delete(synchronize_session="fetch")

        # Next, clear the Candidates. This is done manually because we have
        # no cascading relationship from candidate_subclass to Candidate.
        for cand_subclass in cand_subclasses:
            logger.info(f"Cascading to clear table: {cand_subclass}")
            self.session.query(Candidate).filter_by(type=cand_subclass).delete(
                synchronize_session="fetch"
            )
315863
function removeKeyword(keyword) {
  /* jshint validthis: true */
  var RULES = this.RULES;
  delete RULES.keywords[keyword];
  delete RULES.all[keyword];
  delete RULES.custom[keyword];
  for (var i=0; i<RULES.length; i++) {
    var rules = RULES[i].rules;
    for (var j=0; j<rules.length; j++) {
      if (rules[j].keyword == keyword) {
        rules.splice(j, 1);
        break;
      }
    }
  }
  return this;
}