@@ -109,7 +109,7 @@ function convertFromURL($id) {
109
109
}
110
110
111
111
function createPatternNode ($ row ) {
112
- $ tool = idx ($ row , 'state ' );
112
+ $ tool = idx ($ row , 'state ' ) ?? '' ;
113
113
114
114
// Replace a few hidden characters with there string counterparts. Otherwise JSON parsing will break.
115
115
$ tool = preg_replace (["/ \n/ " , "/ \r/ " , "/ \t/ " ], ["\\\\\\n " , "\\\\\\r " , "\\\\\\t " ], $ tool );
@@ -138,36 +138,34 @@ function createPatternNode($row) {
138
138
$ result = array (
139
139
'id ' => convertToURL (idx ($ row , 'id ' )),
140
140
'keywords ' => idx ($ row , 'keywords ' ),
141
- 'name ' => stripslashes (idx ($ row , 'name ' )),
142
- 'description ' => stripslashes (idx ($ row , 'description ' )),
143
- 'dateAdded ' => strtotime (stripslashes (idx ($ row , 'dateAdded ' )))*1000 ,
141
+ 'name ' => stripslashes (idx ($ row , 'name ' ) ?? '' ),
142
+ 'description ' => stripslashes (idx ($ row , 'description ' ) ?? '' ),
143
+ 'dateAdded ' => strtotime (stripslashes (idx ($ row , 'dateAdded ' ) ?? '' ))*1000 ,
144
144
'flavor ' => idx ($ row , 'flavor ' ),
145
- 'expression ' => stripslashes (idx ($ row , 'pattern ' )),
145
+ 'expression ' => stripslashes (idx ($ row , 'pattern ' ) ?? '' ),
146
146
'text ' => idx ($ row , 'content ' ),
147
147
'tool ' => $ tool ,
148
148
'rating ' => idx ($ row , 'rating ' ),
149
149
'userId ' => intval (idx ($ row , 'owner ' )),
150
- 'author ' => stripslashes (idx ($ row , 'author ' )),
150
+ 'author ' => stripslashes (idx ($ row , 'author ' ) ?? '' ),
151
151
'userRating ' => idx ($ row , 'userRating ' ) ?? '0 ' ,
152
152
'favorite ' => !is_null (idx ($ row , 'favorite ' )),
153
153
'access ' => idx ($ row , 'visibility ' ),
154
154
'mode ' => idx ($ row , 'mode ' ),
155
- 'tests ' => json_decode (idx ($ row , 'tests ' ))
155
+ 'tests ' => json_decode (idx ($ row , 'tests ' ) ?? '' )
156
156
);
157
157
158
158
return $ result ;
159
159
}
160
160
161
- function createPatternSet ($ result , $ total = - 1 , $ startIndex = 0 , $ limit = 100 ) {
161
+ function createPatternSet ($ result , $ limit = 100 ) {
162
162
$ results = array ();
163
163
for ($ i =0 ;$ i <count ($ result );$ i ++) {
164
164
$ results [] = createPatternNode ($ result [$ i ]);
165
165
}
166
166
167
167
return array (
168
- 'startIndex ' => $ startIndex ,
169
168
'limit ' => $ limit ,
170
- 'total ' => $ total ,
171
169
'results ' => $ results
172
170
);
173
171
}
0 commit comments