|
10 | 10 | namespace Joomla\CMS\Console; |
11 | 11 |
|
12 | 12 | use Joomla\Application\Cli\CliInput; |
| 13 | +use Joomla\CMS\Extension\ExtensionHelper; |
13 | 14 | use Joomla\CMS\Filesystem\File; |
14 | 15 | use Joomla\CMS\Filesystem\Folder; |
15 | 16 | use Joomla\CMS\Installer\InstallerHelper; |
@@ -165,6 +166,19 @@ public function doExecute(InputInterface $input, OutputInterface $output): int |
165 | 166 | return self::ERR_CHECKS_FAILED; |
166 | 167 | } |
167 | 168 |
|
| 169 | + $this->progressBar->advance(); |
| 170 | + $this->progressBar->setMessage('Check Database Table Structure...'); |
| 171 | + |
| 172 | + $errors = $this->checkSchema(); |
| 173 | + |
| 174 | + if ($errors > 0) { |
| 175 | + $this->ioStyle->error('Database Table Structure not Up to Date'); |
| 176 | + $this->progressBar->finish(); |
| 177 | + $this->ioStyle->info('There were ' . $errors . ' errors'); |
| 178 | + |
| 179 | + return self::ERR_CHECKS_FAILED; |
| 180 | + } |
| 181 | + |
168 | 182 | $this->progressBar->advance(); |
169 | 183 | $this->progressBar->setMessage('Starting Joomla! update ...'); |
170 | 184 |
|
@@ -386,4 +400,32 @@ public function copyFileTo($file, $dir): void |
386 | 400 | { |
387 | 401 | Folder::copy($file, $dir, '', true); |
388 | 402 | } |
| 403 | + |
| 404 | + /** |
| 405 | + * Check Database Table Structure |
| 406 | + * |
| 407 | + * @return integer the number of errors |
| 408 | + * |
| 409 | + * @since __DEPLOY_VERSION__ |
| 410 | + */ |
| 411 | + public function checkSchema(): int |
| 412 | + { |
| 413 | + $app = $this->getApplication(); |
| 414 | + $app->getLanguage()->load('com_installer', JPATH_ADMINISTRATOR); |
| 415 | + $coreExtensionInfo = ExtensionHelper::getExtensionRecord('joomla', 'file'); |
| 416 | + |
| 417 | + $dbmodel = $app->bootComponent('com_installer')->getMVCFactory($app)->createModel('Database', 'Administrator'); |
| 418 | + |
| 419 | + // Ensure we only get information for core |
| 420 | + $dbmodel->setState('filter.extension_id', $coreExtensionInfo->extension_id); |
| 421 | + |
| 422 | + // We're filtering by a single extension which must always exist - so can safely access this through element 0 of the array |
| 423 | + $changeInformation = $dbmodel->getItems()[0]; |
| 424 | + |
| 425 | + foreach ($changeInformation['errorsMessage'] as $msg) { |
| 426 | + $this->ioStyle->info($msg); |
| 427 | + } |
| 428 | + |
| 429 | + return $changeInformation['errorsCount']; |
| 430 | + } |
389 | 431 | } |
0 commit comments