@@ -318,6 +318,7 @@ function getConnection()
318318 /**
319319 *Set the maintenance mode
320320 * @return bool true - maintenance mode is set; false - maintenance mode could not be set because an update is already running
321+ * @throws UpdateException
321322 */
322323 function addMaintenanceMode ()
323324 {
@@ -667,6 +668,35 @@ function checkphpmodules()
667668 }
668669 }
669670
671+ /**
672+ * Move plugins in temporary folder to prevent them from being overwritten.
673+ * @throws UpdateException
674+ */
675+ function movePluginsInTempFolder ()
676+ {
677+ $ oldDir = __DIR__ . '/../admin/plugins ' ;
678+ $ newDir = __DIR__ . '/../tmp_uploaded_update/tempplugins ' ;
679+ $ state = rename ($ oldDir , $ newDir );
680+ if ($ state === false ) {
681+ throw new UpdateException ("Could not move plugins directory " );
682+ }
683+ }
684+
685+ /**
686+ * Move plugins back in admin directory.
687+ * @throws UpdateException
688+ */
689+ function movePluginsInPlace ()
690+ {
691+ $ oldDir = realpath (__DIR__ . '/../tmp_uploaded_update/tempplugins ' );
692+ $ newDir = realpath (__DIR__ . '/../admin/plugins ' );
693+ $ this ->rmdir_recursive ($ newDir );
694+ $ state = rename ($ oldDir , $ newDir );
695+ if ($ state === false ) {
696+ throw new UpdateException ("Could not move plugins directory to admin folder. " );
697+ }
698+ }
699+
670700 /**
671701 * Update updater to a new location before temp folder is deleted!
672702 * @throws UpdateException
@@ -831,54 +861,71 @@ function replaceNewUpdater()
831861 }
832862 break ;
833863 case 12 :
864+ try {
865+ $ update ->movePluginsInTempFolder ();
866+ echo (json_encode (array ('continue ' => true , 'response ' => 'Backing up the plugins ' , 'autocontinue ' => true )));
867+ } catch (\Exception $ e ) {
868+ echo (json_encode (array ('continue ' => false , 'response ' => $ e ->getMessage ())));
869+ }
870+ break ;
871+ case 13 :
834872 try {
835873 $ update ->deleteFiles ();
836874 echo (json_encode (array ('continue ' => true , 'response ' => 'Old files have been deleted! ' , 'autocontinue ' => true )));
837875 } catch (\Exception $ e ) {
838876 echo (json_encode (array ('continue ' => false , 'response ' => $ e ->getMessage ())));
839877 }
840878 break ;
841- case 13 :
879+ case 14 :
842880 try {
843881 $ update ->moveNewFiles ();
844882 echo (json_encode (array ('continue ' => true , 'response ' => 'Moved new files in place! ' , 'autocontinue ' => true )));
883+
845884 } catch (\Exception $ e ) {
846885 echo (json_encode (array ('continue ' => false , 'response ' => $ e ->getMessage ())));
847886 }
848887 break ;
849- case 14 :
888+ case 15 :
889+ try {
890+ $ update ->movePluginsInPlace ();
891+ echo (json_encode (array ('continue ' => true , 'response ' => 'Moved plugins in place! ' , 'autocontinue ' => true )));
892+ } catch (\Exception $ e ) {
893+ echo (json_encode (array ('continue ' => false , 'response ' => $ e ->getMessage ())));
894+ }
895+ break ;
896+ case 16 :
850897 try {
851898 $ update ->moveEntryPHPpoints ();
852899 echo (json_encode (array ('continue ' => true , 'response ' => 'Moved new entry points in place! ' , 'autocontinue ' => true )));
853900 } catch (\Exception $ e ) {
854901 echo (json_encode (array ('continue ' => false , 'response ' => $ e ->getMessage ())));
855902 }
856903 break ;
857- case 15 :
904+ case 17 :
858905 try {
859906 $ update ->moveUpdater ();
860907 echo (json_encode (array ('continue ' => true , 'response ' => 'Moved new entry points in place! ' , 'autocontinue ' => true )));
861908 } catch (\Exception $ e ) {
862909 echo (json_encode (array ('continue ' => false , 'response ' => $ e ->getMessage ())));
863910 }
864911 break ;
865- case 16 :
912+ case 18 :
866913 try {
867914 $ update ->deleteTemporaryFiles ();
868915 echo (json_encode (array ('continue ' => true , 'response ' => 'Deleted temporary files! ' , 'autocontinue ' => true )));
869916 } catch (\Exception $ e ) {
870917 echo (json_encode (array ('continue ' => false , 'response ' => $ e ->getMessage ())));
871918 }
872919 break ;
873- case 17 :
920+ case 19 :
874921 try {
875922 $ update ->removeMaintenanceMode ();
876923 echo (json_encode (array ('continue ' => true , 'response ' => 'Removed maintenance mode ' , 'autocontinue ' => true )));
877924 } catch (\Exception $ e ) {
878925 echo (json_encode (array ('continue ' => false , 'response ' => $ e ->getMessage ())));
879926 }
880927 break ;
881- case 18 :
928+ case 20 :
882929 $ writeStep = false ;
883930 try {
884931 $ update ->replaceNewUpdater ();
@@ -984,6 +1031,7 @@ function replaceNewUpdater()
9841031
9851032 button.right {
9861033 background-color: #21AE8A;
1034+
9871035 color: white;
9881036 border-radius: 5px;
9891037 height: 40px;
@@ -995,7 +1043,6 @@ function replaceNewUpdater()
9951043 border: none;
9961044 }
9971045
998-
9991046 button:disabled {
10001047 background-color: lightgrey !important;
10011048 }
@@ -1569,6 +1616,7 @@ function replaceNewUpdater()
15691616 <div class="clear"></div>
15701617 <h2>Initialize</h2>
15711618 </div>
1619+
15721620 <div class="step">
15731621 <div class="step-image ">
15741622
@@ -1630,6 +1678,7 @@ function replaceNewUpdater()
16301678 <div class="clear"></div>
16311679 <h2>Perform update</h2>
16321680 </div>
1681+
16331682 <div class="clear"></div>
16341683 </div>
16351684
@@ -1640,10 +1689,12 @@ function replaceNewUpdater()
16401689 <div>
16411690 <button id="next-step" class="right">Next</button>
16421691 <button id="database-upgrade" class="right" style="visibility: hidden;">Upgrade database</button>
1692+
16431693 </div>
16441694 </div>
16451695 </div>
16461696 </div>
1697+
16471698 <!-- Info updater section -->
16481699 <div class="outer">
16491700 <button class="info-footer">
@@ -1737,6 +1788,7 @@ class="book"/>
17371788 $("#center").addClass("cutomMinHeight");
17381789 $(".fixed").addClass("cutomMinHeight");
17391790 </script>
1791+
17401792 <script>
17411793 let previousFormActions = null;
17421794
@@ -1798,6 +1850,8 @@ function setCurrentActionItem(step) {
17981850 16: 3,
17991851 17: 3,
18001852 18: 3,
1853+ 19: 3,
1854+ 20: 3,
18011855 };
18021856
18031857 let steps = document.querySelectorAll('.step-image');
0 commit comments