JoomGalleryfriends / JG4-dev

Development repository for JoomGallery v4.x
GNU General Public License v3.0
10 stars 6 forks source link

Fix error in script when upgrade from JG3 to JG4 #161

Closed Elfangor93 closed 6 months ago

Elfangor93 commented 9 months ago

Upgrade from JG3 to JG4 created an error, when script tries to uninstall modules during the upgrading process. Line 180 of script.php $this->uninstallModules(array('mod_joomgithub')); throws an error because it tries to call method children() on variable type array.

Thanks @csoscd for reporting this issue.

MrMusic commented 9 months ago

I have tried the upgrate with this PR. The JG3 tables were renamed correctly. Unfortunately the default entries are missing in the new database tables.

OS: Windows PHP 8.0.28 MariaDB 10.4.28

Elfangor93 commented 9 months ago

Unfortunately the default entries are missing in the new database tables.

Yes, I have excluded this, because i didn't know how I want to solve this with the upgrade script. But now I know and we can include it.

MrMusic commented 9 months ago

2 errors during installation: 0 Resource 'DatabaseInterface' has not been registered with the container. and 0 Resource 'LanguageFactoryInterface' has not been registered with the container.

Reason: use \Joomla\Database\DatabaseInterface; and use \Joomla\CMS\Language\LanguageFactoryInterface; is missing.

Addition: I have fixed the two errors mentioned above and tried an update from the JG 3.6. The following message appears: jg4-update-error Then the joomgallery_categories is completely empty, no 'root' or 'uncategorised' entry. But the default configuration is present.

Elfangor93 commented 9 months ago

Reason: use \Joomla\Database\DatabaseInterface; and use \Joomla\CMS\Language\LanguageFactoryInterface; is missing.

The two missing use stamenets are now in and the errror should be solved.

MrMusic commented 9 months ago

The two missing use stamenets are now in and the errror should be solved.

Thanks. Sorry, another error still appears: 0 Call to undefined method Joomla\CMS\Language\CachingLanguageFactory::getTag() in line 233 of script.php Changing line 232 to $language = Factory::getLanguage(); solves the error for me.

Elfangor93 commented 9 months ago

Factory::getLanguage() is deprecated and will be removed in Joomla 6. If the approach with the DI Container does not work we could try with $app->getLanguage()

grafik

MrMusic commented 9 months ago

If the approach with the DI Container does not work we could try with $app->getLanguage()

Yes, $app->getLanguage() works.

Now I make a test upgrade from Joomla 3.10.12 to Joomla 4.4.0 Procedure:

  1. Successfully performed Joomla upgrade to 4.4.0.

  2. Current branch 'script-uninstallModules' installed via the extension manager of Joomla.

  3. Messages see screenshot jg4-update-error-2023-10-18

  4. After the installation attempt: The folder 'com_joomgallery' in administrator/components is no longer exist In the Database the old joomgallery tables are present with the extension '_old' In the Database are no new tables from the JoomGallery 4 exist

  5. Then second try to install the current 'script-uninstallModules' Branch

  6. Messages see screenshot jg4-update-error-2023-10-18_2

Installation now overall successful, but In the Database the old tables now have 2x the extension "_old", e.g. "#joomgallery_old_old" and the new table #categories does not contain root category.

AlexanderSupp commented 8 months ago

Question: When this PR fixed this error can I then directly upgrade to JG4 from Joomla 3.10 to Joomla 5.0, or must I proceed Joomla 3.10 to Joomla 4.4 and then from Joomla 4 to Joomla 5?

MrMusic commented 8 months ago

...can I then directly upgrade to JG4 from Joomla 3.10 to Joomla 5.0...

No, first you have to migrate to Joomla 4.4, See https://docs.joomla.org/Joomla_4.4.x_to_5.x_Planning_and_Upgrade_Step_by_Step

Elfangor93 commented 8 months ago

With Joomla 5 (or better PHP 8.2) there are still some issues everywhere in the code. Therefore up until now please use the JG4 only up until Joomla 4.4 and up until PHP 8.1.

Elfangor93 commented 7 months ago

Found the problem to this error: 276254968-9946a7e3-b64b-419a-9295-b3f83eae4de1

Since Joomla 4.4 and Joomla 5.x there is a change in the behavior of File::delete() depending if you use it as Joomla\CMS\Filesystem\File::delete() or Joomla\Filesystem\File::delete(). This is why in Joomla 5 and Joomla 4.4.x the installer script does not work anymore... https://github.com/joomla/joomla-cms/pull/40257#issuecomment-1848936871

Elfangor93 commented 7 months ago

It has to be discussed how to solve this issue...

Elfangor93 commented 7 months ago

Now also this error is fixed 276255031-33878831-0710-4320-a10b-669b13d00000

@MrMusic Can you give this a last check?

MrMusic commented 6 months ago

Error is fixed! After upgrade from Joomla 3.10.12/JoomGallery 3.6.2 this PR is installable and the default category was created correctly. I have tested this item ✅ successfully. Thank you very much.