File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed
src/SWP/Bundle/CoreBundle/Migrations/2021/01 Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -119,19 +119,29 @@ public function postUp(Schema $schema): void
119119 }
120120 }
121121
122- private function unserializeExtraField (string $ data )
122+ private function unserializeExtraField (? string $ data )
123123 {
124- $ data = @ unserialize ( $ data);
125- if ($ data ) {
126- return $ data ;
124+ // Handle null or empty data
125+ if (empty ( $ data) ) {
126+ return null ;
127127 }
128128
129+ $ unserializedData = @unserialize ($ data );
130+ if ($ unserializedData !== false ) {
131+ return $ unserializedData ;
132+ }
133+
134+ // If unserialize failed, try to fix and retry
129135 $ callback = function ($ matches ) {
130136 $ matches [2 ] = trim (preg_replace ('/\s\s+/ ' , ' ' , $ matches [2 ]));
131137 return 's: ' . mb_strlen ($ matches [2 ]) . ':" ' . $ matches [2 ] . '"; ' ;
132138 };
133139
134140 $ data = preg_replace_callback ('!s:(\d+):"(.*?)";!s ' , $ callback , $ data );
141+ if ($ data === null ) {
142+ return null ;
143+ }
144+
135145 return @unserialize ($ data );
136146 }
137147}
You can’t perform that action at this time.
0 commit comments