| @@ -1,5 +1,18 @@ | ||
| 1 | 1 | <?php |
| 2 | +/** | |
| 3 | + * DatabaseUpdate4.php | |
| 4 | + * | |
| 5 | + * The DatabaseUpdate4 class file. | |
| 6 | + * | |
| 7 | + * PHP versions 5 | |
| 8 | + * | |
| 9 | + * @author Alexander Schneider <alexanderschneider85@gmail.com> | |
| 10 | + * @copyright 2008-2017 Alexander Schneider | |
| 11 | + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 | |
| 12 | + * @version SVN: $id$ | |
| 13 | + * @link http://wordpress.org/extend/plugins/user-access-manager/ | |
| 14 | + */ | |
| 2 | 15 | |
| 3 | 16 | declare(strict_types=1); |
| 4 | 17 | |
| 5 | 18 | namespace UserAccessManager\Setup\Update; |
| @@ -6,28 +19,43 @@ | ||
| 6 | 19 | |
| 7 | 20 | use UserAccessManager\Object\ObjectHandler; |
| 8 | 21 | use UserAccessManager\Setup\Database\DatabaseUpdate; |
| 9 | 22 | |
| 23 | +/** | |
| 24 | + * Class DatabaseUpdate4 | |
| 25 | + * | |
| 26 | + * @package UserAccessManager\Setup\Update | |
| 27 | + */ | |
| 10 | 28 | class DatabaseUpdate4 extends DatabaseUpdate |
| 11 | 29 | { |
| 30 | + /** | |
| 31 | + * Returns the version. | |
| 32 | + * @return string | |
| 33 | + */ | |
| 12 | 34 | public function getVersion(): string |
| 13 | 35 | { |
| 14 | 36 | return '1.4.1'; |
| 15 | 37 | } |
| 16 | 38 | |
| 39 | + /** | |
| 40 | + * Executes the update. | |
| 41 | + * @return bool | |
| 42 | + */ | |
| 17 | 43 | public function update(): bool |
| 18 | 44 | { |
| 45 | + $success = true; | |
| 46 | + | |
| 19 | 47 | $dbAccessGroupToObject = $this->database->getUserGroupToObjectTable(); |
| 20 | 48 | $alterQuery = "ALTER TABLE {$dbAccessGroupToObject} |
| 21 | 49 | ADD general_object_type VARCHAR(64) NOT NULL AFTER object_id"; |
| 22 | 50 | |
| 23 | - $success = $this->database->query($alterQuery) !== false; | |
| 51 | + $success = $success && $this->database->query($alterQuery) !== false; | |
| 24 | 52 | |
| 25 | 53 | // Update post entries |
| 26 | 54 | $generalPostType = ObjectHandler::GENERAL_POST_OBJECT_TYPE; |
| 27 | 55 | |
| 28 | 56 | $query = "UPDATE {$dbAccessGroupToObject} |
| 29 | - SET general_object_type = '$generalPostType' | |
| 57 | + SET general_object_type = '{$generalPostType}' | |
| 30 | 58 | WHERE object_type IN ('post', 'page', 'attachment')"; |
| 31 | 59 | |
| 32 | 60 | $success = $success && $this->database->query($query) !== false; |
| 33 | 61 | |
| @@ -34,9 +62,9 @@ | ||
| 34 | 62 | // Update role entries |
| 35 | 63 | $generalRoleType = ObjectHandler::GENERAL_ROLE_OBJECT_TYPE; |
| 36 | 64 | |
| 37 | 65 | $query = "UPDATE {$dbAccessGroupToObject} |
| 38 | - SET general_object_type = '$generalRoleType' | |
| 66 | + SET general_object_type = '{$generalRoleType}' | |
| 39 | 67 | WHERE object_type = 'role'"; |
| 40 | 68 | |
| 41 | 69 | $success = $success && $this->database->query($query) !== false; |
| 42 | 70 | |
| @@ -43,9 +71,9 @@ | ||
| 43 | 71 | // Update user entries |
| 44 | 72 | $generalUserType = ObjectHandler::GENERAL_USER_OBJECT_TYPE; |
| 45 | 73 | |
| 46 | 74 | $query = "UPDATE {$dbAccessGroupToObject} |
| 47 | - SET general_object_type = '$generalUserType' | |
| 75 | + SET general_object_type = '{$generalUserType}' | |
| 48 | 76 | WHERE object_type = 'user'"; |
| 49 | 77 | |
| 50 | 78 | $success = $success && $this->database->query($query) !== false; |
| 51 | 79 | |
| @@ -52,18 +80,18 @@ | ||
| 52 | 80 | // Update term entries |
| 53 | 81 | $generalTermType = ObjectHandler::GENERAL_TERM_OBJECT_TYPE; |
| 54 | 82 | |
| 55 | 83 | $query = "UPDATE {$dbAccessGroupToObject} |
| 56 | - SET general_object_type = '$generalTermType' | |
| 84 | + SET general_object_type = '{$generalTermType}' | |
| 57 | 85 | WHERE object_type = 'term'"; |
| 58 | 86 | |
| 59 | 87 | $success = $success && $this->database->query($query) !== false; |
| 60 | 88 | |
| 61 | - $query = "UPDATE $dbAccessGroupToObject AS gto | |
| 89 | + $query = "UPDATE {$dbAccessGroupToObject} AS gto | |
| 62 | 90 | LEFT JOIN {$this->database->getTermTaxonomyTable()} AS tt |
| 63 | 91 | ON gto.object_id = tt.term_id |
| 64 | 92 | SET gto.object_type = tt.taxonomy |
| 65 | - WHERE gto.general_object_type = '$generalTermType'"; | |
| 93 | + WHERE gto.general_object_type = '{$generalTermType}'"; | |
| 66 | 94 | |
| 67 | 95 | return $success && $this->database->query($query) !== false; |
| 68 | 96 | } |
| 69 | 97 | } |