Advertisement
Guest User

Untitled

a guest
Apr 21st, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.72 KB | None | 0 0
  1. #!/bin/bash
  2. # Patch apllying tool template
  3. # v0.1.2
  4. # (c) Copyright 2013. Magento Inc.
  5. #
  6. # DO NOT CHANGE ANY LINE IN THIS FILE.
  7.  
  8. # 1. Check required system tools
  9. _check_installed_tools() {
  10. local missed=""
  11.  
  12. until [ -z "$1" ]; do
  13. type -t $1 >/dev/null 2>/dev/null
  14. if (( $? != 0 )); then
  15. missed="$missed $1"
  16. fi
  17. shift
  18. done
  19.  
  20. echo $missed
  21. }
  22.  
  23. REQUIRED_UTILS='sed patch'
  24. MISSED_REQUIRED_TOOLS=`_check_installed_tools $REQUIRED_UTILS`
  25. if (( `echo $MISSED_REQUIRED_TOOLS | wc -w` > 0 ));
  26. then
  27. echo -e "Error! Some required system tools, that are utilized in this sh script, are not installed:\nTool(s) \"$MISSED_REQUIRED_TOOLS\" is(are) missed, please install it(them)."
  28. exit 1
  29. fi
  30.  
  31. # 2. Determine bin path for system tools
  32. CAT_BIN=`which cat`
  33. PATCH_BIN=`which patch`
  34. SED_BIN=`which sed`
  35. PWD_BIN=`which pwd`
  36. BASENAME_BIN=`which basename`
  37.  
  38. BASE_NAME=`$BASENAME_BIN "$0"`
  39.  
  40. # 3. Help menu
  41. if [ "$1" = "-?" -o "$1" = "-h" -o "$1" = "--help" ]
  42. then
  43. $CAT_BIN << EOFH
  44. Usage: sh $BASE_NAME [--help] [-R|--revert] [--list]
  45. Apply embedded patch.
  46.  
  47. -R, --revert Revert previously applied embedded patch
  48. --list Show list of applied patches
  49. --help Show this help message
  50. EOFH
  51. exit 0
  52. fi
  53.  
  54. # 4. Get "revert" flag and "list applied patches" flag
  55. REVERT_FLAG=
  56. SHOW_APPLIED_LIST=0
  57. if [ "$1" = "-R" -o "$1" = "--revert" ]
  58. then
  59. REVERT_FLAG=-R
  60. fi
  61. if [ "$1" = "--list" ]
  62. then
  63. SHOW_APPLIED_LIST=1
  64. fi
  65.  
  66. # 5. File pathes
  67. CURRENT_DIR=`$PWD_BIN`/
  68. APP_ETC_DIR=`echo "$CURRENT_DIR""app/etc/"`
  69. APPLIED_PATCHES_LIST_FILE=`echo "$APP_ETC_DIR""applied.patches.list"`
  70.  
  71. # 6. Show applied patches list if requested
  72. if [ "$SHOW_APPLIED_LIST" -eq 1 ] ; then
  73. echo -e "Applied/reverted patches list:"
  74. if [ -e "$APPLIED_PATCHES_LIST_FILE" ]
  75. then
  76. if [ ! -r "$APPLIED_PATCHES_LIST_FILE" ]
  77. then
  78. echo "ERROR: \"$APPLIED_PATCHES_LIST_FILE\" must be readable so applied patches list can be shown."
  79. exit 1
  80. else
  81. $SED_BIN -n "/SUP-\|SUPEE-/p" $APPLIED_PATCHES_LIST_FILE
  82. fi
  83. else
  84. echo "<empty>"
  85. fi
  86. exit 0
  87. fi
  88.  
  89. # 7. Check applied patches track file and its directory
  90. _check_files() {
  91. if [ ! -e "$APP_ETC_DIR" ]
  92. then
  93. echo "ERROR: \"$APP_ETC_DIR\" must exist for proper tool work."
  94. exit 1
  95. fi
  96.  
  97. if [ ! -w "$APP_ETC_DIR" ]
  98. then
  99. echo "ERROR: \"$APP_ETC_DIR\" must be writeable for proper tool work."
  100. exit 1
  101. fi
  102.  
  103. if [ -e "$APPLIED_PATCHES_LIST_FILE" ]
  104. then
  105. if [ ! -w "$APPLIED_PATCHES_LIST_FILE" ]
  106. then
  107. echo "ERROR: \"$APPLIED_PATCHES_LIST_FILE\" must be writeable for proper tool work."
  108. exit 1
  109. fi
  110. fi
  111. }
  112.  
  113. _check_files
  114.  
  115. # 8. Apply/revert patch
  116. # Note: there is no need to check files permissions for files to be patched.
  117. # "patch" tool will not modify any file if there is not enough permissions for all files to be modified.
  118. # Get start points for additional information and patch data
  119. SKIP_LINES=$((`$SED_BIN -n "/^__PATCHFILE_FOLLOWS__$/=" "$CURRENT_DIR""$BASE_NAME"` + 1))
  120. ADDITIONAL_INFO_LINE=$(($SKIP_LINES - 3))p
  121.  
  122. _apply_revert_patch() {
  123. DRY_RUN_FLAG=
  124. if [ "$1" = "dry-run" ]
  125. then
  126. DRY_RUN_FLAG=" --dry-run"
  127. echo "Checking if patch can be applied/reverted successfully..."
  128. fi
  129. PATCH_APPLY_REVERT_RESULT=`$SED_BIN -e '1,/^__PATCHFILE_FOLLOWS__$/d' "$CURRENT_DIR""$BASE_NAME" | $PATCH_BIN $DRY_RUN_FLAG $REVERT_FLAG -p0`
  130. PATCH_APPLY_REVERT_STATUS=$?
  131. if [ $PATCH_APPLY_REVERT_STATUS -eq 1 ] ; then
  132. echo -e "ERROR: Patch can't be applied/reverted successfully.\n\n$PATCH_APPLY_REVERT_RESULT"
  133. exit 1
  134. fi
  135. if [ $PATCH_APPLY_REVERT_STATUS -eq 2 ] ; then
  136. echo -e "ERROR: Patch can't be applied/reverted successfully."
  137. exit 2
  138. fi
  139. }
  140.  
  141. REVERTED_PATCH_MARK=
  142. if [ -n "$REVERT_FLAG" ]
  143. then
  144. REVERTED_PATCH_MARK=" | REVERTED"
  145. fi
  146.  
  147. _apply_revert_patch dry-run
  148. _apply_revert_patch
  149.  
  150. # 9. Track patch applying result
  151. echo "Patch was applied/reverted successfully."
  152. ADDITIONAL_INFO=`$SED_BIN -n ""$ADDITIONAL_INFO_LINE"" "$CURRENT_DIR""$BASE_NAME"`
  153. APPLIED_REVERTED_ON_DATE=`date -u +"%F %T UTC"`
  154. APPLIED_REVERTED_PATCH_INFO=`echo -n "$APPLIED_REVERTED_ON_DATE"" | ""$ADDITIONAL_INFO""$REVERTED_PATCH_MARK"`
  155. echo -e "$APPLIED_REVERTED_PATCH_INFO\n$PATCH_APPLY_REVERT_RESULT\n\n" >> "$APPLIED_PATCHES_LIST_FILE"
  156.  
  157. exit 0
  158.  
  159.  
  160. SUPEE-9465 | EE_1.14.3.0 | v1 | 7d25fe4a71ddef999149201624e0ad573697df8c | Sat Nov 26 04:20:37 2016 +0200 | v1.14.3.0..HEAD
  161.  
  162. __PATCHFILE_FOLLOWS__
  163. diff --git app/code/core/Enterprise/PageCache/Model/Processor/Category.php app/code/core/Enterprise/PageCache/Model/Processor/Category.php
  164. index 2677e73..7d86127 100644
  165. --- app/code/core/Enterprise/PageCache/Model/Processor/Category.php
  166. +++ app/code/core/Enterprise/PageCache/Model/Processor/Category.php
  167. @@ -49,6 +49,8 @@ class Enterprise_PageCache_Model_Processor_Category extends Enterprise_PageCache
  168. * Filter input parameters using parameters map
  169. * @param array $inputParameters
  170. *
  171. + * @deprecated
  172. + *
  173. * @return array
  174. */
  175. protected function _filterInputParameters($inputParameters)
  176. @@ -97,9 +99,9 @@ class Enterprise_PageCache_Model_Processor_Category extends Enterprise_PageCache
  177.  
  178. $sessionParams = Enterprise_PageCache_Model_Cookie::getCategoryCookieValue();
  179. if ($sessionParams) {
  180. - $sessionParams = $this->_filterInputParameters((array)json_decode($sessionParams));
  181. + $sessionParams = (array)json_decode($sessionParams);
  182. foreach ($sessionParams as $key => $value) {
  183. - if (!isset($queryParams[$key])) {
  184. + if (in_array($key, $this->_paramsMap) && !isset($queryParams[$key])) {
  185. $queryParams[$key] = $value;
  186. }
  187. }
  188. @@ -158,7 +160,7 @@ class Enterprise_PageCache_Model_Processor_Category extends Enterprise_PageCache
  189. $queryParams = json_decode($this->_getQueryParams(), true);
  190. if (empty($queryParams)) {
  191. $queryParams = Enterprise_PageCache_Model_Cookie::getCategoryCookieValue();
  192. - $queryParams = $this->_filterInputParameters(json_decode($queryParams, true));
  193. + $queryParams = json_decode($queryParams, true);
  194. }
  195.  
  196. if (is_array($queryParams) && !empty($queryParams)) {
  197. @@ -180,7 +182,7 @@ class Enterprise_PageCache_Model_Processor_Category extends Enterprise_PageCache
  198. protected function _getQueryParams()
  199. {
  200. if (is_null($this->_queryParams)) {
  201. - $queryParams = array_merge($this->_filterInputParameters($this->_getSessionParams()), $_GET);
  202. + $queryParams = array_merge($this->_getSessionParams(), $_GET);
  203. ksort($queryParams);
  204. $this->_queryParams = json_encode($queryParams);
  205. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement