From 15fa28024cc9904e906a0335a2d7b1826fcff355 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Fri, 2 Nov 2012 01:04:14 +0100 Subject: [PATCH] Replaces count calls with semantically correct empty calls --- wcfsetup/install.php | 2 +- .../acp/form/AbstractOptionListForm.class.php | 4 +-- .../lib/acp/form/CronjobEditForm.class.php | 2 +- .../files/lib/acp/form/LoginForm.class.php | 2 +- .../lib/acp/form/MasterPasswordForm.class.php | 2 +- .../files/lib/acp/form/OptionForm.class.php | 2 +- .../form/PackageStartInstallForm.class.php | 2 +- .../lib/acp/form/PackageUpdateForm.class.php | 4 +-- .../form/PackageUpdateSearchForm.class.php | 10 ++++-- .../acp/form/UpdateServerEditForm.class.php | 2 +- .../files/lib/acp/form/UserAddForm.class.php | 4 +-- .../files/lib/acp/form/UserEditForm.class.php | 2 +- .../lib/acp/form/UserGroupAddForm.class.php | 6 ++-- .../lib/acp/form/UserGroupEditForm.class.php | 5 ++- .../lib/acp/form/UserSearchForm.class.php | 6 ++-- .../form/UsersMassProcessingForm.class.php | 17 ++++++---- .../page/PackageAutoUpdateListPage.class.php | 2 +- .../PackageUpdateSearchResultPage.class.php | 4 +-- .../files/lib/acp/page/UserListPage.class.php | 4 +-- .../files/lib/action/AbstractAction.class.php | 4 +-- .../lib/action/ClipboardProxyAction.class.php | 2 +- .../AbstractDatabaseObjectAction.class.php | 32 +++++++++---------- .../lib/data/DatabaseObjectEditor.class.php | 4 +-- .../lib/data/DatabaseObjectList.class.php | 2 +- .../acp/session/ACPSessionEditor.class.php | 4 ++- .../data/category/CategoryAction.class.php | 22 ++++++------- .../data/language/LanguageAction.class.php | 12 ++++--- .../data/language/LanguageEditor.class.php | 18 +++++------ .../lib/data/language/SetupLanguage.class.php | 2 +- .../files/lib/data/option/Option.class.php | 2 +- .../files/lib/data/package/Package.class.php | 8 +++-- .../server/PackageUpdateServer.class.php | 2 +- .../lib/data/template/Template.class.php | 2 +- .../files/lib/data/user/UserAction.class.php | 14 ++++---- .../files/lib/data/user/UserEditor.class.php | 2 +- .../lib/data/user/group/UserGroup.class.php | 8 ++--- .../data/user/group/UserGroupAction.class.php | 2 +- .../data/user/group/UserGroupEditor.class.php | 6 ++-- .../files/lib/form/AbstractForm.class.php | 2 +- .../files/lib/page/AbstractPage.class.php | 8 ++--- .../install/files/lib/system/WCF.class.php | 10 +++--- .../files/lib/system/WCFSetup.class.php | 8 ++--- .../builder/ACPMenuCacheBuilder.class.php | 4 +-- .../builder/OptionCacheBuilder.class.php | 4 +-- .../builder/PageMenuCacheBuilder.class.php | 2 +- .../UserGroupPermissionCacheBuilder.class.php | 2 +- .../source/MemcacheCacheSource.class.php | 5 +-- .../system/cleanup/CleanupHandler.class.php | 2 +- .../clipboard/ClipboardHandler.class.php | 2 +- .../action/UserClipboardAction.class.php | 4 +-- .../RefreshSearchRobotsCronjob.class.php | 4 +-- .../statement/PreparedStatement.class.php | 4 +-- ...reparedStatementConditionBuilder.class.php | 4 +-- .../lib/system/event/EventHandler.class.php | 4 +-- .../files/lib/system/io/File.class.php | 2 +- .../files/lib/system/io/TarWriter.class.php | 2 +- .../lib/system/language/I18nHandler.class.php | 6 ++-- .../system/language/LanguageFactory.class.php | 2 +- .../LanguageServerProcessor.class.php | 10 +++--- .../files/lib/system/mail/Mail.class.php | 2 +- .../lib/system/mail/SMTPMailSender.class.php | 6 ++-- .../files/lib/system/menu/TreeMenu.class.php | 2 +- .../option/MultiSelectOptionType.class.php | 4 +-- .../option/TextI18nOptionType.class.php | 3 +- .../option/TextareaI18nOptionType.class.php | 3 +- .../package/ACPTemplatesFileHandler.class.php | 4 +-- .../system/package/FilesFileHandler.class.php | 2 +- .../system/package/PackageArchive.class.php | 2 +- .../PackageInstallationDispatcher.class.php | 16 ++++++---- .../PackageInstallationNodeBuilder.class.php | 3 +- .../PackageInstallationSQLParser.class.php | 4 +-- .../PackageInstallationScheduler.class.php | 8 ++--- .../package/PackageUpdateDispatcher.class.php | 6 ++-- ...emplatePackageInstallationPlugin.class.php | 2 +- ...tOptionPackageInstallationPlugin.class.php | 4 +-- ...dActionPackageInstallationPlugin.class.php | 2 +- .../FilePackageInstallationPlugin.class.php | 2 +- ...anguagePackageInstallationPlugin.class.php | 6 ++-- .../StylePackageInstallationPlugin.class.php | 2 +- ...emplatePackageInstallationPlugin.class.php | 2 +- .../system/session/SessionHandler.class.php | 2 +- .../lib/system/setup/Installer.class.php | 2 +- .../system/sitemap/SitemapHandler.class.php | 2 +- .../system/template/TemplateEngine.class.php | 8 ++--- .../user/storage/UserStorageHandler.class.php | 4 +-- wcfsetup/install/files/lib/util/XML.class.php | 8 ++--- 86 files changed, 223 insertions(+), 209 deletions(-) diff --git a/wcfsetup/install.php b/wcfsetup/install.php index 94a3d92bfd..6d778d8984 100644 --- a/wcfsetup/install.php +++ b/wcfsetup/install.php @@ -760,7 +760,7 @@ if (!file_exists(TMP_DIR . 'install/files/lib/system/WCFSetup.class.php')) { // try to unzip all setup files into temp folder $tar = new Tar(SETUP_FILE); $contentList = $tar->getContentList(); - if (!count($contentList)) { + if (empty($contentList)) { throw new SystemException("Can not unpack 'WCFSetup.tar.gz'. File is probably broken."); } diff --git a/wcfsetup/install/files/lib/acp/form/AbstractOptionListForm.class.php b/wcfsetup/install/files/lib/acp/form/AbstractOptionListForm.class.php index ebbe6c9810..1c33c9f6e3 100755 --- a/wcfsetup/install/files/lib/acp/form/AbstractOptionListForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/AbstractOptionListForm.class.php @@ -98,7 +98,7 @@ abstract class AbstractOptionListForm extends AbstractForm { $this->errorType = array_merge($this->optionHandler->validate(), $this->errorType); - if (count($this->errorType) > 0) { + if (!empty($this->errorType)) { throw new UserInputException('options', $this->errorType); } } @@ -109,7 +109,7 @@ abstract class AbstractOptionListForm extends AbstractForm { public function readData() { parent::readData(); - if (!count($_POST)) { + if (empty($_POST)) { $this->optionHandler->readData(); } } diff --git a/wcfsetup/install/files/lib/acp/form/CronjobEditForm.class.php b/wcfsetup/install/files/lib/acp/form/CronjobEditForm.class.php index dc11acedb2..db972ab3db 100755 --- a/wcfsetup/install/files/lib/acp/form/CronjobEditForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/CronjobEditForm.class.php @@ -87,7 +87,7 @@ class CronjobEditForm extends CronjobAddForm { public function readData() { parent::readData(); - if (!count($_POST)) { + if (empty($_POST)) { $this->className = $this->cronjob->className; $this->description = $this->cronjob->description; $this->startMinute = $this->cronjob->startMinute; diff --git a/wcfsetup/install/files/lib/acp/form/LoginForm.class.php b/wcfsetup/install/files/lib/acp/form/LoginForm.class.php index d2bcda3105..1a40dbcfdb 100755 --- a/wcfsetup/install/files/lib/acp/form/LoginForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/LoginForm.class.php @@ -154,7 +154,7 @@ class LoginForm extends AbstractForm { parent::readData(); // get preferred username - if (!count($_POST)) { + if (empty($_POST)) { if (isset($_COOKIE[COOKIE_PREFIX.'userID'])) { $user = new User(intval($_COOKIE[COOKIE_PREFIX.'userID'])); if ($user->userID) $this->username = $user->username; diff --git a/wcfsetup/install/files/lib/acp/form/MasterPasswordForm.class.php b/wcfsetup/install/files/lib/acp/form/MasterPasswordForm.class.php index 2166ff036d..6269dce74f 100755 --- a/wcfsetup/install/files/lib/acp/form/MasterPasswordForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/MasterPasswordForm.class.php @@ -91,7 +91,7 @@ class MasterPasswordForm extends ACPForm { public function readData() { parent::readData(); - if (!count($_POST)) { + if (empty($_POST)) { $this->url = WCF::getSession()->requestURI; } } diff --git a/wcfsetup/install/files/lib/acp/form/OptionForm.class.php b/wcfsetup/install/files/lib/acp/form/OptionForm.class.php index e4f3775b30..250fd8718d 100644 --- a/wcfsetup/install/files/lib/acp/form/OptionForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/OptionForm.class.php @@ -89,7 +89,7 @@ class OptionForm extends AbstractOptionListForm { // load option tree $this->optionTree = $this->optionHandler->getOptionTree($this->category->categoryName); - if (!count($_POST)) { + if (empty($_POST)) { // not a valid top (level 1 or 2) category if (!isset($this->optionTree[0])) { throw new IllegalLinkException(); diff --git a/wcfsetup/install/files/lib/acp/form/PackageStartInstallForm.class.php b/wcfsetup/install/files/lib/acp/form/PackageStartInstallForm.class.php index 4878e8dd23..2ba840d204 100755 --- a/wcfsetup/install/files/lib/acp/form/PackageStartInstallForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/PackageStartInstallForm.class.php @@ -178,7 +178,7 @@ class PackageStartInstallForm extends ACPForm { // validate php requirements $errors = PackageInstallationDispatcher::validatePHPRequirements($this->archive->getPhpRequirements()); - if (count($errors)) { + if (!empty($errors)) { WCF::getTPL()->assign('phpRequirements', $errors); throw new UserInputException($type, 'phpRequirements'); } diff --git a/wcfsetup/install/files/lib/acp/form/PackageUpdateForm.class.php b/wcfsetup/install/files/lib/acp/form/PackageUpdateForm.class.php index 78472cec62..5bdbcfeb25 100755 --- a/wcfsetup/install/files/lib/acp/form/PackageUpdateForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/PackageUpdateForm.class.php @@ -68,7 +68,7 @@ class PackageUpdateForm extends ACPForm { public function validate() { parent::validate(); - if (!count($this->updates)) { + if (empty($this->updates)) { throw new UserInputException('updates'); } @@ -77,7 +77,7 @@ class PackageUpdateForm extends ACPForm { try { $this->packageUpdate->buildPackageInstallationStack(); $this->excludedPackages = $this->packageUpdate->getExcludedPackages(); - if (count($this->excludedPackages)) { + if (!empty($this->excludedPackages)) { throw new UserInputException('excludedPackages'); } } diff --git a/wcfsetup/install/files/lib/acp/form/PackageUpdateSearchForm.class.php b/wcfsetup/install/files/lib/acp/form/PackageUpdateSearchForm.class.php index 705cca8425..1b17dbcdb1 100644 --- a/wcfsetup/install/files/lib/acp/form/PackageUpdateSearchForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/PackageUpdateSearchForm.class.php @@ -115,14 +115,18 @@ class PackageUpdateSearchForm extends ACPForm { */ public function validate() { parent::validate(); - + // refresh package database PackageUpdateDispatcher::refreshPackageDatabase($this->packageUpdateServerIDs); // build conditions $conditions = new PreparedStatementConditionBuilder(); + // update servers - if (count($this->packageUpdateServerIDs)) $conditions->add("packageUpdateServerID IN (?)", array($this->packageUpdateServerIDs)); + if (!empty($this->packageUpdateServerIDs)) { + $conditions->add("packageUpdateServerID IN (?)", array($this->packageUpdateServerIDs)); + } + // name if (!empty($this->packageName)) { $condition = "packageName LIKE ?"; @@ -207,7 +211,7 @@ class PackageUpdateSearchForm extends ACPForm { $packages[$row['package']][$row['packageUpdateID']][] = $row['packageVersion']; } - foreach ($packages as $identifier => $packageUpdates) { + foreach ($packages as $packageUpdates) { if (count($packageUpdates) > 1) { foreach ($packageUpdates as $packageUpdateID => $versions) { usort($versions, array('wcf\data\package\Package', 'compareVersion')); diff --git a/wcfsetup/install/files/lib/acp/form/UpdateServerEditForm.class.php b/wcfsetup/install/files/lib/acp/form/UpdateServerEditForm.class.php index 4619916d3b..8f901df853 100755 --- a/wcfsetup/install/files/lib/acp/form/UpdateServerEditForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/UpdateServerEditForm.class.php @@ -72,7 +72,7 @@ class UpdateServerEditForm extends UpdateServerAddForm { public function readData() { parent::readData(); - if (!count($_POST)) { + if (empty($_POST)) { $this->serverURL = $this->updateServer->serverURL; $this->loginUsername = $this->updateServer->loginUsername; $this->loginPassword = $this->updateServer->loginPassword; diff --git a/wcfsetup/install/files/lib/acp/form/UserAddForm.class.php b/wcfsetup/install/files/lib/acp/form/UserAddForm.class.php index 6eed598a2f..493ee71cea 100644 --- a/wcfsetup/install/files/lib/acp/form/UserAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/UserAddForm.class.php @@ -140,7 +140,7 @@ class UserAddForm extends UserOptionListForm { } // validate user groups - if (count($this->groupIDs) > 0) { + if (!empty($this->groupIDs)) { $conditions = new PreparedStatementConditionBuilder(); $conditions->add("groupID IN (?)", array($this->groupIDs)); $conditions->add("groupType NOT IN (?)", array(array(UserGroup::GUESTS, UserGroup::EVERYONE, UserGroup::USERS))); @@ -172,7 +172,7 @@ class UserAddForm extends UserOptionListForm { unset($this->visibleLanguages[$key]); } } - if (!count($this->visibleLanguages) && ($language = LanguageFactory::getInstance()->getLanguage($this->languageID)) && $language->hasContent) { + if (empty($this->visibleLanguages) && ($language = LanguageFactory::getInstance()->getLanguage($this->languageID)) && $language->hasContent) { $this->visibleLanguages[] = $this->languageID; } diff --git a/wcfsetup/install/files/lib/acp/form/UserEditForm.class.php b/wcfsetup/install/files/lib/acp/form/UserEditForm.class.php index 336ac3c23c..3be8e48b42 100755 --- a/wcfsetup/install/files/lib/acp/form/UserEditForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/UserEditForm.class.php @@ -84,7 +84,7 @@ class UserEditForm extends UserAddForm { * @see wcf\page\IPage::readData() */ public function readData() { - if (!count($_POST)) { + if (empty($_POST)) { // get visible languages $this->readVisibleLanguages(); diff --git a/wcfsetup/install/files/lib/acp/form/UserGroupAddForm.class.php b/wcfsetup/install/files/lib/acp/form/UserGroupAddForm.class.php index 4bded886d6..7788c4ab20 100755 --- a/wcfsetup/install/files/lib/acp/form/UserGroupAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/UserGroupAddForm.class.php @@ -107,9 +107,9 @@ class UserGroupAddForm extends AbstractOptionListForm { $this->errorType[$e->getField()] = $e->getType(); } - if (count($this->errorType) > 0) { + if (!empty($this->errorType)) { throw new UserInputException('groupName', $this->errorType); - } + } } /** @@ -171,7 +171,7 @@ class UserGroupAddForm extends AbstractOptionListForm { parent::readData(); $this->optionTree = $this->optionHandler->getOptionTree(); - if (!count($_POST)) { + if (empty($_POST)) { $this->activeTabMenuItem = $this->optionTree[0]['object']->categoryName; } } diff --git a/wcfsetup/install/files/lib/acp/form/UserGroupEditForm.class.php b/wcfsetup/install/files/lib/acp/form/UserGroupEditForm.class.php index b19ca92caa..b9a15a31cb 100755 --- a/wcfsetup/install/files/lib/acp/form/UserGroupEditForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/UserGroupEditForm.class.php @@ -66,7 +66,7 @@ class UserGroupEditForm extends UserGroupAddForm { * @see wcf\page\IPage::readData() */ public function readData() { - if (!count($_POST)) { + if (empty($_POST)) { I18nHandler::getInstance()->setOptions('groupName', 1, $this->group->groupName, 'wcf.acp.group.group\d+'); $this->groupName = $this->group->groupName; $options = $this->optionHandler->getCategoryOptions(); @@ -99,8 +99,7 @@ class UserGroupEditForm extends UserGroupAddForm { public function assignVariables() { parent::assignVariables(); - $useRequestData = (count($_POST)) ? true : false; - I18nHandler::getInstance()->assignVariables($useRequestData); + I18nHandler::getInstance()->assignVariables(!empty($_POST)); WCF::getTPL()->assign(array( 'groupID' => $this->group->groupID, diff --git a/wcfsetup/install/files/lib/acp/form/UserSearchForm.class.php b/wcfsetup/install/files/lib/acp/form/UserSearchForm.class.php index 01ea4ea3f2..657f91503b 100755 --- a/wcfsetup/install/files/lib/acp/form/UserSearchForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/UserSearchForm.class.php @@ -235,7 +235,7 @@ class UserSearchForm extends UserOptionListForm { // do search $this->search(); - if (count($this->matches) == 0) { + if (empty($this->matches)) { throw new UserInputException('search', 'noMatches'); } } @@ -283,10 +283,10 @@ class UserSearchForm extends UserOptionListForm { if (!empty($this->email)) { $this->conditions->add("user_table.email LIKE ?", array('%'.addcslashes($this->email, '_%').'%')); } - if (count($this->groupIDs)) { + if (!empty($this->groupIDs)) { $this->conditions->add("user_table.userID ".($this->invertGroupIDs == 1 ? 'NOT ' : '')."IN (SELECT userID FROM wcf".WCF_N."_user_to_group WHERE groupID IN (?))", array($this->groupIDs)); } - if (count($this->languageIDs)) { + if (!empty($this->languageIDs)) { $this->conditions->add("user_table.languageID IN (?)", array($this->languageIDs)); } } diff --git a/wcfsetup/install/files/lib/acp/form/UsersMassProcessingForm.class.php b/wcfsetup/install/files/lib/acp/form/UsersMassProcessingForm.class.php index ef8332aa72..7dffb6a518 100644 --- a/wcfsetup/install/files/lib/acp/form/UsersMassProcessingForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/UsersMassProcessingForm.class.php @@ -133,7 +133,7 @@ class UsersMassProcessingForm extends UserOptionListForm { // assign to group if ($this->action == 'assignToGroup') { - if (!count($this->assignToGroupIDArray)) { + if (empty($this->assignToGroupIDArray)) { throw new UserInputException('assignToGroupIDArray'); } } @@ -162,6 +162,7 @@ class UsersMassProcessingForm extends UserOptionListForm { // build conditions $this->conditions = new PreparedStatementConditionBuilder(); + // static fields if (!empty($this->username)) { $this->conditions->add("user.username LIKE ?", array('%'.addcslashes($this->username, '_%').'%')); @@ -169,10 +170,10 @@ class UsersMassProcessingForm extends UserOptionListForm { if (!empty($this->email)) { $this->conditions->add("user.email LIKE ?", array('%'.addcslashes($this->email, '_%').'%')); } - if (count($this->groupIDArray) > 0) { + if (!empty($this->groupIDArray)) { $this->conditions->add("user.userID ".($this->invertGroupIDs == 1 ? 'NOT ' : '')."IN (SELECT userID FROM wcf".WCF_N."_user_to_group WHERE groupID IN (?))", array($this->groupIDArray)); } - if (count($this->languageIDArray) > 0) { + if (!empty($this->languageIDArray)) { $this->conditions->add("user.languageID IN (?)", array($this->languageIDArray)); } @@ -356,9 +357,13 @@ class UsersMassProcessingForm extends UserOptionListForm { public function readData() { parent::readData(); - if (!count($_POST)) { - if (MAIL_USE_FORMATTED_ADDRESS) $this->from = MAIL_FROM_NAME . ' <' . MAIL_FROM_ADDRESS . '>'; - else $this->from = MAIL_FROM_ADDRESS; + if (empty($_POST)) { + if (MAIL_USE_FORMATTED_ADDRESS) { + $this->from = MAIL_FROM_NAME.' <'.MAIL_FROM_ADDRESS.'>'; + } + else { + $this->from = MAIL_FROM_ADDRESS; + } } $this->availableGroups = $this->getAvailableGroups(); diff --git a/wcfsetup/install/files/lib/acp/page/PackageAutoUpdateListPage.class.php b/wcfsetup/install/files/lib/acp/page/PackageAutoUpdateListPage.class.php index 6bb5323449..d49bf0b540 100755 --- a/wcfsetup/install/files/lib/acp/page/PackageAutoUpdateListPage.class.php +++ b/wcfsetup/install/files/lib/acp/page/PackageAutoUpdateListPage.class.php @@ -34,7 +34,7 @@ class PackageAutoUpdateListPage extends AbstractPage { public function readParameters() { parent::readParameters(); - if (!count($_POST)) { + if (empty($_POST)) { // refresh package database PackageUpdateDispatcher::refreshPackageDatabase(); } diff --git a/wcfsetup/install/files/lib/acp/page/PackageUpdateSearchResultPage.class.php b/wcfsetup/install/files/lib/acp/page/PackageUpdateSearchResultPage.class.php index 9f4de1b4da..8aa42d121e 100755 --- a/wcfsetup/install/files/lib/acp/page/PackageUpdateSearchResultPage.class.php +++ b/wcfsetup/install/files/lib/acp/page/PackageUpdateSearchResultPage.class.php @@ -141,7 +141,7 @@ class PackageUpdateSearchResultPage extends SortablePage { $row['packageVersions'][] = $row2['packageVersion']; } - if (count($row['packageVersions'])) { + if (!empty($row['packageVersions'])) { // remove duplicates $row['packageVersions'] = array_unique($row['packageVersions']); // sort versions @@ -149,7 +149,7 @@ class PackageUpdateSearchResultPage extends SortablePage { // take lastest version $row['packageVersion'] = end($row['packageVersions']); } - + // get installed instances $sql = "SELECT package.*, CASE WHEN instanceName <> '' THEN instanceName ELSE packageName END AS packageName FROM wcf".WCF_N."_package package diff --git a/wcfsetup/install/files/lib/acp/page/UserListPage.class.php b/wcfsetup/install/files/lib/acp/page/UserListPage.class.php index e63c76d793..6e22413245 100755 --- a/wcfsetup/install/files/lib/acp/page/UserListPage.class.php +++ b/wcfsetup/install/files/lib/acp/page/UserListPage.class.php @@ -77,7 +77,7 @@ class UserListPage extends SortablePage { if (!empty($_REQUEST['id'])) { $this->searchID = intval($_REQUEST['id']); if ($this->searchID) $this->readSearchResult(); - if (!count($this->userIDs)) { + if (empty($this->userIDs)) { throw new IllegalLinkException(); } $this->conditions->add("user_table.userID IN (?)", array($this->userIDs)); @@ -177,7 +177,7 @@ class UserListPage extends SortablePage { } // get user data - if (count($userIDs)) { + if (!empty($userIDs)) { $userToGroups = array(); // get group ids diff --git a/wcfsetup/install/files/lib/action/AbstractAction.class.php b/wcfsetup/install/files/lib/action/AbstractAction.class.php index 16b6c495c4..a2db84beda 100644 --- a/wcfsetup/install/files/lib/action/AbstractAction.class.php +++ b/wcfsetup/install/files/lib/action/AbstractAction.class.php @@ -67,14 +67,14 @@ abstract class AbstractAction implements IAction { } // check modules - if (count($this->neededModules)) { + if (!empty($this->neededModules)) { foreach ($this->neededModules as $module) { if (!defined($module) || !constant($module)) throw new IllegalLinkException(); } } // check permission - if (count($this->neededPermissions)) { + if (!empty($this->neededPermissions)) { WCF::getSession()->checkPermissions($this->neededPermissions); } diff --git a/wcfsetup/install/files/lib/action/ClipboardProxyAction.class.php b/wcfsetup/install/files/lib/action/ClipboardProxyAction.class.php index 189aa71452..bfbf91821c 100644 --- a/wcfsetup/install/files/lib/action/ClipboardProxyAction.class.php +++ b/wcfsetup/install/files/lib/action/ClipboardProxyAction.class.php @@ -99,7 +99,7 @@ class ClipboardProxyAction extends AbstractSecureAction { } $objects = ClipboardHandler::getInstance()->getMarkedItems($typeID); - if (!count($objects) || !isset($objects[$this->typeName]) || !count($objects[$this->typeName])) { + if (empty($objects) || !isset($objects[$this->typeName]) || empty($objects[$this->typeName])) { return null; } diff --git a/wcfsetup/install/files/lib/data/AbstractDatabaseObjectAction.class.php b/wcfsetup/install/files/lib/data/AbstractDatabaseObjectAction.class.php index 298ecf0d9b..ad198d4b03 100644 --- a/wcfsetup/install/files/lib/data/AbstractDatabaseObjectAction.class.php +++ b/wcfsetup/install/files/lib/data/AbstractDatabaseObjectAction.class.php @@ -218,7 +218,7 @@ abstract class AbstractDatabaseObjectAction implements IDatabaseObjectAction, ID */ public function validateCreate() { // validate permissions - if (is_array($this->permissionsCreate) && count($this->permissionsCreate)) { + if (is_array($this->permissionsCreate) && !empty($this->permissionsCreate)) { try { WCF::getSession()->checkPermissions($this->permissionsCreate); } @@ -236,7 +236,7 @@ abstract class AbstractDatabaseObjectAction implements IDatabaseObjectAction, ID */ public function validateDelete() { // validate permissions - if (is_array($this->permissionsDelete) && count($this->permissionsDelete)) { + if (is_array($this->permissionsDelete) && !empty($this->permissionsDelete)) { try { WCF::getSession()->checkPermissions($this->permissionsDelete); } @@ -249,12 +249,12 @@ abstract class AbstractDatabaseObjectAction implements IDatabaseObjectAction, ID } // read objects - if (!count($this->objects)) { + if (empty($this->objects)) { $this->readObjects(); - } - - if (!count($this->objects)) { - throw new ValidateActionException('Invalid object id'); + + if (empty($this->objects)) { + throw new ValidateActionException('Invalid object id'); + } } } @@ -263,7 +263,7 @@ abstract class AbstractDatabaseObjectAction implements IDatabaseObjectAction, ID */ public function validateUpdate() { // validate permissions - if (is_array($this->permissionsUpdate) && count($this->permissionsUpdate)) { + if (is_array($this->permissionsUpdate) && !empty($this->permissionsUpdate)) { try { WCF::getSession()->checkPermissions($this->permissionsUpdate); } @@ -276,12 +276,12 @@ abstract class AbstractDatabaseObjectAction implements IDatabaseObjectAction, ID } // read objects - if (!count($this->objects)) { + if (empty($this->objects)) { $this->readObjects(); - } - - if (!count($this->objects)) { - throw new ValidateActionException('Invalid object id'); + + if (empty($this->objects)) { + throw new ValidateActionException('Invalid object id'); + } } } @@ -298,7 +298,7 @@ abstract class AbstractDatabaseObjectAction implements IDatabaseObjectAction, ID * @see wcf\data\IDeleteAction::delete() */ public function delete() { - if (!count($this->objects)) { + if (empty($this->objects)) { $this->readObjects(); } @@ -319,7 +319,7 @@ abstract class AbstractDatabaseObjectAction implements IDatabaseObjectAction, ID * Updates data. */ public function update() { - if (!count($this->objects)) { + if (empty($this->objects)) { $this->readObjects(); } @@ -334,7 +334,7 @@ abstract class AbstractDatabaseObjectAction implements IDatabaseObjectAction, ID * Reads data by data id. */ protected function readObjects() { - if (!count($this->objectIDs)) { + if (empty($this->objectIDs)) { return; } diff --git a/wcfsetup/install/files/lib/data/DatabaseObjectEditor.class.php b/wcfsetup/install/files/lib/data/DatabaseObjectEditor.class.php index 51c8cbcbd9..e0a0c9fc43 100644 --- a/wcfsetup/install/files/lib/data/DatabaseObjectEditor.class.php +++ b/wcfsetup/install/files/lib/data/DatabaseObjectEditor.class.php @@ -51,7 +51,7 @@ abstract class DatabaseObjectEditor extends DatabaseObjectDecorator implements I * @see wcf\data\IEditableObject::update() */ public function update(array $parameters = array()) { - if (!count($parameters)) return; + if (empty($parameters)) return; // check whether any value changed or not $update = false; @@ -85,7 +85,7 @@ abstract class DatabaseObjectEditor extends DatabaseObjectDecorator implements I * @see wcf\data\IEditableObject::updateCounters() */ public function updateCounters(array $counters = array()) { - if (!count($counters)) return; + if (empty($counters)) return; $updateSQL = ''; $statementParameters = array(); diff --git a/wcfsetup/install/files/lib/data/DatabaseObjectList.class.php b/wcfsetup/install/files/lib/data/DatabaseObjectList.class.php index 5fe958f850..9d8b8e102b 100644 --- a/wcfsetup/install/files/lib/data/DatabaseObjectList.class.php +++ b/wcfsetup/install/files/lib/data/DatabaseObjectList.class.php @@ -154,7 +154,7 @@ abstract class DatabaseObjectList implements \Countable, ITraversableObject { */ public function readObjects() { if ($this->objectIDs !== null) { - if (!count($this->objectIDs)) { + if (empty($this->objectIDs)) { return; } $sql = "SELECT ".(!empty($this->sqlSelects) ? $this->sqlSelects.($this->useQualifiedShorthand ? ',' : '') : '')." diff --git a/wcfsetup/install/files/lib/data/acp/session/ACPSessionEditor.class.php b/wcfsetup/install/files/lib/data/acp/session/ACPSessionEditor.class.php index d42b0450ec..6061483681 100644 --- a/wcfsetup/install/files/lib/data/acp/session/ACPSessionEditor.class.php +++ b/wcfsetup/install/files/lib/data/acp/session/ACPSessionEditor.class.php @@ -55,7 +55,9 @@ class ACPSessionEditor extends DatabaseObjectEditor { */ public static function deleteUserSessions(array $userIDs = array()) { $conditionBuilder = new PreparedStatementConditionBuilder(); - if (count($userIDs)) $conditionBuilder->add('userID IN (?)', array($userIDs)); + if (!empty($userIDs)) { + $conditionBuilder->add('userID IN (?)', array($userIDs)); + } $sql = "DELETE FROM ".call_user_func(array(static::$baseClass, 'getDatabaseTableName'))." ".$conditionBuilder; diff --git a/wcfsetup/install/files/lib/data/category/CategoryAction.class.php b/wcfsetup/install/files/lib/data/category/CategoryAction.class.php index 8fe18a1266..f415d68302 100644 --- a/wcfsetup/install/files/lib/data/category/CategoryAction.class.php +++ b/wcfsetup/install/files/lib/data/category/CategoryAction.class.php @@ -101,7 +101,7 @@ class CategoryAction extends AbstractDatabaseObjectAction implements ICollapsibl */ public function validateCreate() { // validate permissions - if (count($this->permissionsCreate)) { + if (!empty($this->permissionsCreate)) { try { WCF::getSession()->checkPermissions($this->permissionsCreate); } @@ -128,7 +128,7 @@ class CategoryAction extends AbstractDatabaseObjectAction implements ICollapsibl */ public function validateDelete() { // validate permissions - if (count($this->permissionsDelete)) { + if (!empty($this->permissionsDelete)) { try { WCF::getSession()->checkPermissions($this->permissionsDelete); } @@ -138,12 +138,12 @@ class CategoryAction extends AbstractDatabaseObjectAction implements ICollapsibl } // read objects - if (!count($this->objects)) { + if (empty($this->objects)) { $this->readObjects(); - } - - if (!count($this->objects)) { - throw new ValidateActionException('Invalid object id'); + + if (empty($this->objects)) { + throw new ValidateActionException('Invalid object id'); + } } foreach ($this->objects as $categoryEditor) { @@ -172,7 +172,7 @@ class CategoryAction extends AbstractDatabaseObjectAction implements ICollapsibl */ public function validateUpdate() { // validate permissions - if (count($this->permissionsUpdate)) { + if (!empty($this->permissionsUpdate)) { try { WCF::getSession()->checkPermissions($this->permissionsUpdate); } @@ -182,11 +182,11 @@ class CategoryAction extends AbstractDatabaseObjectAction implements ICollapsibl } // read objects - if (!count($this->objects)) { + if (empty($this->objects)) { $this->readObjects(); } - if (!count($this->objects)) { + if (empty($this->objects)) { throw new ValidateActionException('Invalid object id'); } @@ -202,7 +202,7 @@ class CategoryAction extends AbstractDatabaseObjectAction implements ICollapsibl */ public function validateUpdatePosition() { // validate permissions - if (count($this->permissionsUpdate)) { + if (!empty($this->permissionsUpdate)) { try { WCF::getSession()->checkPermissions($this->permissionsUpdate); } diff --git a/wcfsetup/install/files/lib/data/language/LanguageAction.class.php b/wcfsetup/install/files/lib/data/language/LanguageAction.class.php index f5bea5a2f4..16cea56843 100644 --- a/wcfsetup/install/files/lib/data/language/LanguageAction.class.php +++ b/wcfsetup/install/files/lib/data/language/LanguageAction.class.php @@ -47,11 +47,13 @@ class LanguageAction extends AbstractDatabaseObjectAction { throw new ValidateActionException('Insufficient permissions'); } - // read data - $this->readObjects(); - - if (!count($this->objects)) { - throw new ValidateActionException('Invalid object id'); + // read objects + if (empty($this->objects)) { + $this->readObjects(); + + if (empty($this->objects)) { + throw new ValidateActionException('Invalid object id'); + } } } diff --git a/wcfsetup/install/files/lib/data/language/LanguageEditor.class.php b/wcfsetup/install/files/lib/data/language/LanguageEditor.class.php index 74cbe3c155..fe250c460f 100644 --- a/wcfsetup/install/files/lib/data/language/LanguageEditor.class.php +++ b/wcfsetup/install/files/lib/data/language/LanguageEditor.class.php @@ -50,7 +50,7 @@ class LanguageEditor extends DatabaseObjectEditor implements IEditableCachedObje * @param array $packageIDs */ public function updateCategory(array $categoryIDs = array(), array $packageIDs = array()) { - if (!count($categoryIDs)) { + if (empty($categoryIDs)) { // get all categories $sql = "SELECT languageCategoryID FROM wcf".WCF_N."_language_category"; @@ -159,7 +159,7 @@ class LanguageEditor extends DatabaseObjectEditor implements IEditableCachedObje // get items $items = array(); - if (count($packageIDArray)) { + if (!empty($packageIDArray)) { // sql conditions $conditions->add("language_item.packageID IN (?)", array($packageIDArray)); $conditions->add("language_item.languageID = ?", array($this->languageID)); @@ -231,7 +231,7 @@ class LanguageEditor extends DatabaseObjectEditor implements IEditableCachedObje $usedCategories[$category->getAttribute('name')] = 0; } - if (!count($usedCategories)) return; + if (empty($usedCategories)) return; // select existing categories $conditions = new PreparedStatementConditionBuilder(); @@ -276,7 +276,7 @@ class LanguageEditor extends DatabaseObjectEditor implements IEditableCachedObje } } - if (count($items)) { + if (!empty($items)) { $existingItems = $statementParameters = array(); // find existing items @@ -307,7 +307,7 @@ class LanguageEditor extends DatabaseObjectEditor implements IEditableCachedObje } } - if (count($statementParameters)) { + if (!empty($statementParameters)) { if ($packageID) { $sql = "INSERT INTO wcf".WCF_N."_language_item (languageID, languageItem, languageItemValue, languageCategoryID, packageID) @@ -498,7 +498,7 @@ class LanguageEditor extends DatabaseObjectEditor implements IEditableCachedObje * @param array $useCustom */ public function updateItems(array $items, LanguageCategory $category, $packageID = PACKAGE_ID, array $useCustom = array()) { - if (!count($items)) return; + if (empty($items)) return; // find existing language items $languageItemList = new LanguageItemList(); @@ -522,7 +522,7 @@ class LanguageEditor extends DatabaseObjectEditor implements IEditableCachedObje } // create remaining items - if (count($items)) { + if (!empty($items)) { // bypass LanguageItemEditor::create() for performance reasons $sql = "INSERT INTO wcf".WCF_N."_language_item (languageID, languageItem, languageItemValue, languageItemOriginIsSystem, languageCategoryID, packageID) @@ -659,7 +659,7 @@ class LanguageEditor extends DatabaseObjectEditor implements IEditableCachedObje } // save updates - if (count($updatedItems) > 0) { + if (!empty($updatedItems)) { foreach ($updatedItems as $languageID => $categories) { $language = new LanguageEditor($languageID); @@ -689,7 +689,7 @@ class LanguageEditor extends DatabaseObjectEditor implements IEditableCachedObje $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(array(0)); - if (count($languageIDs)) { + if (!empty($languageIDs)) { $sql = ''; $statementParameters = array(); foreach ($languageIDs as $languageID) { diff --git a/wcfsetup/install/files/lib/data/language/SetupLanguage.class.php b/wcfsetup/install/files/lib/data/language/SetupLanguage.class.php index 6b02192d9a..3b67bc672c 100644 --- a/wcfsetup/install/files/lib/data/language/SetupLanguage.class.php +++ b/wcfsetup/install/files/lib/data/language/SetupLanguage.class.php @@ -56,7 +56,7 @@ class SetupLanguage extends Language { } // update language files here - if (count($categoriesToCache) > 0) { + if (!empty($categoriesToCache)) { $file = new File($filename); $file->write("languageCode."\n* encoding: UTF-8\n* category: WCF Setup\n* generated at ".gmdate("r")."\n* \n* DO NOT EDIT THIS FILE\n*/\n"); foreach ($categoriesToCache as $name) { diff --git a/wcfsetup/install/files/lib/data/option/Option.class.php b/wcfsetup/install/files/lib/data/option/Option.class.php index 94c594e0b2..367b46a1b8 100644 --- a/wcfsetup/install/files/lib/data/option/Option.class.php +++ b/wcfsetup/install/files/lib/data/option/Option.class.php @@ -69,7 +69,7 @@ class Option extends DatabaseObject { } $options = array(); - if (count($optionIDs)) { + if (!empty($optionIDs)) { // get needed options $conditions = new PreparedStatementConditionBuilder(); $conditions->add("optionID IN (?)", array($optionIDs)); diff --git a/wcfsetup/install/files/lib/data/package/Package.class.php b/wcfsetup/install/files/lib/data/package/Package.class.php index 19f8cba493..1403e8f1f6 100644 --- a/wcfsetup/install/files/lib/data/package/Package.class.php +++ b/wcfsetup/install/files/lib/data/package/Package.class.php @@ -315,7 +315,7 @@ class Package extends DatabaseObject { } // insert requirements of requirements - if (count($requirements) > 0) { + if (!empty($requirements)) { $sql = "INSERT INTO wcf".WCF_N."_package_requirement_map (packageID, requirement, level) VALUES (?, ?, ?)"; @@ -329,7 +329,9 @@ class Package extends DatabaseObject { $directRequirements = array(); $conditions = new PreparedStatementConditionBuilder($sql); $conditions->add("packageID = ?", array($packageID)); - if (count($requirements)) $conditions->add("requirement NOT IN (?)", array(array_keys($requirements))); + if (!empty($requirements)) { + $conditions->add("requirement NOT IN (?)", array(array_keys($requirements))); + } $sql = "SELECT requirement, ( @@ -347,7 +349,7 @@ class Package extends DatabaseObject { } // insert requirements - if (count($directRequirements) > 0) { + if (!empty($directRequirements)) { $sql = "INSERT INTO wcf".WCF_N."_package_requirement_map (packageID, requirement, level) VALUES (?, ?, ?)"; diff --git a/wcfsetup/install/files/lib/data/package/update/server/PackageUpdateServer.class.php b/wcfsetup/install/files/lib/data/package/update/server/PackageUpdateServer.class.php index 5c02492c65..7cfdb89d14 100644 --- a/wcfsetup/install/files/lib/data/package/update/server/PackageUpdateServer.class.php +++ b/wcfsetup/install/files/lib/data/package/update/server/PackageUpdateServer.class.php @@ -34,7 +34,7 @@ class PackageUpdateServer extends DatabaseObject { $list = new PackageUpdateServerList(); $list->sqlLimit = 0; $list->getConditionBuilder()->add("disabled = ?", array(0)); - if (count($packageUpdateServerIDs)) { + if (!empty($packageUpdateServerIDs)) { $list->getConditionBuilder()->add("packageUpdateServerID IN (?)", array($packageUpdateServerIDs)); } $list->readObjects(); diff --git a/wcfsetup/install/files/lib/data/template/Template.class.php b/wcfsetup/install/files/lib/data/template/Template.class.php index 0a2aec35d0..ef486ac44e 100644 --- a/wcfsetup/install/files/lib/data/template/Template.class.php +++ b/wcfsetup/install/files/lib/data/template/Template.class.php @@ -104,7 +104,7 @@ class Template extends DatabaseObject { } // get templates - if (!count($availableTemplateIDs)) return $results; + if (empty($availableTemplateIDs)) return $results; $conditions = new PreparedStatementConditionBuilder(); $conditions->add("template.templateID IN (?)", array($availableTemplateIDs)); diff --git a/wcfsetup/install/files/lib/data/user/UserAction.class.php b/wcfsetup/install/files/lib/data/user/UserAction.class.php index c17bfeb7a3..ffcb44d5ec 100644 --- a/wcfsetup/install/files/lib/data/user/UserAction.class.php +++ b/wcfsetup/install/files/lib/data/user/UserAction.class.php @@ -98,12 +98,12 @@ class UserAction extends AbstractDatabaseObjectAction implements IClipboardActio */ public function validateUpdate() { // read objects - if (!count($this->objects)) { + if (empty($this->objects)) { $this->readObjects(); - } - - if (!count($this->objects)) { - throw new ValidateActionException('Invalid object id'); + + if (empty($this->objects)) { + throw new ValidateActionException('Invalid object id'); + } } try { @@ -168,7 +168,7 @@ class UserAction extends AbstractDatabaseObjectAction implements IClipboardActio } } else { - if (!count($this->objects)) { + if (empty($this->objects)) { $this->readObjects(); } } @@ -244,7 +244,7 @@ class UserAction extends AbstractDatabaseObjectAction implements IClipboardActio $conditionBuilder = new PreparedStatementConditionBuilder(); $conditionBuilder->add("username LIKE ?", array($searchString.'%')); - if (count($excludedSearchValues)) { + if (!empty($excludedSearchValues)) { $conditionBuilder->add("username NOT IN (?)", array($excludedSearchValues)); } diff --git a/wcfsetup/install/files/lib/data/user/UserEditor.class.php b/wcfsetup/install/files/lib/data/user/UserEditor.class.php index 53240e1937..543ecedf01 100644 --- a/wcfsetup/install/files/lib/data/user/UserEditor.class.php +++ b/wcfsetup/install/files/lib/data/user/UserEditor.class.php @@ -159,7 +159,7 @@ class UserEditor extends DatabaseObjectEditor implements IEditableCachedObject { } // insert new groups - if (count($groupIDs) > 0) { + if (!empty($groupIDs)) { $sql = "INSERT INTO wcf".WCF_N."_user_to_group (userID, groupID) VALUES (?, ?)"; diff --git a/wcfsetup/install/files/lib/data/user/group/UserGroup.class.php b/wcfsetup/install/files/lib/data/user/group/UserGroup.class.php index 522a5ef8ff..c44e861665 100644 --- a/wcfsetup/install/files/lib/data/user/group/UserGroup.class.php +++ b/wcfsetup/install/files/lib/data/user/group/UserGroup.class.php @@ -100,7 +100,7 @@ class UserGroup extends DatabaseObject { self::getCache(); // get all groups - if (!count($types)) return self::$cache['groups']; + if (empty($types)) return self::$cache['groups']; // get groups by type $groupIDs = self::getGroupIDsByType($types); @@ -170,7 +170,7 @@ class UserGroup extends DatabaseObject { self::$accessibleGroups = explode(',', WCF::getSession()->getPermission('admin.user.accessibleGroups')); } - if (count($groupIDs) == 0) return false; + if (empty($groupIDs)) return false; foreach ($groupIDs as $groupID) { if (!in_array($groupID, self::$accessibleGroups)) { @@ -191,7 +191,7 @@ class UserGroup extends DatabaseObject { public static function getAccessibleGroups(array $groupTypes = array(), array $invalidGroupTypes = array()) { $groups = self::getGroupsByType($groupTypes); - if (count($invalidGroupTypes) > 0) { + if (!empty($invalidGroupTypes)) { $invalidGroups = self::getGroupsByType($invalidGroupTypes); foreach ($invalidGroups as $groupID => $group) { unset($groups[$groupID]); @@ -322,7 +322,7 @@ class UserGroup extends DatabaseObject { $groupOptionIDs[$row['optionName']] = $row['optionID']; } - if (count($groupOptionIDs)) { + if (!empty($groupOptionIDs)) { $conditions = new PreparedStatementConditionBuilder(); $conditions->add("option_value.groupID = ?", array($this->groupID)); $conditions->add("option_value.optionID IN (?)", array($groupOptionIDs)); diff --git a/wcfsetup/install/files/lib/data/user/group/UserGroupAction.class.php b/wcfsetup/install/files/lib/data/user/group/UserGroupAction.class.php index 482913cc53..9974f6c494 100644 --- a/wcfsetup/install/files/lib/data/user/group/UserGroupAction.class.php +++ b/wcfsetup/install/files/lib/data/user/group/UserGroupAction.class.php @@ -49,7 +49,7 @@ class UserGroupAction extends AbstractDatabaseObjectAction { * @see wcf\data\AbstractDatabaseObjectAction::update() */ public function update() { - if (!count($this->objects)) { + if (empty($this->objects)) { $this->readObjects(); } diff --git a/wcfsetup/install/files/lib/data/user/group/UserGroupEditor.class.php b/wcfsetup/install/files/lib/data/user/group/UserGroupEditor.class.php index 2470f0ce9e..7ec120eac1 100644 --- a/wcfsetup/install/files/lib/data/user/group/UserGroupEditor.class.php +++ b/wcfsetup/install/files/lib/data/user/group/UserGroupEditor.class.php @@ -60,7 +60,7 @@ class UserGroupEditor extends DatabaseObjectEditor implements IEditableCachedObj * @param array $groupIDs */ protected static function removeGroupAssignments(array $groupIDs) { - if (!count($groupIDs)) return; + if (empty($groupIDs)) return; $sql = "DELETE FROM wcf".WCF_N."_user_to_group WHERE groupID = ?"; @@ -76,7 +76,7 @@ class UserGroupEditor extends DatabaseObjectEditor implements IEditableCachedObj * @param array $groupIDs */ protected static function removeOptionValues(array $groupIDs) { - if (!count($groupIDs)) return; + if (empty($groupIDs)) return; $sql = "DELETE FROM wcf".WCF_N."_user_group_option_value WHERE groupID = ?"; @@ -162,7 +162,7 @@ class UserGroupEditor extends DatabaseObjectEditor implements IEditableCachedObj $optionID = $row['optionID']; // update optionValue from groups which got all existing groups as value - if (count($updateGroupIDs)) { + if (!empty($updateGroupIDs)) { $conditionBuilder = new PreparedStatementConditionBuilder(); $conditionBuilder->add('groupID IN (?)', array($updateGroupIDs)); $conditionBuilder->add('optionID = ?', array($optionID)); diff --git a/wcfsetup/install/files/lib/form/AbstractForm.class.php b/wcfsetup/install/files/lib/form/AbstractForm.class.php index 6e75ca4293..1c88c38213 100644 --- a/wcfsetup/install/files/lib/form/AbstractForm.class.php +++ b/wcfsetup/install/files/lib/form/AbstractForm.class.php @@ -100,7 +100,7 @@ abstract class AbstractForm extends AbstractPage implements IForm { * @see wcf\page\IPage::readData() */ public function readData() { - if (count($_POST) || count($_FILES)) { + if (!empty($_POST) || !empty($_FILES)) { $this->submit(); } diff --git a/wcfsetup/install/files/lib/page/AbstractPage.class.php b/wcfsetup/install/files/lib/page/AbstractPage.class.php index 8c5b4145e6..b07e3fb86d 100644 --- a/wcfsetup/install/files/lib/page/AbstractPage.class.php +++ b/wcfsetup/install/files/lib/page/AbstractPage.class.php @@ -114,11 +114,9 @@ abstract class AbstractPage implements IPage, ITrackablePage { EventHandler::getInstance()->fireAction($this, 'checkModules'); // check modules - if (count($this->neededModules)) { - foreach ($this->neededModules as $module) { - if (!defined($module) || !constant($module)) { - throw new IllegalLinkException(); - } + foreach ($this->neededModules as $module) { + if (!defined($module) || !constant($module)) { + throw new IllegalLinkException(); } } } diff --git a/wcfsetup/install/files/lib/system/WCF.class.php b/wcfsetup/install/files/lib/system/WCF.class.php index 66fa36581f..f254ecd547 100644 --- a/wcfsetup/install/files/lib/system/WCF.class.php +++ b/wcfsetup/install/files/lib/system/WCF.class.php @@ -154,19 +154,19 @@ class WCF { protected function initMagicQuotes() { if (function_exists('get_magic_quotes_gpc')) { if (@get_magic_quotes_gpc()) { - if (count($_REQUEST)) { + if (!empty($_REQUEST)) { $_REQUEST = util\ArrayUtil::stripslashes($_REQUEST); } - if (count($_POST)) { + if (!empty($_POST)) { $_POST = util\ArrayUtil::stripslashes($_POST); } - if (count($_GET)) { + if (!empty($_GET)) { $_GET = util\ArrayUtil::stripslashes($_GET); } - if (count($_COOKIE)) { + if (!empty($_COOKIE)) { $_COOKIE = util\ArrayUtil::stripslashes($_COOKIE); } - if (count($_FILES)) { + if (!empty($_FILES)) { foreach ($_FILES as $name => $attributes) { foreach ($attributes as $key => $value) { if ($key != 'tmp_name') { diff --git a/wcfsetup/install/files/lib/system/WCFSetup.class.php b/wcfsetup/install/files/lib/system/WCFSetup.class.php index e027ba09e0..ee8f057392 100644 --- a/wcfsetup/install/files/lib/system/WCFSetup.class.php +++ b/wcfsetup/install/files/lib/system/WCFSetup.class.php @@ -373,7 +373,7 @@ class WCFSetup extends WCF { // sql $system['sql']['value'] = array_keys(self::getAvailableDBClasses()); - $system['sql']['result'] = count($system['sql']['value']) > 0; + $system['sql']['result'] = !empty($system['sql']['value']); // upload_max_filesize $system['uploadMaxFilesize']['value'] = ini_get('upload_max_filesize'); @@ -493,7 +493,7 @@ class WCFSetup extends WCF { if (isset($_POST['send'])) { try { // no languages selected - if (count(self::$selectedLanguages) == 0) { + if (empty(self::$selectedLanguages)) { throw new UserInputException('selectedLanguages'); } @@ -696,7 +696,7 @@ class WCFSetup extends WCF { // log sql queries preg_match_all("~CREATE\s+TABLE\s+(\w+)~i", $sql, $matches); - if (count($matches[1])) { + if (!empty($matches[1])) { $sql = "INSERT INTO wcf".WCF_N."_package_installation_sql_log (sqlTable) VALUES (?)"; @@ -829,7 +829,7 @@ class WCFSetup extends WCF { $languages[] = $row['languageID']; } - if (count($languages) > 0) { + if (!empty($languages)) { $sql = "INSERT INTO wcf".WCF_N."_language_to_package (languageID) VALUES (?)"; diff --git a/wcfsetup/install/files/lib/system/cache/builder/ACPMenuCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/ACPMenuCacheBuilder.class.php index 6fe33e3757..08477cdf64 100644 --- a/wcfsetup/install/files/lib/system/cache/builder/ACPMenuCacheBuilder.class.php +++ b/wcfsetup/install/files/lib/system/cache/builder/ACPMenuCacheBuilder.class.php @@ -38,7 +38,7 @@ class ACPMenuCacheBuilder implements ICacheBuilder { $itemIDs[$row['menuItem']] = $row['menuItemID']; } - if (count($itemIDs) > 0) { + if (!empty($itemIDs)) { $conditions = new PreparedStatementConditionBuilder(); $conditions->add("menuItemID IN (?)", array($itemIDs)); @@ -63,7 +63,7 @@ class ACPMenuCacheBuilder implements ICacheBuilder { // get top option categories $optionCategories = $this->getTopOptionCategories($packageID); - if (count($optionCategories) > 0) { + if (!empty($optionCategories)) { if (!isset($data['wcf.acp.menu.link.option.category'])) { $data['wcf.acp.menu.link.option.category'] = array(); } diff --git a/wcfsetup/install/files/lib/system/cache/builder/OptionCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/OptionCacheBuilder.class.php index caec5d0482..cf76d1852c 100644 --- a/wcfsetup/install/files/lib/system/cache/builder/OptionCacheBuilder.class.php +++ b/wcfsetup/install/files/lib/system/cache/builder/OptionCacheBuilder.class.php @@ -60,7 +60,7 @@ class OptionCacheBuilder implements ICacheBuilder { $optionCategories[$row['categoryName']] = $row['categoryID']; } - if (count($optionCategories) > 0) { + if (!empty($optionCategories) > 0) { // get needed option categories $conditions = new PreparedStatementConditionBuilder(); $conditions->add("categoryID IN (?)", array($optionCategories)); @@ -98,7 +98,7 @@ class OptionCacheBuilder implements ICacheBuilder { $optionIDs[$row['optionName']] = $row['optionID']; } - if (count($optionIDs) > 0) { + if (!empty($optionIDs)) { // get option class from type $className = 'wcf\data\option\Option'; if (!empty($type)) { diff --git a/wcfsetup/install/files/lib/system/cache/builder/PageMenuCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/PageMenuCacheBuilder.class.php index 21cc619781..ae1936c3a1 100644 --- a/wcfsetup/install/files/lib/system/cache/builder/PageMenuCacheBuilder.class.php +++ b/wcfsetup/install/files/lib/system/cache/builder/PageMenuCacheBuilder.class.php @@ -36,7 +36,7 @@ class PageMenuCacheBuilder implements ICacheBuilder { $itemIDs[$row['menuItem']] = $row['menuItemID']; } - if (count($itemIDs) > 0) { + if (!empty($itemIDs)) { // get needed menu items and build item tree $conditions = new PreparedStatementConditionBuilder(); $conditions->add("menu_item.menuItemID IN (?)", array($itemIDs)); diff --git a/wcfsetup/install/files/lib/system/cache/builder/UserGroupPermissionCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/UserGroupPermissionCacheBuilder.class.php index 55291229a4..ac6d4db0e5 100644 --- a/wcfsetup/install/files/lib/system/cache/builder/UserGroupPermissionCacheBuilder.class.php +++ b/wcfsetup/install/files/lib/system/cache/builder/UserGroupPermissionCacheBuilder.class.php @@ -55,7 +55,7 @@ class UserGroupPermissionCacheBuilder implements ICacheBuilder { $options[$row['optionName']] = $row['optionID']; } - if (count($options) > 0) { + if (!empty($options)) { // get needed options $conditions = new PreparedStatementConditionBuilder(); $conditions->add("option_value.groupID IN (?)", array(explode(',', $groupIDs))); diff --git a/wcfsetup/install/files/lib/system/cache/source/MemcacheCacheSource.class.php b/wcfsetup/install/files/lib/system/cache/source/MemcacheCacheSource.class.php index 3c60ecc396..77dd2f0a30 100644 --- a/wcfsetup/install/files/lib/system/cache/source/MemcacheCacheSource.class.php +++ b/wcfsetup/install/files/lib/system/cache/source/MemcacheCacheSource.class.php @@ -75,7 +75,7 @@ class MemcacheCacheSource implements ICacheSource { * Saves modifications of the cache log. */ protected function updateLog() { - if (count($this->newLogEntries)) { + if (!empty($this->newLogEntries)) { $sql = "DELETE FROM wcf".WCF_N."_cache_resource WHERE cacheResource = ?"; $statement = WCF::getDB()->prepareStatement($sql); @@ -92,7 +92,8 @@ class MemcacheCacheSource implements ICacheSource { } } - if (count($this->obsoleteLogEntries)) { + + if (!empty($this->obsoleteLogEntries)) { $sql = "DELETE FROM wcf".WCF_N."_cache_resource WHERE cacheResource = ?"; $statement = WCF::getDB()->prepareStatement($sql); diff --git a/wcfsetup/install/files/lib/system/cleanup/CleanupHandler.class.php b/wcfsetup/install/files/lib/system/cleanup/CleanupHandler.class.php index 1e5a88a6c6..9177758a3f 100644 --- a/wcfsetup/install/files/lib/system/cleanup/CleanupHandler.class.php +++ b/wcfsetup/install/files/lib/system/cleanup/CleanupHandler.class.php @@ -87,7 +87,7 @@ class CleanupHandler { $objectIDs[] = $row['objectID']; } - if (count($objectIDs)) { + if (!empty($objectIDs)) { $this->executeAdapters($adapters, $objectIDs); } } diff --git a/wcfsetup/install/files/lib/system/clipboard/ClipboardHandler.class.php b/wcfsetup/install/files/lib/system/clipboard/ClipboardHandler.class.php index 1f93e17ed2..8f9e7499b4 100644 --- a/wcfsetup/install/files/lib/system/clipboard/ClipboardHandler.class.php +++ b/wcfsetup/install/files/lib/system/clipboard/ClipboardHandler.class.php @@ -227,7 +227,7 @@ class ClipboardHandler extends SingletonFactory { // get objects $this->loadMarkedItems(); - if (!count($this->markedItems)) return null; + if (empty($this->markedItems)) return null; // fetch action ids $this->loadActionCache(); diff --git a/wcfsetup/install/files/lib/system/clipboard/action/UserClipboardAction.class.php b/wcfsetup/install/files/lib/system/clipboard/action/UserClipboardAction.class.php index a99734a75f..1057060b85 100644 --- a/wcfsetup/install/files/lib/system/clipboard/action/UserClipboardAction.class.php +++ b/wcfsetup/install/files/lib/system/clipboard/action/UserClipboardAction.class.php @@ -40,7 +40,7 @@ class UserClipboardAction implements IClipboardAction { case 'delete': $userIDs = $this->validateDelete($objects); - if (!count($userIDs)) { + if (empty($userIDs)) { return null; } @@ -98,7 +98,7 @@ class UserClipboardAction implements IClipboardAction { } // no valid users found - if (!count($userIDs)) return array(); + if (empty($userIDs)) return array(); // fetch user to group associations $conditions = new PreparedStatementConditionBuilder(); diff --git a/wcfsetup/install/files/lib/system/cronjob/RefreshSearchRobotsCronjob.class.php b/wcfsetup/install/files/lib/system/cronjob/RefreshSearchRobotsCronjob.class.php index 464fbd364f..59523acb65 100644 --- a/wcfsetup/install/files/lib/system/cronjob/RefreshSearchRobotsCronjob.class.php +++ b/wcfsetup/install/files/lib/system/cronjob/RefreshSearchRobotsCronjob.class.php @@ -31,9 +31,9 @@ class RefreshSearchRobotsCronjob implements ICronjob { $xpath = $xml->xpath(); // fetch spiders - $spiders = $xpath->query('/spiderlist/spider'); + $spiders = $xpath->query('/spiderlist/spider'); - if (count($spiders)) { + if (!empty($spiders)) { // delete old entries $sql = "DELETE FROM wcf".WCF_N."_spider"; $statement = WCF::getDB()->prepareStatement($sql); diff --git a/wcfsetup/install/files/lib/system/database/statement/PreparedStatement.class.php b/wcfsetup/install/files/lib/system/database/statement/PreparedStatement.class.php index 38f7f647de..d84959fb37 100644 --- a/wcfsetup/install/files/lib/system/database/statement/PreparedStatement.class.php +++ b/wcfsetup/install/files/lib/system/database/statement/PreparedStatement.class.php @@ -88,7 +88,7 @@ class PreparedStatement { try { if (WCF::benchmarkIsEnabled()) Benchmark::getInstance()->start($this->query, Benchmark::TYPE_SQL_QUERY); - if (!count($parameters)) $this->pdoStatement->execute(); + if (empty($parameters)) $this->pdoStatement->execute(); else $this->pdoStatement->execute($parameters); if (WCF::benchmarkIsEnabled()) Benchmark::getInstance()->stop(); @@ -113,7 +113,7 @@ class PreparedStatement { try { if (WCF::benchmarkIsEnabled()) Benchmark::getInstance()->start($this->query, Benchmark::TYPE_SQL_QUERY); - if (!count($parameters)) $this->pdoStatement->execute(); + if (empty($parameters)) $this->pdoStatement->execute(); else $this->pdoStatement->execute($parameters); if (WCF::benchmarkIsEnabled()) Benchmark::getInstance()->stop(); diff --git a/wcfsetup/install/files/lib/system/database/util/PreparedStatementConditionBuilder.class.php b/wcfsetup/install/files/lib/system/database/util/PreparedStatementConditionBuilder.class.php index b3b79c3dc7..13a38352b5 100644 --- a/wcfsetup/install/files/lib/system/database/util/PreparedStatementConditionBuilder.class.php +++ b/wcfsetup/install/files/lib/system/database/util/PreparedStatementConditionBuilder.class.php @@ -32,9 +32,9 @@ class PreparedStatementConditionBuilder extends ConditionBuilder { if (!array_key_exists($count, $parameters)) { throw new SystemException("missing parameter for token number " . ($count + 1) . " in condition '".$condition."'"); } - + $result = '?'; - if (is_array($parameters[$count]) && count($parameters[$count])) { + if (is_array($parameters[$count]) && !empty($parameters[$count])) { $result .= str_repeat(',?', count($parameters[$count]) - 1); } diff --git a/wcfsetup/install/files/lib/system/event/EventHandler.class.php b/wcfsetup/install/files/lib/system/event/EventHandler.class.php index ba5732a701..f699ea3c13 100644 --- a/wcfsetup/install/files/lib/system/event/EventHandler.class.php +++ b/wcfsetup/install/files/lib/system/event/EventHandler.class.php @@ -99,7 +99,7 @@ class EventHandler extends SingletonFactory { foreach ($familyTree as $member) { if (isset($this->inheritedActions[$member])) { $actions = $this->inheritedActions[$member]; - if (isset($actions[$eventName]) && count($actions[$eventName]) > 0) { + if (isset($actions[$eventName]) && !empty($actions[$eventName])) { foreach ($actions[$eventName] as $action) { if (isset($this->inheritedActionsObjects[$name][$action['listenerClassName']])) continue; @@ -154,7 +154,7 @@ class EventHandler extends SingletonFactory { $name = self::generateKey($className, $eventName); // execute inherited actions first - if (count($this->inheritedActions) > 0) { + if (!empty($this->inheritedActions)) { $this->executeInheritedActions($eventObj, $eventName, $className, $name); } diff --git a/wcfsetup/install/files/lib/system/io/File.class.php b/wcfsetup/install/files/lib/system/io/File.class.php index 325badc470..ff2d823ac3 100644 --- a/wcfsetup/install/files/lib/system/io/File.class.php +++ b/wcfsetup/install/files/lib/system/io/File.class.php @@ -45,7 +45,7 @@ class File { */ public function __construct($filename, $mode = 'wb', $options = array()) { $this->filename = $filename; - if (count($options)) { + if (!empty($options)) { $context = stream_context_create($options); $this->resource = fopen($filename, $mode, false, $context); } diff --git a/wcfsetup/install/files/lib/system/io/TarWriter.class.php b/wcfsetup/install/files/lib/system/io/TarWriter.class.php index edd053b3fd..773f61782e 100644 --- a/wcfsetup/install/files/lib/system/io/TarWriter.class.php +++ b/wcfsetup/install/files/lib/system/io/TarWriter.class.php @@ -88,7 +88,7 @@ class TarWriter extends Tar { */ public function add($files, $addDir = '', $removeDir = '') { if (!is_array($files)) $files = array($files); - if (!count($files)) return false; + if (empty($files)) return false; $result = true; diff --git a/wcfsetup/install/files/lib/system/language/I18nHandler.class.php b/wcfsetup/install/files/lib/system/language/I18nHandler.class.php index 826a0f1a89..07f61d82ef 100644 --- a/wcfsetup/install/files/lib/system/language/I18nHandler.class.php +++ b/wcfsetup/install/files/lib/system/language/I18nHandler.class.php @@ -196,7 +196,7 @@ class I18nHandler extends SingletonFactory { * @throws SystemException if $i18nValues doesn't have any elements */ public function setValues($elementID, array $i18nValues) { - if (!count($i18nValues)) { + if (empty($i18nValues)) { throw new SystemException('Invalid argument for parameter $i18nValues', 0, 'Expected filled array as second argument. Empty array given.'); } if (!$this->isPlainValue($elementID)) { @@ -293,7 +293,7 @@ class I18nHandler extends SingletonFactory { } // insert language items - if (count($insertLanguageIDs)) { + if (!empty($insertLanguageIDs)) { $sql = "INSERT INTO wcf".WCF_N."_language_item (languageID, languageItem, languageItemValue, languageItemOriginIsSystem, languageCategoryID, packageID) VALUES (?, ?, ?, ?, ?, ?)"; @@ -312,7 +312,7 @@ class I18nHandler extends SingletonFactory { } // update language items - if (count($updateLanguageIDs)) { + if (!empty($updateLanguageIDs)) { $sql = "UPDATE wcf".WCF_N."_language_item SET languageItemValue = ? WHERE languageItemID = ?"; diff --git a/wcfsetup/install/files/lib/system/language/LanguageFactory.class.php b/wcfsetup/install/files/lib/system/language/LanguageFactory.class.php index e1ab76055b..2980add985 100644 --- a/wcfsetup/install/files/lib/system/language/LanguageFactory.class.php +++ b/wcfsetup/install/files/lib/system/language/LanguageFactory.class.php @@ -87,7 +87,7 @@ class LanguageFactory extends SingletonFactory { */ public function getLanguageByCode($languageCode) { // called within WCFSetup - if ($this->cache === false || !count($this->cache['codes'])) { + if ($this->cache === false || empty($this->cache['codes'])) { $sql = "SELECT languageID FROM wcf".WCF_N."_language WHERE languageCode = ?"; diff --git a/wcfsetup/install/files/lib/system/language/LanguageServerProcessor.class.php b/wcfsetup/install/files/lib/system/language/LanguageServerProcessor.class.php index 7c8a75c141..65fa2a5df1 100644 --- a/wcfsetup/install/files/lib/system/language/LanguageServerProcessor.class.php +++ b/wcfsetup/install/files/lib/system/language/LanguageServerProcessor.class.php @@ -32,7 +32,7 @@ class LanguageServerProcessor extends SingletonFactory { * @param array $languageServers */ public function import(Language $language, array $languageServers) { - if (!count($languageServers)) return; + if (empty($languageServers)) return; $this->language = $language; // get package list @@ -202,7 +202,7 @@ class LanguageServerProcessor extends SingletonFactory { } // ignore variables if no package is known - if (!count($packages)) return; + if (empty($packages)) return; $this->importVariables($variables, $packages); } @@ -256,7 +256,7 @@ class LanguageServerProcessor extends SingletonFactory { } // create items - if (count($createItems)) { + if (!empty($createItems)) { $sql = "INSERT INTO wcf".WCF_N."_language_item (languageID, languageItem, languageItemValue, languageItemOriginIsSystem, languageCategoryID, packageID) VALUES (?, ?, ?, ?, ?, ?)"; @@ -275,7 +275,7 @@ class LanguageServerProcessor extends SingletonFactory { } // update items - if (count($updateItems)) { + if (!empty($updateItems)) { $sql = "UPDATE wcf".WCF_N."_language_item SET languageItemValue = ? WHERE languageItemID = ?"; @@ -317,7 +317,7 @@ class LanguageServerProcessor extends SingletonFactory { // create non-existing categories $createCategories = array_diff($categoryNames, array_keys($existingCategories)); - if (count($createCategories)) { + if (!empty($createCategories)) { // use raw queries for better performance $sql = "INSERT INTO wcf".WCF_N."_language_category (languageCategory) diff --git a/wcfsetup/install/files/lib/system/mail/Mail.class.php b/wcfsetup/install/files/lib/system/mail/Mail.class.php index 755960f86f..9cdc0e4774 100644 --- a/wcfsetup/install/files/lib/system/mail/Mail.class.php +++ b/wcfsetup/install/files/lib/system/mail/Mail.class.php @@ -58,7 +58,7 @@ class Mail { if (!empty($cc)) $this->addCC($cc); if (!empty($bcc)) $this->addBCC($bcc); - if (count($attachments) > 0) $this->setAttachments($attachments); + if (!empty($attachments)) $this->setAttachments($attachments); } /** diff --git a/wcfsetup/install/files/lib/system/mail/SMTPMailSender.class.php b/wcfsetup/install/files/lib/system/mail/SMTPMailSender.class.php index 64d96b5568..b1e4c977fb 100644 --- a/wcfsetup/install/files/lib/system/mail/SMTPMailSender.class.php +++ b/wcfsetup/install/files/lib/system/mail/SMTPMailSender.class.php @@ -105,9 +105,9 @@ class SMTPMailSender extends MailSender { */ public function sendMail(Mail $mail) { $this->recipients = array(); - if (count($mail->getTo()) > 0) $this->recipients = $mail->getTo(); - if (count($mail->getCC()) > 0) $this->recipients = array_merge($this->recipients, $mail->getCC()); - if (count($mail->getBCC())> 0) $this->recipients = array_merge($this->recipients, $mail->getBCC()); + if (count($mail->getTo()) > 0) $this->recipients = $mail->getTo(); + if (count($mail->getCC()) > 0) $this->recipients = array_merge($this->recipients, $mail->getCC()); + if (count($mail->getBCC())> 0) $this->recipients = array_merge($this->recipients, $mail->getBCC()); // apply connection if ($this->connection === null) { diff --git a/wcfsetup/install/files/lib/system/menu/TreeMenu.class.php b/wcfsetup/install/files/lib/system/menu/TreeMenu.class.php index 5178f51d74..4cf8d963d2 100644 --- a/wcfsetup/install/files/lib/system/menu/TreeMenu.class.php +++ b/wcfsetup/install/files/lib/system/menu/TreeMenu.class.php @@ -131,7 +131,7 @@ abstract class TreeMenu extends SingletonFactory { foreach ($this->menuItems[$parentMenuItem] as $key => $item) { $this->removeEmptyItems($item->menuItem); - if (empty($item->menuItemLink) && (!isset($this->menuItems[$item->menuItem]) || !count($this->menuItems[$item->menuItem]))) { + if (empty($item->menuItemLink) && (!isset($this->menuItems[$item->menuItem]) || empty($this->menuItems[$item->menuItem]))) { // remove this item unset($this->menuItems[$parentMenuItem][$key]); } diff --git a/wcfsetup/install/files/lib/system/option/MultiSelectOptionType.class.php b/wcfsetup/install/files/lib/system/option/MultiSelectOptionType.class.php index cf3af34a81..fd41488fcb 100644 --- a/wcfsetup/install/files/lib/system/option/MultiSelectOptionType.class.php +++ b/wcfsetup/install/files/lib/system/option/MultiSelectOptionType.class.php @@ -55,9 +55,9 @@ class MultiSelectOptionType extends SelectOptionType { * @see wcf\system\option\ISearchableUserOption::getCondition() */ public function getCondition(PreparedStatementConditionBuilder &$conditions, Option $option, $value) { - if (!is_array($value) || !count($value)) return false; + if (!is_array($value) || empty($value)) return false; $value = ArrayUtil::trim($value); - if (!count($value)) return false; + if (empty($value)) return false; $conditions->add("option_value.userOption".$option->optionID." = ?", array(implode("\n", $value))); return true; diff --git a/wcfsetup/install/files/lib/system/option/TextI18nOptionType.class.php b/wcfsetup/install/files/lib/system/option/TextI18nOptionType.class.php index 36483812fd..107b153058 100644 --- a/wcfsetup/install/files/lib/system/option/TextI18nOptionType.class.php +++ b/wcfsetup/install/files/lib/system/option/TextI18nOptionType.class.php @@ -26,8 +26,7 @@ class TextI18nOptionType extends TextOptionType { * @see wcf\system\option\IOptionType::getFormElement() */ public function getFormElement(Option $option, $value) { - $useRequestData = (count($_POST)) ? true : false; - I18nHandler::getInstance()->assignVariables($useRequestData); + I18nHandler::getInstance()->assignVariables(!empty($_POST)); WCF::getTPL()->assign(array( 'option' => $option, diff --git a/wcfsetup/install/files/lib/system/option/TextareaI18nOptionType.class.php b/wcfsetup/install/files/lib/system/option/TextareaI18nOptionType.class.php index ac73f751c1..d2e0f2825c 100644 --- a/wcfsetup/install/files/lib/system/option/TextareaI18nOptionType.class.php +++ b/wcfsetup/install/files/lib/system/option/TextareaI18nOptionType.class.php @@ -26,8 +26,7 @@ class TextareaI18nOptionType extends TextareaOptionType { * @see wcf\system\option\IOptionType::getFormElement() */ public function getFormElement(Option $option, $value) { - $useRequestData = (count($_POST)) ? true : false; - I18nHandler::getInstance()->assignVariables($useRequestData); + I18nHandler::getInstance()->assignVariables(!empty($_POST)); WCF::getTPL()->assign(array( 'option' => $option, diff --git a/wcfsetup/install/files/lib/system/package/ACPTemplatesFileHandler.class.php b/wcfsetup/install/files/lib/system/package/ACPTemplatesFileHandler.class.php index 43eda0d62c..de522599ec 100644 --- a/wcfsetup/install/files/lib/system/package/ACPTemplatesFileHandler.class.php +++ b/wcfsetup/install/files/lib/system/package/ACPTemplatesFileHandler.class.php @@ -56,7 +56,7 @@ class ACPTemplatesFileHandler extends PackageInstallationFileHandler { } // check if files from installing package are in conflict with already installed files - if (!$this->packageInstallation->getPackage()->isApplication && count($lockedFiles) > 0) { + if (!$this->packageInstallation->getPackage()->isApplication && !empty($lockedFiles)) { foreach ($fileNames as $key => $file) { if (isset($lockedFiles[$file]) && $packageID != $lockedFiles[$file]) { $owningPackage = new Package($lockedFiles[$file]); @@ -95,7 +95,7 @@ class ACPTemplatesFileHandler extends PackageInstallationFileHandler { } } - if (count($files)) { + if (!empty($files)) { $sql = "INSERT INTO wcf".WCF_N."_".$this->tableName." (packageID, templateName) VALUES (?, ?)"; diff --git a/wcfsetup/install/files/lib/system/package/FilesFileHandler.class.php b/wcfsetup/install/files/lib/system/package/FilesFileHandler.class.php index d7bd21c083..6bf1a51cb1 100644 --- a/wcfsetup/install/files/lib/system/package/FilesFileHandler.class.php +++ b/wcfsetup/install/files/lib/system/package/FilesFileHandler.class.php @@ -38,7 +38,7 @@ class FilesFileHandler extends PackageInstallationFileHandler { } // check delivered files - if (count($lockedFiles) > 0) { + if (!empty($lockedFiles)) { $dir = $this->packageInstallation->getPackage()->packageDir; foreach ($files as $key => $file) { if (isset($lockedFiles[$dir.$file])) { diff --git a/wcfsetup/install/files/lib/system/package/PackageArchive.class.php b/wcfsetup/install/files/lib/system/package/PackageArchive.class.php index 7572833851..a0111a54b2 100644 --- a/wcfsetup/install/files/lib/system/package/PackageArchive.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageArchive.class.php @@ -824,7 +824,7 @@ class PackageArchive { */ public function getConflictedExcludedPackages() { $conflictedPackages = array(); - if (count($this->excludedPackages) > 0) { + if (!empty($this->excludedPackages)) { $conditions = new PreparedStatementConditionBuilder(); $conditions->add("package IN (?)", array(array_keys($this->excludedPackages))); diff --git a/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php b/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php index f79c9eb024..6b95d8ae81 100644 --- a/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php @@ -240,23 +240,25 @@ class PackageInstallationDispatcher { // if package is plugin to com.woltlab.wcf it must not have any other requirement $requirements = $this->getArchive()->getRequirements(); - if ($package->parentPackageID == 1 && count($requirements)) { - foreach ($requirements as $package => $data) { - if ($package == 'com.woltlab.wcf') continue; - throw new SystemException('Package '.$package->package.' is plugin of com.woltlab.wcf (WCF) but has more than one requirement.'); - } + if ($package->parentPackageID == 1 && !empty($requirements)) { + foreach ($requirements as $package => $data) { + if ($package == 'com.woltlab.wcf') continue; + throw new SystemException('Package '.$package->package.' is plugin of com.woltlab.wcf (WCF) but has more than one requirement.'); + } } // insert requirements and dependencies $requirements = $this->getArchive()->getAllExistingRequirements(); - if (count($requirements) > 0) { + if (!empty($requirements)) { $sql = "INSERT INTO wcf".WCF_N."_package_requirement (packageID, requirement) VALUES (?, ?)"; $statement = WCF::getDB()->prepareStatement($sql); foreach ($requirements as $identifier => $possibleRequirements) { - if (count($possibleRequirements) == 1) $requirement = array_shift($possibleRequirements); + if (count($possibleRequirements) == 1) { + $requirement = array_shift($possibleRequirements); + } else { $requirement = $possibleRequirements[$this->selectedRequirements[$identifier]]; } diff --git a/wcfsetup/install/files/lib/system/package/PackageInstallationNodeBuilder.class.php b/wcfsetup/install/files/lib/system/package/PackageInstallationNodeBuilder.class.php index 9c018a9abc..f15a8876ab 100644 --- a/wcfsetup/install/files/lib/system/package/PackageInstallationNodeBuilder.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageInstallationNodeBuilder.class.php @@ -511,11 +511,12 @@ class PackageInstallationNodeBuilder { } // insert nodes - if (count($pluginNodes) > 0) { + if (!empty($pluginNodes)) { $sql = "INSERT INTO wcf".WCF_N."_package_installation_node (queueID, processNo, sequenceNo, node, parentNode, nodeType, nodeData) VALUES (?, ?, ?, ?, ?, ?, ?)"; $statement = WCF::getDB()->prepareStatement($sql); + foreach ($pluginNodes as $index => $nodeData) { $statement->execute(array( $this->installation->queue->queueID, diff --git a/wcfsetup/install/files/lib/system/package/PackageInstallationSQLParser.class.php b/wcfsetup/install/files/lib/system/package/PackageInstallationSQLParser.class.php index 807c8c1ead..47039fb72d 100644 --- a/wcfsetup/install/files/lib/system/package/PackageInstallationSQLParser.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageInstallationSQLParser.class.php @@ -143,7 +143,7 @@ class PackageInstallationSQLParser extends SQLParser { } // columns - if (count($this->columnLog)) { + if (!empty($this->columnLog)) { $sql = "DELETE FROM wcf".WCF_N."_package_installation_sql_log WHERE sqlTable = ? AND sqlColumn = ?"; @@ -171,7 +171,7 @@ class PackageInstallationSQLParser extends SQLParser { } // indices - if (count($this->indexLog)) { + if (!empty($this->indexLog)) { $sql = "DELETE FROM wcf".WCF_N."_package_installation_sql_log WHERE sqlTable = ? AND sqlIndex = ?"; diff --git a/wcfsetup/install/files/lib/system/package/PackageInstallationScheduler.class.php b/wcfsetup/install/files/lib/system/package/PackageInstallationScheduler.class.php index 7610ed3d45..5dc63dce77 100644 --- a/wcfsetup/install/files/lib/system/package/PackageInstallationScheduler.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageInstallationScheduler.class.php @@ -265,11 +265,11 @@ class PackageInstallationScheduler { } } - if (count($authorizationRequiredException)) { + if (!empty($authorizationRequiredException)) { throw array_shift($authorizationRequiredException); } - if (count($systemExceptions)) { + if (!empty($systemExceptions)) { throw array_shift($systemExceptions); } @@ -284,7 +284,7 @@ class PackageInstallationScheduler { public function getExcludedPackages() { $excludedPackages = array(); - if (count($this->packageInstallationStack)) { + if (!empty($this->packageInstallationStack)) { $packageInstallations = array(); $packageIdentifier = array(); foreach ($this->packageInstallationStack as $packageInstallation) { @@ -292,7 +292,7 @@ class PackageInstallationScheduler { $packageInstallations[] = $packageInstallation; $packageIdentifier[] = $packageInstallation['package']; } - + // check exclusions of the new packages // get package update ids $conditions = new PreparedStatementConditionBuilder(); diff --git a/wcfsetup/install/files/lib/system/package/PackageUpdateDispatcher.class.php b/wcfsetup/install/files/lib/system/package/PackageUpdateDispatcher.class.php index 04de4848e4..b534c790be 100644 --- a/wcfsetup/install/files/lib/system/package/PackageUpdateDispatcher.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageUpdateDispatcher.class.php @@ -75,7 +75,7 @@ abstract class PackageUpdateDispatcher { unset($response); // save packages - if (count($allNewPackages)) { + if (!empty($allNewPackages)) { self::savePackageUpdates($allNewPackages, $updateServer->packageUpdateServerID); } unset($allNewPackages); @@ -362,7 +362,7 @@ abstract class PackageUpdateDispatcher { // get existing versions $existingPackageVersions = array(); - if (count($existingPackages) > 0) { + if (!empty($existingPackages)) { // get package update ids $packageUpdateIDs = array(); foreach ($existingPackages as $packageUpdate) { @@ -720,7 +720,7 @@ abstract class PackageUpdateDispatcher { $versions[] = $row; } - if (!count($versions)) { + if (empty($versions)) { throw new SystemException("Can not find package '".$package."' in version '".$version."'"); } diff --git a/wcfsetup/install/files/lib/system/package/plugin/ACPTemplatePackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/ACPTemplatePackageInstallationPlugin.class.php index a5311df869..d398f1d26f 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/ACPTemplatePackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/ACPTemplatePackageInstallationPlugin.class.php @@ -69,7 +69,7 @@ class ACPTemplatePackageInstallationPlugin extends AbstractPackageInstallationPl $templates[] = 'acp/templates/'.$row['templateName'].'.tpl'; } - if (count($templates) > 0) { + if (!empty($templates)) { // delete template files $packageDir = FileUtil::addTrailingSlash(FileUtil::getRealPath(WCF_DIR.$this->installation->getPackage()->packageDir)); $deleteEmptyDirectories = $this->installation->getPackage()->isApplication; diff --git a/wcfsetup/install/files/lib/system/package/plugin/AbstractOptionPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/AbstractOptionPackageInstallationPlugin.class.php index 0a1e7c6614..3323b527a4 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/AbstractOptionPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/AbstractOptionPackageInstallationPlugin.class.php @@ -48,7 +48,7 @@ abstract class AbstractOptionPackageInstallationPlugin extends AbstractXMLPackag $options[] = $element->getAttribute('name'); } - if (count($options)) { + if (!empty($options)) { $sql = "DELETE FROM wcf".WCF_N."_".$this->tableName." WHERE optionName = ? AND packageID = ?"; @@ -69,7 +69,7 @@ abstract class AbstractOptionPackageInstallationPlugin extends AbstractXMLPackag $categories[] = $element->getAttribute('name'); } - if (count($categories)) { + if (!empty($categories)) { // delete options for given categories $sql = "DELETE FROM wcf".WCF_N."_".$this->tableName." WHERE categoryName = ?"; diff --git a/wcfsetup/install/files/lib/system/package/plugin/ClipboardActionPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/ClipboardActionPackageInstallationPlugin.class.php index 326b33f259..3732e03c75 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/ClipboardActionPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/ClipboardActionPackageInstallationPlugin.class.php @@ -127,7 +127,7 @@ class ClipboardActionPackageInstallationPlugin extends AbstractXMLPackageInstall $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(array($this->installation->getPackageID())); - if (count($this->pages)) { + if (!empty($this->pages)) { // insert pages $sql = "INSERT INTO wcf".WCF_N."_clipboard_page (pageClassName, packageID, actionID) diff --git a/wcfsetup/install/files/lib/system/package/plugin/FilePackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/FilePackageInstallationPlugin.class.php index 83ed31befd..93042a7063 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/FilePackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/FilePackageInstallationPlugin.class.php @@ -109,7 +109,7 @@ class FilePackageInstallationPlugin extends AbstractPackageInstallationPlugin { $files[] = $row['filename']; } - if (count($files) > 0) { + if (!empty($files)) { // delete files $this->installation->deleteFiles($packageDir, $files); diff --git a/wcfsetup/install/files/lib/system/package/plugin/LanguagePackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/LanguagePackageInstallationPlugin.class.php index a4a4622b25..4375e11731 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/LanguagePackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/LanguagePackageInstallationPlugin.class.php @@ -135,7 +135,7 @@ class LanguagePackageInstallationPlugin extends AbstractXMLPackageInstallationPl } // save package to language - if (count($addedLanguageIDArray)) { + if (!empty($addedLanguageIDArray)) { $condition = ''; $statementParameters = array($this->installation->getPackageID()); foreach ($addedLanguageIDArray as $languageID) { @@ -206,7 +206,7 @@ class LanguagePackageInstallationPlugin extends AbstractXMLPackageInstallationPl $categoryIDs[$row['languageCategoryID']] = true; } - if (count($itemIDs) > 0) { + if (!empty($itemIDs)) { $sql = "DELETE FROM wcf".WCF_N."_".$this->tableName." WHERE languageItemID = ? AND packageID = ?"; @@ -273,7 +273,7 @@ class LanguagePackageInstallationPlugin extends AbstractXMLPackageInstallationPl } // Delete categories from DB. - if (count($categoriesToDelete) > 0) { + if (!empty($categoriesToDelete)) { $sql = "DELETE FROM wcf".WCF_N."_language_category WHERE languageCategory = ?"; $statement = WCF::getDB()->prepareStatement($sql); diff --git a/wcfsetup/install/files/lib/system/package/plugin/StylePackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/StylePackageInstallationPlugin.class.php index 90ba02310b..de5bec8f87 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/StylePackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/StylePackageInstallationPlugin.class.php @@ -70,7 +70,7 @@ class StylePackageInstallationPlugin extends AbstractPackageInstallationPlugin { $styleList->readObjects(); $styles = $styleList->getObjects(); - if (count($styles)) { + if (!empty($styles)) { $styleEditor = new StyleEditor($styles[0]); $styleEditor->setAsDefault(); } diff --git a/wcfsetup/install/files/lib/system/package/plugin/TemplatePackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/TemplatePackageInstallationPlugin.class.php index da569be192..f844490ace 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/TemplatePackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/TemplatePackageInstallationPlugin.class.php @@ -58,7 +58,7 @@ class TemplatePackageInstallationPlugin extends AbstractPackageInstallationPlugi $templates[] = 'templates/'.$row['templateName'].'.tpl'; } - if (count($templates) > 0) { + if (!empty($templates)) { // delete template files $packageDir = FileUtil::addTrailingSlash(FileUtil::getRealPath(WCF_DIR.$this->installation->getPackage()->packageDir)); $deleteEmptyDirectories = $this->installation->getPackage()->isApplication; diff --git a/wcfsetup/install/files/lib/system/session/SessionHandler.class.php b/wcfsetup/install/files/lib/system/session/SessionHandler.class.php index 43441324e8..204a9d040d 100644 --- a/wcfsetup/install/files/lib/system/session/SessionHandler.class.php +++ b/wcfsetup/install/files/lib/system/session/SessionHandler.class.php @@ -565,7 +565,7 @@ class SessionHandler extends SingletonFactory { * @param array $userIDs */ public static function resetSessions(array $userIDs = array()) { - if (count($userIDs)) { + if (!empty($userIDs)) { UserStorageHandler::getInstance()->reset($userIDs, 'groupIDs', 1); UserStorageHandler::getInstance()->reset($userIDs, 'languageIDs', 1); } diff --git a/wcfsetup/install/files/lib/system/setup/Installer.class.php b/wcfsetup/install/files/lib/system/setup/Installer.class.php index ecac03e10c..ea5e88b085 100644 --- a/wcfsetup/install/files/lib/system/setup/Installer.class.php +++ b/wcfsetup/install/files/lib/system/setup/Installer.class.php @@ -165,7 +165,7 @@ class Installer { $errors[] = array('file' => $file, 'code' => $e->getCode(), 'message' => $e->getMessage()); } } - if (count($errors) > 0) { + if (!empty($errors)) { throw new SystemException('error(s) during the installation of the files.', $errors); } diff --git a/wcfsetup/install/files/lib/system/sitemap/SitemapHandler.class.php b/wcfsetup/install/files/lib/system/sitemap/SitemapHandler.class.php index 4314fb9b59..ae67f2e907 100644 --- a/wcfsetup/install/files/lib/system/sitemap/SitemapHandler.class.php +++ b/wcfsetup/install/files/lib/system/sitemap/SitemapHandler.class.php @@ -45,7 +45,7 @@ class SitemapHandler extends SingletonFactory { public function getTree() { $tree = array(); - if (count($this->cache) > 0) { + if (!empty($this->cache)) { foreach ($this->cache as $sitemap) { $tree[] = $sitemap->sitemapName; } diff --git a/wcfsetup/install/files/lib/system/template/TemplateEngine.class.php b/wcfsetup/install/files/lib/system/template/TemplateEngine.class.php index 5231555673..669afe7581 100755 --- a/wcfsetup/install/files/lib/system/template/TemplateEngine.class.php +++ b/wcfsetup/install/files/lib/system/template/TemplateEngine.class.php @@ -556,7 +556,7 @@ class TemplateEngine extends SingletonFactory { } // add new template variables - if (count($variables)) { + if (!empty($variables)) { $this->v = array_merge($this->v, $variables); } @@ -589,7 +589,7 @@ class TemplateEngine extends SingletonFactory { } // add new template variables - if (count($variables)) { + if (!empty($variables)) { $this->v = array_merge($this->v, $variables); } @@ -700,7 +700,7 @@ class TemplateEngine extends SingletonFactory { } // add new template variables - if (count($variables)) { + if (!empty($variables)) { $this->v = array_merge($this->v, $variables); } @@ -762,7 +762,7 @@ class TemplateEngine extends SingletonFactory { */ protected function loadTemplateListenerCode($templateName) { // cache was already loaded - if (!isset($this->templateListeners[$templateName]) || count($this->templateListeners[$templateName])) return; + if (!isset($this->templateListeners[$templateName]) || !empty($this->templateListeners[$templateName])) return; $cacheName = PACKAGE_ID.'-'.$this->environment.'-'.$templateName; CacheHandler::getInstance()->addResource( diff --git a/wcfsetup/install/files/lib/system/user/storage/UserStorageHandler.class.php b/wcfsetup/install/files/lib/system/user/storage/UserStorageHandler.class.php index 3bb974770b..10c300530f 100644 --- a/wcfsetup/install/files/lib/system/user/storage/UserStorageHandler.class.php +++ b/wcfsetup/install/files/lib/system/user/storage/UserStorageHandler.class.php @@ -157,7 +157,7 @@ class UserStorageHandler extends SingletonFactory { public function shutdown() { WCF::getDB()->beginTransaction(); // remove outdated entries - if (count($this->resetFields)) { + if (!empty($this->resetFields)) { $sql = "DELETE FROM wcf".WCF_N."_user_storage WHERE userID = ? AND field = ? @@ -178,7 +178,7 @@ class UserStorageHandler extends SingletonFactory { } // insert data - if (count($this->updateFields)) { + if (!empty($this->updateFields)) { $sql = "INSERT INTO wcf".WCF_N."_user_storage (userID, field, fieldValue, packageID) VALUES (?, ?, ?, ?)"; diff --git a/wcfsetup/install/files/lib/util/XML.class.php b/wcfsetup/install/files/lib/util/XML.class.php index 1b470434c6..1ae93c95dd 100644 --- a/wcfsetup/install/files/lib/util/XML.class.php +++ b/wcfsetup/install/files/lib/util/XML.class.php @@ -64,7 +64,7 @@ class XML { // check for errors occured in libxml $errors = $this->pollErrors(); - if (count($errors)) { + if (!empty($errors)) { $this->throwException("XML document '".$this->path."' is not valid XML.", $errors); } } @@ -83,7 +83,7 @@ class XML { // check for errors occured in libxml $errors = $this->pollErrors(); - if (count($errors)) { + if (!empty($errors)) { $this->throwException("XML document '".$this->path."' is not valid XML.", $errors); } } @@ -100,7 +100,7 @@ class XML { // check for errors occured in libxml $errors = $this->pollErrors(); - if (count($errors)) { + if (!empty($errors)) { $this->throwException("XML document '".$this->path."' violates XML schema definition.", $errors); } } @@ -174,7 +174,7 @@ class XML { * @param array $errors */ protected function throwException($message, array $errors = array()) { - if (count($errors)) { + if (!empty($errors)) { $description = 'LibXML output:
';
 			foreach ($errors as $error) {
 				$description .= "#".$error['line']."\t".$error['message'];
-- 
2.20.1