Skip to content

4.1.1.29

Choose a tag to compare

@gosha-bot gosha-bot released this 28 Oct 02:47
· 86 commits to main since this release
ec7fe7f

Changes

  • Notifications (\extension\ka_extensions\Notifications): a bell in the admin header next to the Kamod Health Status icon (kamod child of common/header and the header.twig kapatch of the library). add($code, $text, $ttl = 0) for the logged in administrator (for all administrators when there is none, e.g. in the catalog), addForAll($code, $text, $ttl = 0) for all administrators, remove($code), get($code). $ttl in seconds, 0 = until closed. The bell is shown to administrators with access to Extensions > Ka Extensions when they have notifications; the text is escaped; the cross deletes a notification by POST (extension/extension/ka_extensions/deleteNotification, modify permission of Ka Extensions). New table ka_notification (created on the Ka Extensions page or on the first add()). en-gb and ru-ru strings. See docgen/guides/notifications.rst.
  • HiddenSettings (\extension\ka_extensions\HiddenSettings): hidden values of a module in the admin area and in the catalog, get($ext_code, $key, $default = null), set($ext_code, $key, $value) and increase($ext_code, $key, $add = 1). The storage is the same as of getConfigHidden()/setConfigHidden() (group '<ext_code>_hidden', keys '<ext_code>hidden', arrays as JSON). set() writes one key instead of the whole group, increase() is one UPDATE value = value + N (a missing value is inserted once under a named lock), so parallel requests do not lose values. getConfigHidden()/setConfigHidden() of the admin setting model are wrappers of it now. See docgen/guides/upgrading_modules.rst.
  • TraitDBFilter (DBProxy): removeFilter() removed all filters of the class, a nested method removing its filter also removed the filter of the calling method (e.g. several modules extending one model method). Fixed: setFilter() returns the filter id, removeFilter($id) removes only that filter, removeFilter() without the id removes only the last filter of the current class. Existing calls work as before; the recommended use is $id = setFilter(...) and removeFilter($id) in a 'finally' block.
  • Forms: validateField() of a 'number' field returned true after the 'Minimum value is %s' / 'Maximum value is %s' error, a child class checking more could go on and replace the error. Fixed: it returns false. An empty value of a non-required 'number' field is not checked against min_value/max_value any more (a minimum above zero gave an error).
  • Settings page (ControllerSettings): a validation error of a module without its own text was shown as the raw key 'error_field_is_empty'. Fixed: the page loads the library common language file before the module files (a module text still wins). New ru-ru texts of the field validation ('Поле не заполнено', minimum, maximum, not a number) in admin and catalog, the 'number' validation texts are in en-gb too.
  • Extensions > Ka Extensions: a module installed without a stored version (0.0.0.0) showed the orange 'Files: ..., installed: 0.0.0.0' text under its version. Now nothing is shown under the version in this case, the hint stays in the tooltip of the 'Refresh' button. The Version column is wider (15%), the Name column is 45%.
  • Module upgrade: Extensions > Ka Extensions shows a yellow 'Refresh' button next to an installed module when $extension_version of its files is greater than the installed version, with the hint 'Files: , installed: ' (en-gb and ru-ru). The button (POST only, the modify permission of Ka Extensions) calls the new upgradeExtension($from_version, $to_version) of the module installer; on success the new version is stored, the kamod cache is marked for a rebuild and the module page gets the permissions, on failure the installed version and the button stay. By default upgradeExtension() calls install(), a module overrides it for migrations. A module without $extension_version gets no button. See docgen/guides/upgrading_modules.rst.
  • Installation: the version of the module ($extension_version) is stored on installation as the hidden value 'version' of the module. A module installed by an older library has no stored version, it is 0.0.0.0 (the 'Refresh' button is shown once).
  • Admin setting model (kamod child of model/setting/setting): getConfigHidden($ext_code, $key) and setConfigHidden($ext_code, $key, $value) for hidden values of a module (the installed version, counters). They are stored by the OpenCart getSetting()/editSetting() in the group '<ext_code>_hidden' under the keys '<ext_code>hidden', other hidden values of the module are kept, saving the settings page does not touch them. A missing value is null.
  • ControllerSettings: uninstallation does not delete the module settings any more, they are used again by the next installation or upgrade. getSettingCode() is moved to ControllerInstaller.
  • KaURLify vendor: the composer.json files of the bundled libraries are removed, the portable-ascii ASCII class is not final.
  • KaURLify: smaller package. voku/stop-words is not bundled (KaURLify does not remove stop words, remove_words() keeps its own list) and the CJK and Hangul transliteration tables of portable-ascii are removed: Chinese, Japanese and Korean characters are dropped from urls. See system/library/extension/ka_extensions/vendor/README.md.
  • KaURLify (\extension\ka_extensions\KaURLify): url keywords and file names from any text, filter($text, $length, $language, $url_type) as in the KaURLify class of CSV Product Import and of the OpenCart 4 library. It wraps jbroadway/urlify 1.2.5 with voku/portable-ascii 2.1.1 and voku/stop-words 2.0.1, added to system/library/extension/ka_extensions/vendor (with their licenses, loaded without composer, PHP 7.2+). The language code ('ru', 'ru-ru') selects the transliteration rules; Ukrainian letters missing in the Ukrainian table are converted by the Russian rules.
  • Forms: a 'text' or 'textarea' field can have 'max_length' (characters, e.g. the size of its database column). A longer posted value fails validation with the new language string error_field_too_long (admin and catalog, en-gb and ru-ru).
  • Installation: permissions of the extension pages were added to the user group on every installation, a reinstalled module had its routes in the group lists several times. Fixed: a permission is added only when the group does not have it yet. Existing duplicates are removed when the user group is saved.
  • Forms: a 'checkboxes' field (a list of checkboxes) could not be saved with all boxes unchecked, the old value was kept because unchecked boxes are not posted. Fixed: a submitted form without the field saves an empty list.
  • ControllerList: delete() and deleteRecord() work by POST requests only, a GET request (e.g. a link) deletes nothing and shows the permission error. A delete link in a list template has to be replaced with a button posting to the same url.
  • Language: the permission error of the library pages (e.g. a refused GET delete of ControllerList) was shown as the raw key 'error_permission' when the module language file did not define it. Fixed: error_permission is in the library common language file (en-gb, and a new ru-ru file); a module's own error_permission still wins.
  • QB: orderBy($order, $after) and groupBy($groupBy, $after) dropped the value (wrong argument order of Arrays::insertAfterKey()). Fixed: the value is put after $after, at the end when $after is not in the list. Several from() tables are separated with commas.
  • kamod: a kapatch for a newer or another major kamod version was skipped, but the patched file was written empty. Fixed: the file keeps its contents.
  • kamod: the log (kamod.log) had the month name instead of the hour in the time. Fixed.
  • Pagination: without the 'limit' parameter the OpenCart 3 setting 'Default Items Per Page (Admin)' (config_limit_admin) was ignored and 20 was used. Fixed.
  • Model: the deprecated getNamespace() used an undefined variable for a class without a namespace (a warning). Fixed: an empty namespace is returned.
  • Forms: validation of fields. A required field of spaces passed; a required 'checkboxes' field posted as an empty list gave a TypeError; a non-numeric value of a 'number' field with min_value/max_value passed the limits (now 'The value must be a number'); initFields() of no fields returned null instead of an empty array. Fixed.
  • Forms (ControllerForm): the raw POST was saved. An unchecked checkbox kept its old value, a 'checkboxes' field with all boxes unchecked kept the old list. A posted primary key was trusted when the url had none: a new record form updated the posted record. Fixed in the new protected getPostedRecord(): unchecked boxes are saved as '0' / an empty list, the primary key is taken from the url only.
  • Form fields: the field templates (common/fields/*.twig, admin and catalog) printed values without escaping (OpenCart 3 Twig has autoescape off), a quote broke an input and HTML in a value was output as is. Fixed: values, placeholders and option values are escaped with the new Twig filter ka_escape (htmlspecialchars without encoding existing entities again, so values stored html-escaped by OpenCart are shown as before). Labels, errors and 'plaintext' fields are printed as before.
  • Settings page template: the form posted to an empty 'action' (the controller sets 'action_save'), Enter in a field submitted to the current url. Fixed: the form uses action_save ('action' still wins when a module sets it).
  • ControllerSettings: for a vendor other than 'ka_extensions' the settings page saved the values under '<ext_code>', but install() stored the default values and uninstall() deleted the settings under '<ext_code>'. The defaults did not reach the group of the page (OpenCart skips keys not starting with the code) and uninstallation left the saved values. Fixed: one protected getSettingCode() ('<ext_code>' for vendor 'ka_extensions', '<ext_code>' for others) is used for saving and installation (the settings are not deleted on uninstallation any more, see above). Old rows stored under '<ext_code>' by older versions are not removed automatically.

Pull requests

  • ControllerList: delete by POST only by @gosha-bot in #15
  • Module upgrade: Refresh button, installed version, hidden values (OC3) by @gosha-bot in #16
  • Version 4.1.1.29 (not released) by @gosha-bot in #17
  • Library fixes: version hint, settings language, number limits, delete POST check, DB filter ids by @gosha-bot in #18
  • HiddenSettings and admin Notifications (bell) by @gosha-bot in #19
  • Release 4.1.1.29 by @gosha-bot in #20

Full Changelog: v4.1.1.28...v4.1.1.29