2626
2727namespace OC \Files \Cache ;
2828
29+ use Doctrine \DBAL \Platforms \MySQLPlatform ;
2930use OC \DB \QueryBuilder \QueryBuilder ;
3031use OC \SystemConfig ;
3132use OCP \DB \QueryBuilder \IQueryBuilder ;
@@ -45,12 +46,24 @@ public function __construct(IDBConnection $connection, SystemConfig $systemConfi
4546 $ this ->cache = $ cache ;
4647 }
4748
48- public function selectFileCache (string $ alias = null ) {
49+ public function selectFileCache (string $ alias = null , string $ mysqlIndexHint = '' ) {
4950 $ name = $ alias ? $ alias : 'filecache ' ;
5051 $ this ->select ("$ name.fileid " , 'storage ' , 'path ' , 'path_hash ' , "$ name.parent " , 'name ' , 'mimetype ' , 'mimepart ' , 'size ' , 'mtime ' ,
5152 'storage_mtime ' , 'encrypted ' , 'etag ' , 'permissions ' , 'checksum ' , 'metadata_etag ' , 'creation_time ' , 'upload_time ' )
52- ->from ('filecache ' , $ name )
53- ->leftJoin ($ name , 'filecache_extended ' , 'fe ' , $ this ->expr ()->eq ("$ name.fileid " , 'fe.fileid ' ));
53+ ->from ('filecache ' , $ name );
54+ if ($ mysqlIndexHint !== '' && $ this ->getConnection ()->getDatabasePlatform () instanceof MySQLPlatform) {
55+ $ this ->add ('join ' , [
56+ $ this ->quoteAlias ($ name ) => [
57+ // horrible query builder crimes to sneak in raw sql after the "FROM oc_filecache $name"
58+ 'joinType ' => $ mysqlIndexHint . ' left ' ,
59+ 'joinTable ' => $ this ->getTableName ('filecache_extended ' ),
60+ 'joinAlias ' => $ this ->quoteAlias ('fe ' ),
61+ 'joinCondition ' => $ this ->expr ()->eq ("$ name.fileid " , 'fe.fileid ' ),
62+ ],
63+ ], true );
64+ } else {
65+ $ this ->leftJoin ($ name , 'filecache_extended ' , 'fe ' , $ this ->expr ()->eq ("$ name.fileid " , 'fe.fileid ' ));
66+ }
5467
5568 $ this ->alias = $ name ;
5669
0 commit comments