/**
  * Fixes database errors.
  *
  * Also migrates settings from the old Shop settings table to \Cx\Core\Setting.
  * @return  boolean                 False.  Always.
  * @throws  Cx\Lib\Update_DatabaseException
  */
 static function errorHandler()
 {
     global $_CONFIGURATION;
     // ShopSettings
     \Cx\Core\Setting\Controller\Setting::errorHandler();
     \Cx\Core\Setting\Controller\Setting::init('Shop', 'config');
     $table_name = DBPREFIX . 'module_shop_config';
     $i = 0;
     if (\Cx\Lib\UpdateUtil::table_exist($table_name)) {
         // Migrate all entries using the \Cx\Core\Setting\Controller\Setting class
         $query = "\n                SELECT `name`, `value`, `status`\n                  FROM " . DBPREFIX . "module_shop_config\n                 ORDER BY `id` ASC";
         $objResult = \Cx\Lib\UpdateUtil::sql($query);
         if (!$objResult) {
             throw new \Cx\Lib\Update_DatabaseException('Failed to query old Shop settings', $query);
         }
         while (!$objResult->EOF) {
             $name = $objResult->fields['name'];
             $value = $objResult->fields['value'];
             $status = $objResult->fields['status'];
             $name_status = null;
             switch ($name) {
                 // OBSOLETE
                 case 'tax_default_id':
                 case 'tax_enabled':
                 case 'tax_included':
                 case 'tax_number':
                     // Ignore, do not migrate!
                     $name = null;
                     break;
                     // VALUE ONLY (RE: arrConfig\[.*?\]\[.value.\])
                 // VALUE ONLY (RE: arrConfig\[.*?\]\[.value.\])
                 case 'confirmation_emails':
                     $name = 'email_confirmation';
                     break;
                 case 'country_id':
                 case 'datatrans_merchant_id':
                 case 'datatrans_request_type':
                     break;
                 case 'datatrans_status':
                     $name = 'datatrans_active';
                     break;
                 case 'datatrans_use_testserver':
                 case 'email':
                 case 'fax':
                 case 'orderitems_amount_max':
                 case 'paypal_default_currency':
                 case 'postfinance_mobile_ijustwanttotest':
                 case 'postfinance_mobile_sign':
                 case 'postfinance_mobile_status':
                 case 'postfinance_mobile_webuser':
                 case 'product_sorting':
                 case 'saferpay_finalize_payment':
                 case 'saferpay_window_option':
                     break;
                 case 'shop_address':
                 case 'shop_company':
                 case 'shop_show_products_default':
                 case 'shop_thumbnail_max_height':
                 case 'shop_thumbnail_max_width':
                 case 'shop_thumbnail_quality':
                 case 'shop_weight_enable':
                     $name = preg_replace('/^shop_/', '', $name);
                     break;
                 case 'telephone':
                 case 'vat_default_id':
                 case 'vat_enabled_foreign_customer':
                 case 'vat_enabled_foreign_reseller':
                 case 'vat_enabled_home_customer':
                 case 'vat_enabled_home_reseller':
                 case 'vat_included_foreign_customer':
                 case 'vat_included_foreign_reseller':
                 case 'vat_included_home_customer':
                 case 'vat_included_home_reseller':
                 case 'vat_number':
                 case 'vat_other_id':
                     break;
                 case 'yellowpay_accepted_payment_methods':
                 case 'yellowpay_authorization_type':
                 case 'yellowpay_hash_seed':
                 case 'yellowpay_hash_signature_in':
                 case 'yellowpay_hash_signature_out':
                 case 'yellowpay_use_testserver':
                     $name = preg_replace('/^yellowpay(.*)$/', 'postfinance$1', $name);
                     break;
                 case 'yellowpay_id':
                     // Obsolete
                     $name = null;
                     break;
                     // VALUE & STATUS
                 // VALUE & STATUS
                 case 'paypal_account_email':
                     $name_status = 'paypal_active';
                     break;
                 case 'saferpay_id':
                     $name_status = 'saferpay_active';
                     break;
                 case 'yellowpay_shop_id':
                     $name = 'postfinance_shop_id';
                     $name_status = 'postfinance_active';
                     break;
                     // STATUS ONLY (RE: arrConfig\[.*?\]\[.status.\])
                 // STATUS ONLY (RE: arrConfig\[.*?\]\[.status.\])
                 case 'payment_lsv_status':
                     $name_status = 'payment_lsv_active';
                     $name = null;
                     break;
                 case 'saferpay_use_test_account':
                     $name_status = $name;
                     $name = null;
                     break;
             }
             if ($name) {
                 if (\Cx\Core\Setting\Controller\Setting::getValue($name, 'Shop') === NULL && !\Cx\Core\Setting\Controller\Setting::add($name, $value, ++$i)) {
                     throw new \Cx\Lib\Update_DatabaseException("Failed to add \\Cx\\Core\\Setting entry for '{$name}'");
                 }
             }
             if ($name_status) {
                 if (\Cx\Core\Setting\Controller\Setting::getValue($name_status, 'Shop') === NULL && !\Cx\Core\Setting\Controller\Setting::add($name_status, $status, ++$i)) {
                     throw new \Cx\Lib\Update_DatabaseException("Failed to add \\Cx\\Core\\Setting entry for status '{$name_status}'");
                 }
             }
             $objResult->MoveNext();
         }
     }
     \Cx\Core\Setting\Controller\Setting::init('Shop', 'config');
     // Try adding any that just *might* be missing for *any* reason
     \Cx\Core\Setting\Controller\Setting::add('email', '*****@*****.**', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('email_confirmation', '*****@*****.**', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('company', 'Comvation AG', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('address', 'Burgstrasse 20', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('country_id', 204, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('telephone', '+4133 2266000', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('fax', '+4133 2266001', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('vat_number', '12345678', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('vat_enabled_foreign_customer', 0, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('vat_enabled_foreign_reseller', 0, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('vat_enabled_home_customer', 1, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('vat_enabled_home_reseller', 1, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('vat_included_foreign_customer', 0, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('vat_included_foreign_reseller', 0, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('vat_included_home_customer', 1, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('vat_included_home_reseller', 1, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('vat_default_id', 1, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('vat_other_id', 1, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('weight_enable', 0, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('show_products_default', 0, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('product_sorting', 0, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_DROPDOWN, '0:TXT_SHOP_PRODUCT_SORTING_ALPHABETIC,' . '1:TXT_SHOP_PRODUCT_SORTING_INDIVIDUAL,' . '2:TXT_SHOP_PRODUCT_SORTING_PRODUCTCODE', 'config');
     \Cx\Core\Setting\Controller\Setting::add('thumbnail_max_width', 140, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('thumbnail_max_height', 140, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('thumbnail_quality', 90, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('saferpay_id', '1234', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('saferpay_active', 1, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('saferpay_use_test_account', 1, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('saferpay_finalize_payment', 1, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('saferpay_window_option', 2, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('paypal_active', 1, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('paypal_account_email', '*****@*****.**', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('paypal_default_currency', 'CHF', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     // Also see Yellowpay.class
     \Cx\Core\Setting\Controller\Setting::add('payrexx_instance_name', 'Instanz Name', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT);
     \Cx\Core\Setting\Controller\Setting::add('payrexx_api_secret', 'API Secret', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT);
     \Cx\Core\Setting\Controller\Setting::add('payrexx_active', '0', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_CHECKBOX, '1');
     \Cx\Core\Setting\Controller\Setting::add('postfinance_shop_id', 'Ihr Kontoname', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT);
     \Cx\Core\Setting\Controller\Setting::add('postfinance_active', '0', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_CHECKBOX, '1');
     \Cx\Core\Setting\Controller\Setting::add('postfinance_authorization_type', 'SAL', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_DROPDOWN, 'RES:Reservation,SAL:Verkauf');
     // OBSOLETE
     // As it appears that in_array(0, $array) is true for each non-empty
     // $array, indices for the entries must be numbered starting at 1.
     //        $arrPayments = array();
     //        foreach (self::$arrKnownPaymentMethod as $index => $name) {
     //            $arrPayments[$index] = $name;
     //        }
     //        \Cx\Core\Setting\Controller\Setting::add('postfinance_accepted_payment_methods', '', ++$i,
     //                \Cx\Core\Setting\Controller\Setting::TYPE_CHECKBOXGROUP,
     //                \Cx\Core\Setting\Controller\Setting::joinValues($arrPayments));
     \Cx\Core\Setting\Controller\Setting::add('postfinance_hash_signature_in', 'Mindestens 16 Buchstaben, Ziffern und Zeichen', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT);
     \Cx\Core\Setting\Controller\Setting::add('postfinance_hash_signature_out', 'Mindestens 16 Buchstaben, Ziffern und Zeichen', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT);
     \Cx\Core\Setting\Controller\Setting::add('postfinance_use_testserver', '1', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_CHECKBOX, '1');
     \Cx\Core\Setting\Controller\Setting::add('postfinance_mobile_webuser', '1234', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('postfinance_mobile_sign', 'geheimer_schlüssel', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('postfinance_mobile_ijustwanttotest', 1, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('postfinance_mobile_status', 1, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('datatrans_merchant_id', '1234', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('datatrans_active', 1, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('datatrans_request_type', 'CAA', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('datatrans_use_testserver', 1, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('payment_lsv_active', 0, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     // New for V3.0
     // Disable jsCart by default.
     $useJsCart = '0';
     // Activate it in case it was activated in config/configuration.php
     if (isset($_CONFIGURATION['custom']['shopJsCart']) && $_CONFIGURATION['custom']['shopJsCart']) {
         $useJsCart = '1';
     }
     \Cx\Core\Setting\Controller\Setting::add('use_js_cart', $useJsCart, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_CHECKBOX);
     // Disable shopnavbar on other pages by default.
     $shopnavbar = '0';
     // Activate it in case it was activated in config/configuration.php
     if (isset($_CONFIGURATION['custom']['shopnavbar']) && $_CONFIGURATION['custom']['shopnavbar']) {
         $shopnavbar = '1';
     }
     \Cx\Core\Setting\Controller\Setting::add('shopnavbar_on_all_pages', $shopnavbar, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_CHECKBOX);
     // New for v3.1.0
     \Cx\Core\Setting\Controller\Setting::add('orderitems_amount_min', 0, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     // New for v2.2(?)
     \Cx\Core\Setting\Controller\Setting::add('orderitems_amount_max', 0, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     // New for v2.3
     \Cx\Core\Setting\Controller\Setting::add('register', ShopLibrary::REGISTER_MANDATORY, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_DROPDOWN, \Cx\Core\Setting\Controller\Setting::joinValues(array(ShopLibrary::REGISTER_MANDATORY, ShopLibrary::REGISTER_OPTIONAL, ShopLibrary::REGISTER_NONE)), 'config');
     \Cx\Core\Setting\Controller\Setting::add('numof_products_per_page_frontend', 25, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('history_maximum_age_days', 730, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('numof_orders_per_page_frontend', 10, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('numof_orders_per_page_backend', 25, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('numof_customers_per_page_backend', 25, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('numof_manufacturers_per_page_backend', 25, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('numof_mailtemplate_per_page_backend', 25, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('numof_coupon_per_page_backend', 25, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('usergroup_id_customer', 0, 341, \Cx\Core\Setting\Controller\Setting::TYPE_DROPDOWN_USERGROUP, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('usergroup_id_reseller', 0, 342, \Cx\Core\Setting\Controller\Setting::TYPE_DROPDOWN_USERGROUP, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('user_profile_attribute_customer_group_id', 0, 351, \Cx\Core\Setting\Controller\Setting::TYPE_DROPDOWN_USER_CUSTOM_ATTRIBUTE, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('user_profile_attribute_notes', 0, 352, \Cx\Core\Setting\Controller\Setting::TYPE_DROPDOWN_USER_CUSTOM_ATTRIBUTE, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('num_categories_per_row', 4, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     // Note that the Settings *MUST* be reinited after adding new entries!
     // Add more new/missing settings here
     \Cx\Lib\UpdateUtil::drop_table($table_name);
     // Always
     return false;
 }