3 namespace wcf\data\devtools\missing\language\item;
5 use wcf\data\AbstractDatabaseObjectAction;
6 use wcf\data\IDeleteAction;
7 use wcf\system\exception\IllegalLinkException;
12 * Executes missing language item log entry-related actions.
14 * @author Matthias Schmidt
15 * @copyright 2001-2020 WoltLab GmbH
16 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
17 * @package WoltLabSuite\Core\Devtools\Missing\Language\Item
20 * @method DevtoolsMissingLanguageItemEditor[] getObjects()
21 * @method DevtoolsMissingLanguageItemEditor getSingleObject()
23 class DevtoolsMissingLanguageItemAction extends AbstractDatabaseObjectAction implements IDeleteAction
28 protected $permissionsDelete = ['admin.configuration.package.canInstallPackage'];
31 * Logs a missing language item.
33 public function logLanguageItem()
35 $stackTraceData = \wcf\functions\exception\sanitizeStacktrace(new \Exception(), true);
36 // Remove stack entries related to logging.
37 \array_shift($stackTraceData);
38 \array_shift($stackTraceData);
39 \array_shift($stackTraceData);
40 $stackTrace = JSON::encode($stackTraceData);
42 $sql = "INSERT INTO wcf" . WCF_N . "_devtools_missing_language_item
43 (languageID, languageItem, lastTime, stackTrace)
45 ON DUPLICATE KEY UPDATE lastTime = ?,
47 $statement = WCF::getDB()->prepareStatement($sql);
49 $this->parameters['language']->languageID,
50 $this->parameters['languageItem'],
62 public function validateDelete()
64 if (!ENABLE_DEVELOPER_TOOLS || !LOG_MISSING_LANGUAGE_ITEMS) {
65 throw new IllegalLinkException();
68 parent::validateDelete();
72 * Validates the `clearLog` action.
74 public function validateClearLog()
76 if (!ENABLE_DEVELOPER_TOOLS || !LOG_MISSING_LANGUAGE_ITEMS) {
77 throw new IllegalLinkException();
80 WCF::getSession()->checkPermissions(['admin.configuration.package.canInstallPackage']);
84 * Removes all entries from the missing language item log.
86 public function clearLog()
88 $sql = "DELETE FROM wcf" . WCF_N . "_devtools_missing_language_item";
89 $statement = WCF::getDB()->prepareStatement($sql);
90 $statement->execute();
94 * Validates the `clearExistingLog` action.
98 public function validateClearExistingLog(): void
100 if (!ENABLE_DEVELOPER_TOOLS || !LOG_MISSING_LANGUAGE_ITEMS) {
101 throw new IllegalLinkException();
104 WCF::getSession()->checkPermissions(['admin.configuration.package.canInstallPackage']);
108 * Removes the entries from the missing language item log for which a language item exists now.
112 public function clearExistingLog(): void
114 $sql = "DELETE devtools_missing_language_item
115 FROM wcf" . WCF_N . "_devtools_missing_language_item devtools_missing_language_item
116 INNER JOIN wcf" . WCF_N . "_language_item language_item
118 language_item.languageItem = devtools_missing_language_item.languageItem
119 AND language_item.languageID = devtools_missing_language_item.languageID
121 $statement = WCF::getDB()->prepareStatement($sql);
122 $statement->execute();