Hello!
Version 4.3.6 is on its way with PHP 7 support and new cool Multi-Vendor features. And meanwhile, check out developer changes for the new version and be ready to adapt your add-ons and themes.
Common changes
- Minimal PHP version requirement bumped from 5.3.0 to 5.3.6
- PHP7 compatibility implemented
- PHP7 APCu cache driver added
- Mysqli DB driver now doesn't suppress "mysqli" class constructor errors
- You may now install and use symlinked add-ons under the CS-Cart installation directory. This is useful when you develop an add-on in a separate Git repository and create symbolic links of an add-on files under the CS-Cart root directory.
- Debugger panel now supports EXPLAIN FORMAT=JSON automatically if you use MySQL 5.7
- Now every block cache parameter can be adjusted via the "app/schemas/block_manager/block_cache_properties.php" schema. Earlier only the "update_handlers" parameter could.
- Debugger SQL formatting was broken, now it's completely awesome
- Now Bootstrap::sendHeaders() method doesn't send cache-restricting headers "Expires", "Last-Modified", "Cache-Control", and "Pragma". Sending those headers is delegated to the session_start() function call. It will send correct headers based on the session.cache_limiter PHP configuration parameter value.
- Service providers pattern was implemented. Provider classes are stored at the \Tygh\Providers namespace and are registered in the init.php file.
- Database connection class was refactored and was moved to the Application service locator as a component. It's available now as Tygh::$app['db'].
- \Tygh\Database now doesn't contain any logic and proxies all method calls to the Tygh::$app['db'] component
- All database functions such as db_query are still working like earlier, but they now use internally new component
- All of your code will work as earlier, but the \Tygh\Database class is now deprecated and iwill be removed in the next major release (5.x)
- You may now use several DB connections transparently by adding one more DB connection component to the service locator:
// Create a new instance of connection Tygh::$app['replication_db'] = new \Tygh\Database\Connection(new \Tygh\Backend\Database\Pdo());// Establish connection to the DB
Tygh::$app[‘replication_db’]->connect(‘user’, ‘password’, ‘localhost’, ‘db_name’, array(‘table_prefix’ => ‘cscart_’));// Run queries!
$user = Tygh::$app[‘replication_db’]->getRow(‘SELECT * FROM ?:users WHERE user_id = ?i’, 1);
- You may want to take a look at the "app/Tygh/Providers/DatabaseProvider.php" and "app/Tygh/Database/Connection.php" files for deeper understanding of internal mechanisms
- Debugger and On-site editing templates were moved to the backend area
- The "backend" Smarty template resource was implemented, you can fetch or display backend template with an elegant syntax: php \Tygh::$app['view']->display('backend:views/debugger/debugger.tpl');
- \Tygh\Http class:
- The encoding extra parameter was added for cURL requests, it stands for CURLOPT_ENCODING parameter
- Multi-requests no longer trigger 100% CPU usage
- Working with sessions and session data is now realized through the Tygh::$app['session'] component
- Code for writing into a session: php Tygh::$app['session']['cart'] = array(); Tygh::$app['session']['cart']['products'][] = array();
- Code for reading from a session: php $cart = Tygh::$app['session']['cart']; // or by link $cart = & Tygh::$app['session']['cart']; It works the same way as working with $_SESSION directly. However, Tygh::$app['session'] belongs to the \Tygh\Web\Session class. This class replaces the old \Tygh\Session and allows to address to session data with the array syntax. The old Tygh\Session class is deprecated. However, it still works, because it proxies all method calls to the Tygh::$app['session']. We have replaced the usage of '\Tygh\Session with Tygh::$app['session'] in the core and default add-ons. The code that uses $_SESSION` directly may not work as intended with full-page caching turned on.
We also implemented service providers. A service provider is a class, an instance of which registers any components and values in the Application container (also known as Service Locator).
We added the \Tygh\Providers namespace and the first provider \Tygh\Providers\SessionProvider, that registers the values of session, session.storage and session.storage.class in the container.
- Code related to archiving and unpacking was refactored and moved to the \Tygh\Tools\Archivers namespace. All existing functions now internally use the new code with backward compatibility preserved. Also, the Archive_Tar class was re-included into CS-Cart and is used as a fallback in case of PharData class fails to perform.
Hook changes
New hooks
- fn_set_hook('render_block_pre', $block, $block_schema, $params, $block_content); - Allows to perform any actions before actually rendering a block
- fn_set_hook('render_block_post', $block, $block_schema, $block_content, $load_block_from_cache, $display_this_block, $params); - Allows to perform any actions after actually rendering a block
- fn_set_hook('registry_save_pre', self::$_changed_tables, self::$_cached_keys); - Hook is executed before saving cache data to persistent storage and clearing expired cache
- fn_set_hook('settings_update_value_by_id_pre', $this, $object_id, $value, $company_id, $execute_functions, $data, $old_data, $table); - Hook is executed before updating a setting value by setting an object ID
- fn_set_hook('settings_update_value_by_id_post', $this, $object_id, $value, $company_id, $execute_functions, $data, $old_data, $table); - Hook is executed after updating a setting value by setting an object ID
- fn_set_hook('buy_together_update_chain_pre', $item_id, $product_id, $item_data, $auth, $lang_code); - Modifies product chain update parameters
- fn_set_hook('buy_together_update_chain_post', $item_id, $product_id, $item_data, $auth, $lang_code); - Modifies product chain update results
- fn_set_hook('buy_together_get_chains_pre', $parms, $auth, $lang_code); - Modifies product chains get parameters
- fn_set_hook('buy_together_get_chains', $params, $auth, $lang_code, $fields, $conditions, $joins); - Change selection condition (fields, conditions, joins) before selecting a payment method data
- fn_set_hook('buy_together_get_chains_post', $params, $auth, $lang_code, $chains, $fields, $conditions, $joins); - Gets function result along with parameters and query information
- fn_set_hook('get_discussion_posts_pre', $params, $items_per_page); - Modifies request parameters for fetching discussion posts
- fn_set_hook('get_discussion_posts', $params, $items_per_page, $fields, $join, $condition, $order_by, $limit); - Modifies discuission posts query
- fn_set_hook('get_discussion_posts_post', $params, $items_per_page, $posts); - Modifies discussion posts and request parameters
- fn_set_hook('delete_discussion_pre', $object_id, $object_type); - Modifies discussed object properties
- fn_set_hook('delete_discussion_post', $object_id, $object_type, $is_deleted); - Modifies deletion results
- fn_set_hook('discussion_delete_post_pre', $post_id); - Modifies deleting discussion post identifier
- fn_set_hook('discussion_delete_post_post', $post_id); - Modifies deleted discussion post identifier
- fn_set_hook('get_discussion_titles', $discussion_object_titles); - Modifies title strings for different discussion types.
- fn_set_hook('image_zoom_check_image_post', $file_path, $image_data, $images); - Post hook for checking a detailed image sizes ration
- fn_set_hook('update_addon_status_pre', $addon, $status, $show_notification, $on_install, $allow_unmanaged, $old_status, $scheme); - Hook is executed before changing an add-on status (i.e. before an add-on enabling or disabling).
- fn_set_hook('update_addon_status_post', $addon, $status, $show_notification, $on_install, $allow_unmanaged, $old_status, $scheme); - Hook is executed after changing an add-on status (i.e. after an add-on enabling or disabling).
- fn_set_hook('filter_product_data', $request, $product_data); - Filters product data
- fn_set_hook('top_menu_form_pre', $top_menu, $level, $active); - Modifies top menu forming parameters
- fn_set_hook('top_menu_form_post', $top_menu, $level, $active); - Modifies top menu items
- fn_set_hook('update_customization_mode', $modes, $enabled_modes, $available_modes); - Hook is executed before saving enabled customization modes to DB.
- fn_set_hook('get_predefined_statuses', $type, $statuses, $status); - Prepares statuses for particular object type
- fn_set_hook('change_company_status_pre', $company_id, $status_to, $reason, $status_from, $skip_query, $notify); - Actions before a company status change
- fn_set_hook('change_company_status_before_mail', $company_id, $status_to, $reason, $status_from, $skip_query, $notify, $company_data, $user_data, $result); - Actions between changing a company status and sending an e-mail
- fn_set_hook('create_company_admin_pre', $company_data, $fields, $notify); - Actions before creating a company admin
- fn_set_hook('create_company_admin', $company_data, $fields, $notify, $user); - Actions before creating a company admin directly
- fn_set_hook('create_company_admin_post', $company_data, $fields, $notify, $user); - Actions after creating a company admin
- fn_set_hook('dispatch_before_send_response', $status, $area, $controller, $mode, $action); - Allows to perform actions before an HTTP response is sent to the client. This is the last place where you can modify the HTTP headers list.
- fn_set_hook('mve_place_order_post', $order_id, $action, $order_status, $cart, $auth, $order_info, $company_data, $data, $payout_id); - Actions after saving a vendor payout
Changed hooks
- fn_set_hook('top_menu_form', $v, $type, $id, $use_name); is now deprecated
-fn_set_hook('render_block_content_after', $block_schema, $block, $block_content); +fn_set_hook('render_block_content_after', $block_schema, $block, $block_content, $params, $load_block_from_cache);
-fn_set_hook('get_categories_after_sql', $categories, $params); +fn_set_hook('get_categories_after_sql', $categories, $params, $join, $condition, $fields, $group_by, $sortings, $sorting, $limit, $lang_code);
-fn_set_hook('get_category_data', $category_id, $field_list, $join, $lang_code); +fn_set_hook('get_category_data', $category_id, $field_list, $join, $lang_code, $conditions);
-fn_set_hook('clone_product_option_post', $from_product_id, $to_product_id, $from_global_option_id, $v); +fn_set_hook('clone_product_option_post', $from_product_id, $to_product_id, $from_global_option_id, $option_data, $change_options, $change_variants);
-fn_set_hook('delete_status_pre', $status, $type, $can_delete); +fn_set_hook('delete_status_pre', $status, $type, $can_delete, $is_default, $status_id);
-fn_set_hook('delete_status_post', $status, $type, $can_delete); +fn_set_hook('delete_status_post', $status, $type, $can_delete, $is_default, $status_id);
-fn_set_hook('update_image', $image_data, $image_id, $image_type, $images_path, $_data); +fn_set_hook('update_image', $image_data, $image_id, $image_type, $images_path, $_data, $mime_type);
-fn_set_hook('mve_place_order', $order_info, $company_data, $action, $__order_status, $cart, $_data); +fn_set_hook('mve_place_order', $order_info, $company_data, $action, $order_status, $cart, $data, $payout_id, $auth);
Core functions
Changed functions
- \Tygh\Themes\Styles::getCustomFonts() became public
- \Tygh\Tools\Url::__construct() now can be called without any arguments
- fn_exim_set_quotes() is now deprecated in favour of fn_exim_quote()
- fn_companies_change_status() is now deprecated in favour of fn_change_company_status()
-public static function sanitizeData(array $data, array $rules, array $disabled_actions = array()) +public static function sanitizeData(array $data, array $rules, array $disabled_actions = array(), &$changed = false)
-function fn_install_addon($addon, $show_notification = true, $install_demo = false) +function fn_install_addon($addon, $show_notification = true, $install_demo = false, $allow_unmanaged = false)
-function fn_update_addon_status($addon, $status, $show_notification = true, $on_install = false) +function fn_update_addon_status($addon, $status, $show_notification = true, $on_install = false, $allow_unmanaged = false)
-function fn_get_subcategories($category_id = '0', $lang_code = CART_LANGUAGE) // backward compatibility preserved +function fn_get_subcategories($category_id = '0', $params = array(), $lang_code = CART_LANGUAGE)
-function fn_delete_status($status, $type) +function fn_delete_status($status, $type, $is_default = false)
-function fn_create_theme_logos_by_layout_id($theme_name, $layout_id = 0, $company_id = null, $for_company = false, $style_id = '') +function fn_create_theme_logos_by_layout_id($theme_name, $layout_id = 0, $company_id = null, $for_company = false, $style_id = '', $whitelist_of_logo_types = null)
-function fn_get_logos($company_id = null, $layout_id = 0, $style_id = '') +function fn_get_logos($company_id = null, $layout_id = null, $style_id = null)
-function fn_generate_thumbnail($image_path, $width, $height = 0, $lazy = false) +function fn_generate_thumbnail($image_path, $width, $height = 0, $lazy = false, $return_rel_path = false)
-function fn_login_user($user_id = '') +function fn_login_user($user_id = 0, $regenerate_session_id = false)
New functions
- \Tygh\Themes\Styles::createMissedLogoTypesForLayout($layout_id, $style_id)- Creates logos of missing logo types for a given layout and style.
- \Tygh\Themes\Themes::setManifest($manifest_data) - Sets theme manifest contents.
- \Tygh\Themes\Themes::getSettingsOverrides($lang_code = CART_LANGUAGE) - Gets theme setting overrides
- \Tygh\Themes\Themes::overrideSettings($settings = null, $company_id = null) - Overrides settings values from a theme manifest file
- \Tygh\Themes\Themes::cloneAs($clone_name, $clone_data = array(), $company_id = 0) - Creates a clone of a theme.
- \Tygh\Registry::getAll() - Returns all variables stored in the registry
- \Tygh\Registry::getAll() - Returns all cache keys
- \Tygh\Tools\Url::setHost()
- \Tygh\Tools\Url::setQueryString()
- \Tygh\Tools\Url::getQueryString()
- \Tygh\Tools\Url::setPath()
- \Tygh\Tools\Url::getPath()
- \Tygh\Tools\Url::containsAsSubpath(self $url) - Checks if a given URL is a subpart of the current URL by matching their paths
- fn_image_zoom_check_image(&$image_data, &$images) - Checks a detailed image sizes ration
- fn_seo_get_canonical_links($base_url, $search) - Generates SEO Canonical, Prev, Next links
- fn_exim_quote(&$value, $quote = "'")
- fn_exim_apply_company($pattern, &$alt_keys, &$object, &$skip_get_primary_object_id) - Adds the current company_id as altkey if an object doesn't have store defined. Needed to determine the primary object correctly.
- fn_promotions_filter_data($data) - Filtration conditions and bonus values
- fn_promotions_filter_conditions($conditions) - Filtration conditions values
- fn_promotions_filter_bonuses($bonuses) - Filtration bonus values
- fn_get_addon_layouts_path($addon_name, $theme_name = '[theme]') - Returns path to the add-on layouts file in a specified theme
- fn_store_shipping_rates($order_id = 0, &$cart, $customer_auth) - Stores shipping rates when managing an order
- fn_filter_product_data(&$request, &$product_data) - Filters product data before saving
- fn_check_change_store_mode_permission() - Checks permission for the store mode change
- fn_get_predefined_statuses($type, $status = '') - Gets a list of the predefined statuses for a particular object type
- fn_delete_status_by_id($status_id) - Deletes a status, its description, and data by the status identifier
- fn_get_status_id($status, $type, $is_default = null) - Returns a status identifier by the status code and type
- fn_get_statuses_by_type($type) - Returns statuses of a specified type
- fn_change_company_status($company_id, $status_to, $reason = '', &$status_from = '', $skip_query = false, $notify = true) - Changes a company status. Allowed statuses are A(ctive) and D(isabled).
- fn_create_company_admin($company_data, $fields = '', $notify = false) - Creates a company admin
- fn_check_current_user_access($permission) - Checks if the current user has access to the specified permission