[4.0] database importer exporter (rebase)#24733
Conversation
|
These CLI files really should make use of the |
|
Is there a documentation to implement joomla/console ? If I execute:
|
|
Do you have a code branch somewhere? You should only need command classes,
not an application class.
Check the Framework’s Event, Keychain, Router, and Session packages for
example commands. The CMS repo has some commands as well. And check the
framework.joomla.org repo for a full application example.
On Sun, Apr 28, 2019 at 10:25 AM Olivier ***@***.***> wrote:
Is there a documentation to implement joomla/console ?
The only one I found is:
https://github.com/joomla-framework/console/blob/master/docs/overview.md
If I execute:
https://gist.github.com/twister65/c52a2e5816fd9a0b923b9cd188719d5f
I have:
PHP Fatal error: Uncaught Error: Class 'Joomla\Console\Application' not
found in /home/olivier/src/database/Console/ExportApplication.php:11
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#24733 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AACZ7IL2SWSNW25EJ65TBNLPSW6W3ANCNFSM4HI2J7SQ>
.
--
- Michael Please pardon any errors, this message was sent from my iPhone.
|
|
@mbabker , the code branch is: I failed to test these commands with the joomla/console/application.
See https://gist.github.com/twister65/c52a2e5816fd9a0b923b9cd188719d5f We must also read the configuration file to configure the database interface. |
|
For the class not found bit, you'll need to add the relevant packages to the
For the Database package, what you've got in there is just fine for now. When integrated into the CMS, the service layer would have to take care of loading in the correct database connection when the command is run. We can worry about that later. I'll do a more thorough look at your branch later. |
|
@mbabker , I put the console application in the cli directory. Is this the right place ? |
Not quite. Instead of adding a new application, you'd register the commands with the existing application (part of the point of the console package is to make it so you can build commands usable in any compatible application, whereas the old concept of So for the CMS integration, you're really doing 2 things:
In $container->share(
ExportCommand::class,
function (Container $container)
{
return new ExportCommand($container->get('db'));
},
true
);
$container->share(
ImportCommand::class,
function (Container $container)
{
return new ImportCommand($container->get('db'));
},
true
);
In |
|
You didn't need that last commit. For the CMS integration, the only changes this PR needs is the changes to the files in The only thing this PR is dependent upon once it gets in that state is the pull request in the Framework repository to be merged then the CMS pulls in the upstream changes. The only reason to add the command classes to the CMS repo directly is if the CMS 100% cannot use the classes in the Framework package, which from everything I've seen that is not the case. |
php cli/joomla.php
|
It is ready for testing with Joomla/Console. See the testing instructions. |
|
Upstream PR's merged, this repo just needs the corresponding |
|
to be honest i didn't test all the options .... sorry i'm lazy ... |
|
I have tested this item ✅ successfully on 8fa6edf This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/24733. |
FWIW I added some functional tests for both the export command and import command on a MySQL build, so between the tests for the import/export class chains and the command tests we should be covered on all the functionality now. Since all this PR is doing is adding the integration for the CMS' console application, this should be considered RTC as any bugs in either the import or export code, or the CLI commands, are going to be upstream bugs and not a blocker for this PR. The branch just needs to have 4.0-dev merged in again to pick up the autoloader fixes that broke the tests. |
|
your statements are gold to my ears |
|
RTC This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/24733. |
|
Try to import in a new blank database (without table). The joomla/console script fails, unlike the previous cli script or Joomla/Console Application. |
To import in a new database
|
Define "fails". |
|
Put Joomla in debug mode and see what happens. IIRC I set up the Symfony debug handler is configured to show the exception details and backtrace when debug's enabled (but the Console application is also supposed to be catching and processing Exceptions within it so I have no idea why that handler is actually being triggered). |
|
Same result with debugging enabled. I have also defined the session handler on filesystem (previously defined on database). Without effect ... |
|
Well, without an Exception to debug things aren't going to go too far. You might need to find one of the catch blocks in the Joomla\Console\Application class and dump the Exception there to see what's going on. Though if I had to blindly take a guess, given your "empty database" statement, it's probably an Exception being thrown from the drop table call in the import command, but that would then mean it's not a |
|
With DatabaseConsole, it works fine. |
|
All that means is that the command executes correctly in an isolated context. That doesn't identify if there is an integration issue with the Console package and the CMS or some quirk in the import code that you don't get from a standalone version that has no outside influences. That DatabaseConsole file can't be merged because the intent is all CLI things go through |
|
|
That'd be expected then. Unfortunately a chunk of the CMS outside the install app just requires some of the database to be there, I'm not sure you'd be able to make the import command work on a completely empty database (maybe some of the work in #21452 helps with this scenario). |
|
Thank you @twister65 Would you mind creating a page on the https://docs.joomla.org site documenting this feature? |
|
Of course, I created an account and confirmed my email. But I can't edit a new page:
Maybe someone else can do it, click on the link below: |
|
@twister65 docs page done can you double check please https://docs.joomla.org/CLI_Database_Exporter_Importer |

Rebase Pull Request #23320.
This PR aims to back up and restore the Joomla database using export and import commands (joomla / console).
Summary of Changes
See PR #23320, PR #14272 (and PR #10991).
Testing Instructions
Before:
https://developer.joomla.org/nightly-builds.html
Then:
php joomla.php database:export --all --folder <folder_path>php joomla.php database:import --all --folder <folder_path>You can also :
php joomla.php database:export --all --zipphp joomla.php database:export --table <table_name>php joomla.php database:export --table <table_name> --zipphp joomla.php database:import --table <table_name>If you need help:
php joomla.php database:export --helpphp joomla.php database:import --helpExpected result
Export/import tables with structure and data.
Actual result
Does not export/import views, stored procedures and triggers (optional for the Joomla database).
Documentation Changes Required