Projekt

Allgemein

Profil

GX-Bug #55956 » SEOBOOSTRepairFix.patch

Till Tepelmann, 29.03.2018 21:57

Unterschiede anzeigen:

src/gm/classes/GMSEOBoost.php (date 1522353173000)
1034 1034
	}
1035 1035
	
1036 1036
	
1037
	public function repair($p_type = 'all')
1037
	public function repair($p_type = 'all', $p_id = 0)
1038 1038
	{
1039 1039
		if($p_type == 'all' || $p_type == 'products')
1040 1040
		{
1041
			$t_get_languages_ids = xtc_db_query("SELECT languages_id
1041
			if(!empty($p_id))
1042
			{
1043
				$t_get_empty_keywords_ids = xtc_db_query("SELECT products_id
1044
													FROM " . TABLE_PRODUCTS_DESCRIPTION . "
1045
													WHERE
1046
													(gm_url_keywords = '' OR LENGTH(gm_url_keywords) >= 255)
1047
													AND products_id = '" . $p_id . "'
1048
													", 'db_link', false);
1049
				
1050
				$t_get_double_keywords_ids = xtc_db_query("select count(gm_url_keywords) as count from `products_description` group by gm_url_keywords,language_id HAVING count > 1",
1051
				                                          'db_link', false);
1052
			}
1053
			if(empty($p_id) || xtc_db_num_rows($t_get_empty_keywords_ids) > 0 || xtc_db_num_rows($t_get_double_keywords_ids) > 0)
1054
			{
1055
				
1056
				$t_get_languages_ids = xtc_db_query("SELECT languages_id
1042 1057
													FROM " . TABLE_LANGUAGES . "", 'db_link', false);
1043
			while($t_result_array = xtc_db_fetch_array($t_get_languages_ids))
1044
			{
1045
				$c_languages_id = (int)$t_result_array['languages_id'];
1046
				
1047
				$t_get_empty_keywords = xtc_db_query("SELECT
1058
				while($t_result_array = xtc_db_fetch_array($t_get_languages_ids))
1059
				{
1060
					$c_languages_id = (int)$t_result_array['languages_id'];
1061
					
1062
					$t_get_empty_keywords = xtc_db_query("SELECT
1048 1063
															products_id,
1049 1064
															products_name
1050 1065
														FROM " . TABLE_PRODUCTS_DESCRIPTION . "
1051 1066
														WHERE
1052 1067
															(gm_url_keywords = '' OR LENGTH(gm_url_keywords) >= 255)
1053 1068
															AND language_id = '" . $c_languages_id . "'", 'db_link',
1054
				                                     false);
1055
				while($t_product_array = xtc_db_fetch_array($t_get_empty_keywords))
1056
				{
1057
					$c_cleaned_name = $this->clean_keyword($t_product_array['products_name']);
1058
					if(strlen_wrapper($c_cleaned_name . '-' . $t_product_array['products_id']) >= 255)
1059
					{
1060
						$c_cleaned_name = substr_wrapper($c_cleaned_name, 0, 100);
1061
					}
1062
					
1063
					if($c_cleaned_name != '')
1064
					{
1065
						$t_update = xtc_db_query("UPDATE " . TABLE_PRODUCTS_DESCRIPTION . "
1069
					                                     false);
1070
					while($t_product_array = xtc_db_fetch_array($t_get_empty_keywords))
1071
					{
1072
						$c_cleaned_name = $this->clean_keyword($t_product_array['products_name']);
1073
						if(strlen_wrapper($c_cleaned_name . '-' . $t_product_array['products_id']) >= 255)
1074
						{
1075
							$c_cleaned_name = substr_wrapper($c_cleaned_name, 0, 100);
1076
						}
1077
						
1078
						if($c_cleaned_name != '')
1079
						{
1080
							$t_update = xtc_db_query("UPDATE " . TABLE_PRODUCTS_DESCRIPTION . "
1066 1081
													SET gm_url_keywords = '" . $c_cleaned_name . "'
1067 1082
													WHERE
1068 1083
														products_id = '" . (int)$t_product_array['products_id'] . "'
1069 1084
														AND language_id = '" . $c_languages_id . "'", 'db_link', false);
1070
					}
1071
					else
1072
					{
1073
						$t_update = xtc_db_query("UPDATE " . TABLE_PRODUCTS_DESCRIPTION . "
1085
						}
1086
						else
1087
						{
1088
							$t_update = xtc_db_query("UPDATE " . TABLE_PRODUCTS_DESCRIPTION . "
1074 1089
													SET gm_url_keywords = 'product-"
1075
						                         . (int)$t_product_array['products_id'] . "'
1090
							                         . (int)$t_product_array['products_id'] . "'
1076 1091
													WHERE
1077 1092
														products_id = '" . (int)$t_product_array['products_id'] . "'
1078 1093
														AND language_id = '" . $c_languages_id . "'", 'db_link', false);
1079
					}
1080
				}
1081
				
1082
				$t_found_double_keywords = true;
1083
				
1084
				while($t_found_double_keywords)
1085
				{
1086
					$t_products_array = array();
1087
					$t_found          = false;
1088
					
1089
					$t_get_double_keywords = xtc_db_query("SELECT DISTINCT
1094
						}
1095
					}
1096
					
1097
					$t_found_double_keywords = true;
1098
					
1099
					while($t_found_double_keywords)
1100
					{
1101
						$t_products_array = [];
1102
						$t_found          = false;
1103
						
1104
						$t_get_double_keywords = xtc_db_query("SELECT DISTINCT
1090 1105
																a.products_id,
1091 1106
																a.gm_url_keywords
1092 1107
															FROM " . TABLE_PRODUCTS_DESCRIPTION . " a
1093 1108
															LEFT JOIN " . TABLE_PRODUCTS_DESCRIPTION . " AS b ON ("
1094
					                                      . $this->v_binary_string . "a.gm_url_keywords = "
1095
					                                      . $this->v_binary_string . "b.gm_url_keywords)
1109
						                                      . $this->v_binary_string . "a.gm_url_keywords = "
1110
						                                      . $this->v_binary_string . "b.gm_url_keywords)
1096 1111
															WHERE
1097 1112
																a.products_id != b.products_id
1098 1113
																AND a.language_id = '" . $c_languages_id . "'
1099 1114
																AND b.language_id = '" . $c_languages_id . "'
1100 1115
															ORDER BY a.products_id", 'db_link', false);
1101
					
1102
					while($t_result_array = xtc_db_fetch_array($t_get_double_keywords))
1103
					{
1104
						$t_found                                          = true;
1105
						$t_products_array[$t_result_array['products_id']] = $t_result_array['gm_url_keywords'];
1106
					}
1107
					
1108
					if(!$t_found)
1109
					{
1110
						$t_found_double_keywords = false;
1111
					}
1112
					else
1113
					{
1114
						$t_cleared_keywords_array = array();
1115
						
1116
						foreach($t_products_array AS $t_products_id => $t_gm_url_keywords)
1117
						{
1118
							$t_keys_array = array();
1119
							$t_keys_array = array_keys($t_products_array, $t_gm_url_keywords);
1120
							
1121
							for($i = 1; $i < count($t_keys_array); $i++)
1122
							{
1123
								if(!in_array($t_gm_url_keywords, $t_cleared_keywords_array))
1124
								{
1125
									$t_new_url_keyword = preg_replace('/(.+?)(-[0-9]+)$/', "$1", $t_gm_url_keywords);
1126
									$c_new_url_keyword = ((isset($GLOBALS["___mysqli_ston"])
1127
									                       && is_object($GLOBALS["___mysqli_ston"])) ? mysqli_real_escape_string($GLOBALS["___mysqli_ston"],
1128
									                                                                                             $t_new_url_keyword) : ((trigger_error("[MySQLConverterToo] Fix the mysql_escape_string() call! This code does not work.",
1129
									                                                                                                                                   E_USER_ERROR)) ? "" : ""));
1130
									
1131
									$t_sql_products_id = $t_keys_array[$i];
1132
									if($c_new_url_keyword . '-' . $t_keys_array[$i] == $t_gm_url_keywords)
1133
									{
1134
										$t_sql_products_id = $t_keys_array[0];
1135
									}
1136
									
1137
									$t_update = xtc_db_query("UPDATE " . TABLE_PRODUCTS_DESCRIPTION . "
1116
						
1117
						while($t_result_array = xtc_db_fetch_array($t_get_double_keywords))
1118
						{
1119
							$t_found                                          = true;
1120
							$t_products_array[$t_result_array['products_id']] = $t_result_array['gm_url_keywords'];
1121
						}
1122
						
1123
						if(!$t_found)
1124
						{
1125
							$t_found_double_keywords = false;
1126
						}
1127
						else
1128
						{
1129
							$t_cleared_keywords_array = [];
1130
							
1131
							foreach($t_products_array AS $t_products_id => $t_gm_url_keywords)
1132
							{
1133
								$t_keys_array = [];
1134
								$t_keys_array = array_keys($t_products_array, $t_gm_url_keywords);
1135
								
1136
								for($i = 1; $i < count($t_keys_array); $i++)
1137
								{
1138
									if(!in_array($t_gm_url_keywords, $t_cleared_keywords_array))
1139
									{
1140
										$t_new_url_keyword = preg_replace('/(.+?)(-[0-9]+)$/', "$1",
1141
										                                  $t_gm_url_keywords);
1142
										$c_new_url_keyword = ((isset($GLOBALS["___mysqli_ston"])
1143
										                       && is_object($GLOBALS["___mysqli_ston"]))
1144
											? mysqli_real_escape_string($GLOBALS["___mysqli_ston"], $t_new_url_keyword)
1145
											: ((trigger_error("[MySQLConverterToo] Fix the mysql_escape_string() call! This code does not work.",
1146
											                  E_USER_ERROR))
1147
												? ""
1148
												: ""));
1149
										
1150
										$t_sql_products_id = $t_keys_array[$i];
1151
										if($c_new_url_keyword . '-' . $t_keys_array[$i] == $t_gm_url_keywords)
1152
										{
1153
											$t_sql_products_id = $t_keys_array[0];
1154
										}
1155
										
1156
										$t_update = xtc_db_query("UPDATE " . TABLE_PRODUCTS_DESCRIPTION . "
1138 1157
																SET gm_url_keywords = '" . $c_new_url_keyword . "-"
1139
									                         . (int)$t_sql_products_id . "'
1158
										                         . (int)$t_sql_products_id . "'
1140 1159
																WHERE
1141 1160
																	products_id = '" . (int)$t_sql_products_id . "'
1142 1161
																	AND language_id = '" . $c_languages_id . "'",
1143
									                         'db_link', false);
1144
								}
1145
							}
1146
							
1147
							$t_cleared_keywords_array[] = $t_gm_url_keywords;
1162
										                         'db_link', false);
1163
									}
1164
								}
1165
								
1166
								$t_cleared_keywords_array[] = $t_gm_url_keywords;
1167
							}
1148 1168
						}
1149 1169
					}
1150 1170
				}
src/GXMainComponents/Services/Core/Product/ProductWriteService.inc.php (date 1522352940000)
124 124
		$this->productRepo->store($product);
125 125
		
126 126
		// set url keywords
127
		$this->urlKeywordsRepairer->repair('products');
127
		$this->urlKeywordsRepairer->repair('products',$product->getProductId());
128 128

  
129 129
		return $this;
130 130
	}
src/GXMainComponents/Shared/Interfaces/UrlKeywordsRepairerInterface.inc.php (date 1522353308000)
21 21
	/**
22 22
	 * @param string $type all|products|categories|contents
23 23
	 *
24
	 * @param int $p_id
25
	 *
24 26
	 * @return null
25 27
	 */
26
	public function repair($type = 'all');
28
	public function repair($type = 'all', $p_id = 0);
27 29
}
    (1-1/1)