throw new UserInputException('name');
}
else {
- $sql = "SELECT COUNT(*) AS count
+ $sql = "SELECT COUNT(*)
FROM wcf".WCF_N."_devtools_project
WHERE name = ?";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute([$this->name]);
- $count = $statement->fetchColumn();
- if ($count > 0) {
+
+ if ($statement->fetchColumn()) {
throw new UserInputException('name', 'notUnique');
}
}
throw new UserInputException('path', $errorType);
}
+ $this->validateUniquePath();
+
$this->path = $path;
}
}
+ /**
+ * Checks that the project path is not used by another project.
+ */
+ protected function validateUniquePath() {
+ $sql = "SELECT COUNT(*)
+ FROM wcf".WCF_N."_devtools_project
+ WHERE path = ?";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute([$this->path]);
+
+ if ($statement->fetchColumn()) {
+ throw new UserInputException('path', 'notUnique');
+ }
+ }
+
/**
* @inheritDoc
*/
use wcf\data\devtools\project\DevtoolsProjectAction;
use wcf\form\AbstractForm;
use wcf\system\exception\IllegalLinkException;
+use wcf\system\exception\UserInputException;
use wcf\system\WCF;
/**
}
}
+ /** @noinspection PhpMissingParentCallCommonInspection */
+ /**
+ * @inheritDoc
+ */
+ protected function validateUniquePath() {
+ $sql = "SELECT COUNT(*)
+ FROM wcf".WCF_N."_devtools_project
+ WHERE path = ?
+ AND projectID <> ?";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute([$this->path, $this->objectID]);
+
+ if ($statement->fetchColumn()) {
+ throw new UserInputException('path', 'notUnique');
+ }
+ }
+
/**
* @inheritDoc
*/
}
}
+ /** @noinspection PhpMissingParentCallCommonInspection */
/**
* @inheritDoc
*/
<item name="wcf.acp.devtools.project.path.error.missingExclude"><![CDATA[In der <kbd>package.xml</kbd> fehlt die <kbd>>excludedpackage<</kbd>-Anweisung für <kbd>com.woltlab.wcf</kbd>.]]></item>
<item name="wcf.acp.devtools.project.path.error.notInstalled"><![CDATA[Das Paket muss bereits installiert sein.]]></item>
<item name="wcf.acp.devtools.project.path.error.notFound"><![CDATA[Der Pfad ist ungültig.]]></item>
+ <item name="wcf.acp.devtools.project.path.error.notUnique"><![CDATA[Der Pfad wird bereits von einem anderen Projekt verwendet.]]></item>
<item name="wcf.acp.devtools.project.path.error.versionMismatch"><![CDATA[Die Version in der <kbd>package.xml</kbd> passt nicht zur installierten Version, möglicherweise wurde eine falsches Verzeichnis ausgewählt.]]></item>
<item name="wcf.acp.devtools.project.sync"><![CDATA[Daten-Abgleich]]></item>
<item name="wcf.acp.devtools.pip.defaultFilename"><![CDATA[Suchmuster]]></item>
<item name="wcf.acp.devtools.project.path.error.missingExclude"><![CDATA[The <kbd>package.xml</kbd> is missing the <kbd>>excludedpackage<</kbd> instruction for <kbd>com.woltlab.wcf</kbd>.]]></item>
<item name="wcf.acp.devtools.project.path.error.notInstalled"><![CDATA[The package must be installed already.]]></item>
<item name="wcf.acp.devtools.project.path.error.notFound"><![CDATA[The path is invalid.]]></item>
+ <item name="wcf.acp.devtools.project.path.error.notUnique"><![CDATA[The path is already used by another project.]]></item>
<item name="wcf.acp.devtools.project.path.error.versionMismatch"><![CDATA[The version shown in the <kbd>package.xml</kbd> does not match the installed version, you may have selected the wrong path.]]></item>
<item name="wcf.acp.devtools.project.sync"><![CDATA[Sync Data]]></item>
<item name="wcf.acp.devtools.pip.defaultFilename"><![CDATA[Search Pattern]]></item>