joomla / joomla-cms

Home of the Joomla! Content Management System
https://www.joomla.org
GNU General Public License v2.0
4.73k stars 3.64k forks source link

Deleting library parameters from the database when updating the library #39360

Open sergeytolkachyov opened 1 year ago

sergeytolkachyov commented 1 year ago

My library uses library helper to save parameters to the database (Joomla\CMS\Helper\LibraryHelper::saveParams()). the parameters are stored in the #__extensions table, the paramscolumn. If you install the next version of your library via Joomla installer, the parameters are removed from this column. The same applies to the custom_datacolumn. See the video https://user-images.githubusercontent.com/6236403/205869005-ee3faeb9-65b6-456d-aacd-13d077ca55db.mp4

Steps to reproduce the issue

Expected result

Actual result

System information (as much as possible)

Additional comments

richard67 commented 1 year ago

@sergeytolkachyov Does it have the reason described in issue #35083 , i.e. you have an uninstall SQL and that runs on update? If so, does the workaround provided in this comment https://github.com/joomla/joomla-cms/issues/35083#issuecomment-896195730 work for you?

sergeytolkachyov commented 1 year ago

@sergeytolkachyov Does it have the reason described in issue #35083 , i.e. you have an uninstall SQL and that runs on update? If so, does the workaround provided in this comment #35083 (comment) work for you?

No, that issue does not match to mine. I haven't any sql files in library package. This issue connected with core joomla table #__extensions. there is a library XML manifest

<?xml version="1.0" encoding="UTF-8" ?>
<extension type="library" method="upgrade">
    <name>WebTolk AmoCRM library</name>
    <libraryname>Webtolk/Amocrm</libraryname>
    <version>1.0.2-alpha</version>
    <description>AmoCRM connection library</description>
    <creationDate>06/12/2022</creationDate>
    <copyright>2022 Sergey Tolkachyov</copyright>
    <license>GNU/GPL 3.0</license>
    <author>Sergey Tolkachyov</author>
    <authorEmail>info@web-tolk.ru</authorEmail>
    <authorUrl>https://web-tolk.ru</authorUrl>
    <namespace path="src">Webtolk\Amocrm</namespace>
    <files folder="libraries">
        <folder>src</folder>
        <filename>amocrm.xml</filename>
    </files>
</extension>
sergeytolkachyov commented 1 year ago

@richard67 Hmm, there is an installer bug only for type="library"... I'll test it. That is very strange

SharkyKZ commented 1 year ago

It's not a bug, it's a feature™

https://github.com/joomla/joomla-cms/blob/485885b0863e82cf6443ae5edf523f80deb49dff/libraries/src/Installer/Adapter/LibraryAdapter.php#L47-L57

It can be removed in 5.0.

sergeytolkachyov commented 1 year ago

It's not a bug, it's a feature™

https://github.com/joomla/joomla-cms/blob/485885b0863e82cf6443ae5edf523f80deb49dff/libraries/src/Installer/Adapter/LibraryAdapter.php#L47-L57

It can be removed in 5.0.

This method is no deprecated now. Why not fix it now?

SharkyKZ commented 1 year ago

Because existing extensions may rely on this behavior. In which case they do not handle the removal or renaming of library files on updates. Changing this behavior could potentially break some libraries which is why this to be done in the next major version.

sergeytolkachyov commented 1 year ago

@SharkyKZ What could be tougher than deleting and installing a new one instead of a real update? As far as I understand, everyone who faces this problem finds workarounds in order to restore the correct, necessary behavior. Did you read #35083 (comment) - this is just a vivid example of how developers are trying to work around the problem and achieve the desired result

SharkyKZ commented 1 year ago

Yes, I've seen that. In fact, I remember when it was supposedly fixed in https://github.com/joomla/joomla-cms/pull/23303. I agree this behavior needs to be removed and I already explained why this should be done in 5.0. But it's not for me to decide. You can submit a PR against 4.2 if you want and hope someone merges it.

sergeytolkachyov commented 1 year ago

Ping