]> git.mxchange.org Git - friendica.git/blob - src/Model/Photo.php
- Fixing SystemResource
[friendica.git] / src / Model / Photo.php
1 <?php
2
3 /**
4  * @file src/Model/Photo.php
5  * @brief This file contains the Photo class for database interface
6  */
7 namespace Friendica\Model;
8
9 use Friendica\Core\Cache;
10 use Friendica\Core\Config;
11 use Friendica\Core\L10n;
12 use Friendica\Core\Logger;
13 use Friendica\Core\StorageManager;
14 use Friendica\Core\System;
15 use Friendica\Database\DBA;
16 use Friendica\Database\DBStructure;
17 use Friendica\DI;
18 use Friendica\Model\Storage\IStorage;
19 use Friendica\Model\Storage\SystemResource;
20 use Friendica\Object\Image;
21 use Friendica\Util\DateTimeFormat;
22 use Friendica\Util\Images;
23 use Friendica\Util\Network;
24 use Friendica\Util\Security;
25 use Friendica\Util\Strings;
26
27 require_once "include/dba.php";
28
29 /**
30  * Class to handle photo dabatase table
31  */
32 class Photo
33 {
34         /**
35          * @brief Select rows from the photo table and returns them as array
36          *
37          * @param array $fields     Array of selected fields, empty for all
38          * @param array $conditions Array of fields for conditions
39          * @param array $params     Array of several parameters
40          *
41          * @return boolean|array
42          *
43          * @throws \Exception
44          * @see   \Friendica\Database\DBA::selectToArray
45          */
46         public static function selectToArray(array $fields = [], array $conditions = [], array $params = [])
47         {
48                 if (empty($fields)) {
49                         $fields = self::getFields();
50                 }
51
52                 return DBA::selectToArray('photo', $fields, $conditions, $params);
53         }
54
55         /**
56          * @brief Retrieve a single record from the photo table
57          *
58          * @param array $fields     Array of selected fields, empty for all
59          * @param array $conditions Array of fields for conditions
60          * @param array $params     Array of several parameters
61          *
62          * @return bool|array
63          *
64          * @throws \Exception
65          * @see   \Friendica\Database\DBA::select
66          */
67         public static function selectFirst(array $fields = [], array $conditions = [], array $params = [])
68         {
69                 if (empty($fields)) {
70                         $fields = self::getFields();
71                 }
72
73                 return DBA::selectFirst("photo", $fields, $conditions, $params);
74         }
75
76         /**
77          * @brief Get photos for user id
78          *
79          * @param integer $uid        User id
80          * @param string  $resourceid Rescource ID of the photo
81          * @param array   $conditions Array of fields for conditions
82          * @param array   $params     Array of several parameters
83          *
84          * @return bool|array
85          *
86          * @throws \Exception
87          * @see   \Friendica\Database\DBA::select
88          */
89         public static function getPhotosForUser($uid, $resourceid, array $conditions = [], array $params = [])
90         {
91                 $conditions["resource-id"] = $resourceid;
92                 $conditions["uid"] = $uid;
93
94                 return self::selectToArray([], $conditions, $params);
95         }
96
97         /**
98          * @brief Get a photo for user id
99          *
100          * @param integer $uid        User id
101          * @param string  $resourceid Rescource ID of the photo
102          * @param integer $scale      Scale of the photo. Defaults to 0
103          * @param array   $conditions Array of fields for conditions
104          * @param array   $params     Array of several parameters
105          *
106          * @return bool|array
107          *
108          * @throws \Exception
109          * @see   \Friendica\Database\DBA::select
110          */
111         public static function getPhotoForUser($uid, $resourceid, $scale = 0, array $conditions = [], array $params = [])
112         {
113                 $conditions["resource-id"] = $resourceid;
114                 $conditions["uid"] = $uid;
115                 $conditions["scale"] = $scale;
116
117                 return self::selectFirst([], $conditions, $params);
118         }
119
120         /**
121          * @brief Get a single photo given resource id and scale
122          *
123          * This method checks for permissions. Returns associative array
124          * on success, "no sign" image info, if user has no permission,
125          * false if photo does not exists
126          *
127          * @param string  $resourceid Rescource ID of the photo
128          * @param integer $scale      Scale of the photo. Defaults to 0
129          *
130          * @return boolean|array
131          * @throws \Exception
132          */
133         public static function getPhoto($resourceid, $scale = 0)
134         {
135                 $r = self::selectFirst(["uid"], ["resource-id" => $resourceid]);
136                 if (!DBA::isResult($r)) {
137                         return false;
138                 }
139
140                 $uid = $r["uid"];
141
142                 $sql_acl = Security::getPermissionsSQLByUserId($uid);
143
144                 $conditions = ["`resource-id` = ? AND `scale` <= ? " . $sql_acl, $resourceid, $scale];
145                 $params = ["order" => ["scale" => true]];
146                 $photo = self::selectFirst([], $conditions, $params);
147
148                 return $photo;
149         }
150
151         /**
152          * @brief Check if photo with given conditions exists
153          *
154          * @param array $conditions Array of extra conditions
155          *
156          * @return boolean
157          * @throws \Exception
158          */
159         public static function exists(array $conditions)
160         {
161                 return DBA::exists("photo", $conditions);
162         }
163
164
165         /**
166          * @brief Get Image object for given row id. null if row id does not exist
167          *
168          * @param array $photo Photo data. Needs at least 'id', 'type', 'backend-class', 'backend-ref'
169          *
170          * @return \Friendica\Object\Image
171          * @throws \Friendica\Network\HTTPException\InternalServerErrorException
172          * @throws \ImagickException
173          */
174         public static function getImageForPhoto(array $photo)
175         {
176                 $data = "";
177
178                 if ($photo["backend-class"] == "") {
179                         // legacy data storage in "data" column
180                         $i = self::selectFirst(["data"], ["id" => $photo["id"]]);
181                         if ($i === false) {
182                                 return null;
183                         }
184                         $data = $i["data"];
185                 } else {
186                         $backendClass = $photo["backend-class"];
187                         $backendRef = $photo["backend-ref"];
188                         $data = $backendClass::get($backendRef);
189                 }
190
191                 if ($data === "") {
192                         return null;
193                 }
194
195                 return new Image($data, $photo["type"]);
196         }
197
198         /**
199          * @brief Return a list of fields that are associated with the photo table
200          *
201          * @return array field list
202          * @throws \Exception
203          */
204         private static function getFields()
205         {
206                 $allfields = DBStructure::definition(DI::app()->getBasePath(), false);
207                 $fields = array_keys($allfields["photo"]["fields"]);
208                 array_splice($fields, array_search("data", $fields), 1);
209                 return $fields;
210         }
211
212         /**
213          * @brief Construct a photo array for a system resource image
214          *
215          * @param string $filename Image file name relative to code root
216          * @param string $mimetype Image mime type. Defaults to "image/jpeg"
217          *
218          * @return array
219          * @throws \Exception
220          */
221         public static function createPhotoForSystemResource($filename, $mimetype = "image/jpeg")
222         {
223                 $fields = self::getFields();
224                 $values = array_fill(0, count($fields), "");
225
226                 $photo = array_combine($fields, $values);
227                 $photo["backend-class"] = SystemResource::NAME;
228                 $photo["backend-ref"] = $filename;
229                 $photo["type"] = $mimetype;
230                 $photo["cacheable"] = false;
231
232                 return $photo;
233         }
234
235
236         /**
237          * @brief store photo metadata in db and binary in default backend
238          *
239          * @param Image   $Image     Image object with data
240          * @param integer $uid       User ID
241          * @param integer $cid       Contact ID
242          * @param integer $rid       Resource ID
243          * @param string  $filename  Filename
244          * @param string  $album     Album name
245          * @param integer $scale     Scale
246          * @param integer $profile   Is a profile image? optional, default = 0
247          * @param string  $allow_cid Permissions, allowed contacts. optional, default = ""
248          * @param string  $allow_gid Permissions, allowed groups. optional, default = ""
249          * @param string  $deny_cid  Permissions, denied contacts.optional, default = ""
250          * @param string  $deny_gid  Permissions, denied greoup.optional, default = ""
251          * @param string  $desc      Photo caption. optional, default = ""
252          *
253          * @return boolean True on success
254          * @throws \Friendica\Network\HTTPException\InternalServerErrorException
255          */
256         public static function store(Image $Image, $uid, $cid, $rid, $filename, $album, $scale, $profile = 0, $allow_cid = "", $allow_gid = "", $deny_cid = "", $deny_gid = "", $desc = "")
257         {
258                 $photo = self::selectFirst(["guid"], ["`resource-id` = ? AND `guid` != ?", $rid, ""]);
259                 if (DBA::isResult($photo)) {
260                         $guid = $photo["guid"];
261                 } else {
262                         $guid = System::createGUID();
263                 }
264
265                 $existing_photo = self::selectFirst(["id", "created", "backend-class", "backend-ref"], ["resource-id" => $rid, "uid" => $uid, "contact-id" => $cid, "scale" => $scale]);
266                 $created = DateTimeFormat::utcNow();
267                 if (DBA::isResult($existing_photo)) {
268                         $created = $existing_photo["created"];
269                 }
270
271                 // Get defined storage backend.
272                 // if no storage backend, we use old "data" column in photo table.
273                 // if is an existing photo, reuse same backend
274                 $data = "";
275                 $backend_ref = "";
276
277                 if (DBA::isResult($existing_photo)) {
278                         $backend_ref = (string)$existing_photo["backend-ref"];
279                         $storage = DI::facStorage()->getByName($existing_photo["backend-class"] ?? '');
280                 } else {
281                         $storage = DI::storage();
282                 }
283
284                 if ($storage === null) {
285                         $data = $Image->asString();
286                 } else {
287                         $backend_ref = $storage->put($Image->asString(), $backend_ref);
288                 }
289
290
291                 $fields = [
292                         "uid" => $uid,
293                         "contact-id" => $cid,
294                         "guid" => $guid,
295                         "resource-id" => $rid,
296                         "created" => $created,
297                         "edited" => DateTimeFormat::utcNow(),
298                         "filename" => basename($filename),
299                         "type" => $Image->getType(),
300                         "album" => $album,
301                         "height" => $Image->getHeight(),
302                         "width" => $Image->getWidth(),
303                         "datasize" => strlen($Image->asString()),
304                         "data" => $data,
305                         "scale" => $scale,
306                         "profile" => $profile,
307                         "allow_cid" => $allow_cid,
308                         "allow_gid" => $allow_gid,
309                         "deny_cid" => $deny_cid,
310                         "deny_gid" => $deny_gid,
311                         "desc" => $desc,
312                         "backend-class" => (string)$storage,
313                         "backend-ref" => $backend_ref
314                 ];
315
316                 if (DBA::isResult($existing_photo)) {
317                         $r = DBA::update("photo", $fields, ["id" => $existing_photo["id"]]);
318                 } else {
319                         $r = DBA::insert("photo", $fields);
320                 }
321
322                 return $r;
323         }
324
325
326         /**
327          * @brief Delete info from table and data from storage
328          *
329          * @param array $conditions Field condition(s)
330          * @param array $options    Options array, Optional
331          *
332          * @return boolean
333          *
334          * @throws \Exception
335          * @see   \Friendica\Database\DBA::delete
336          */
337         public static function delete(array $conditions, array $options = [])
338         {
339                 // get photo to delete data info
340                 $photos = self::selectToArray(['backend-class', 'backend-ref'], $conditions);
341
342                 foreach($photos as $photo) {
343                         /** @var IStorage $backend_class */
344                         $backend_class = (string)$photo["backend-class"];
345                         if ($backend_class !== "") {
346                                 $backend_class::delete($photo["backend-ref"]);
347                         }
348                 }
349
350                 return DBA::delete("photo", $conditions, $options);
351         }
352
353         /**
354          * @brief Update a photo
355          *
356          * @param array         $fields     Contains the fields that are updated
357          * @param array         $conditions Condition array with the key values
358          * @param Image         $img        Image to update. Optional, default null.
359          * @param array|boolean $old_fields Array with the old field values that are about to be replaced (true = update on duplicate)
360          *
361          * @return boolean  Was the update successfull?
362          *
363          * @throws \Friendica\Network\HTTPException\InternalServerErrorException
364          * @see   \Friendica\Database\DBA::update
365          */
366         public static function update($fields, $conditions, Image $img = null, array $old_fields = [])
367         {
368                 if (!is_null($img)) {
369                         // get photo to update
370                         $photos = self::selectToArray(['backend-class', 'backend-ref'], $conditions);
371
372                         foreach($photos as $photo) {
373                                 /** @var IStorage $backend_class */
374                                 $backend_class = (string)$photo["backend-class"];
375                                 if ($backend_class !== "") {
376                                         $fields["backend-ref"] = $backend_class::put($img->asString(), $photo["backend-ref"]);
377                                 } else {
378                                         $fields["data"] = $img->asString();
379                                 }
380                         }
381                         $fields['updated'] = DateTimeFormat::utcNow();
382                 }
383
384                 $fields['edited'] = DateTimeFormat::utcNow();
385
386                 return DBA::update("photo", $fields, $conditions, $old_fields);
387         }
388
389         /**
390          * @param string  $image_url     Remote URL
391          * @param integer $uid           user id
392          * @param integer $cid           contact id
393          * @param boolean $quit_on_error optional, default false
394          * @return array
395          * @throws \Friendica\Network\HTTPException\InternalServerErrorException
396          * @throws \ImagickException
397          */
398         public static function importProfilePhoto($image_url, $uid, $cid, $quit_on_error = false)
399         {
400                 $thumb = "";
401                 $micro = "";
402
403                 $photo = DBA::selectFirst(
404                         "photo", ["resource-id"], ["uid" => $uid, "contact-id" => $cid, "scale" => 4, "album" => "Contact Photos"]
405                 );
406                 if (!empty($photo['resource-id'])) {
407                         $resource_id = $photo["resource-id"];
408                 } else {
409                         $resource_id = self::newResource();
410                 }
411
412                 $photo_failure = false;
413
414                 $filename = basename($image_url);
415                 if (!empty($image_url)) {
416                         $ret = Network::curl($image_url, true);
417                         $img_str = $ret->getBody();
418                         $type = $ret->getContentType();
419                 } else {
420                         $img_str = '';
421                 }
422
423                 if ($quit_on_error && ($img_str == "")) {
424                         return false;
425                 }
426
427                 if (empty($type)) {
428                         $type = Images::guessType($image_url, true);
429                 }
430
431                 $Image = new Image($img_str, $type);
432                 if ($Image->isValid()) {
433                         $Image->scaleToSquare(300);
434
435                         $r = self::store($Image, $uid, $cid, $resource_id, $filename, "Contact Photos", 4);
436
437                         if ($r === false) {
438                                 $photo_failure = true;
439                         }
440
441                         $Image->scaleDown(80);
442
443                         $r = self::store($Image, $uid, $cid, $resource_id, $filename, "Contact Photos", 5);
444
445                         if ($r === false) {
446                                 $photo_failure = true;
447                         }
448
449                         $Image->scaleDown(48);
450
451                         $r = self::store($Image, $uid, $cid, $resource_id, $filename, "Contact Photos", 6);
452
453                         if ($r === false) {
454                                 $photo_failure = true;
455                         }
456
457                         $suffix = "?ts=" . time();
458
459                         $image_url = DI::baseUrl() . "/photo/" . $resource_id . "-4." . $Image->getExt() . $suffix;
460                         $thumb = DI::baseUrl() . "/photo/" . $resource_id . "-5." . $Image->getExt() . $suffix;
461                         $micro = DI::baseUrl() . "/photo/" . $resource_id . "-6." . $Image->getExt() . $suffix;
462
463                         // Remove the cached photo
464                         $a = DI::app();
465                         $basepath = $a->getBasePath();
466
467                         if (is_dir($basepath . "/photo")) {
468                                 $filename = $basepath . "/photo/" . $resource_id . "-4." . $Image->getExt();
469                                 if (file_exists($filename)) {
470                                         unlink($filename);
471                                 }
472                                 $filename = $basepath . "/photo/" . $resource_id . "-5." . $Image->getExt();
473                                 if (file_exists($filename)) {
474                                         unlink($filename);
475                                 }
476                                 $filename = $basepath . "/photo/" . $resource_id . "-6." . $Image->getExt();
477                                 if (file_exists($filename)) {
478                                         unlink($filename);
479                                 }
480                         }
481                 } else {
482                         $photo_failure = true;
483                 }
484
485                 if ($photo_failure && $quit_on_error) {
486                         return false;
487                 }
488
489                 if ($photo_failure) {
490                         $image_url = DI::baseUrl() . "/images/person-300.jpg";
491                         $thumb = DI::baseUrl() . "/images/person-80.jpg";
492                         $micro = DI::baseUrl() . "/images/person-48.jpg";
493                 }
494
495                 return [$image_url, $thumb, $micro];
496         }
497
498         /**
499          * @param array $exifCoord coordinate
500          * @param string $hemi      hemi
501          * @return float
502          */
503         public static function getGps($exifCoord, $hemi)
504         {
505                 $degrees = count($exifCoord) > 0 ? self::gps2Num($exifCoord[0]) : 0;
506                 $minutes = count($exifCoord) > 1 ? self::gps2Num($exifCoord[1]) : 0;
507                 $seconds = count($exifCoord) > 2 ? self::gps2Num($exifCoord[2]) : 0;
508
509                 $flip = ($hemi == "W" || $hemi == "S") ? -1 : 1;
510
511                 return floatval($flip * ($degrees + ($minutes / 60) + ($seconds / 3600)));
512         }
513
514         /**
515          * @param string $coordPart coordPart
516          * @return float
517          */
518         private static function gps2Num($coordPart)
519         {
520                 $parts = explode("/", $coordPart);
521
522                 if (count($parts) <= 0) {
523                         return 0;
524                 }
525
526                 if (count($parts) == 1) {
527                         return $parts[0];
528                 }
529
530                 return floatval($parts[0]) / floatval($parts[1]);
531         }
532
533         /**
534          * @brief Fetch the photo albums that are available for a viewer
535          *
536          * The query in this function is cost intensive, so it is cached.
537          *
538          * @param int  $uid    User id of the photos
539          * @param bool $update Update the cache
540          *
541          * @return array Returns array of the photo albums
542          * @throws \Friendica\Network\HTTPException\InternalServerErrorException
543          */
544         public static function getAlbums($uid, $update = false)
545         {
546                 $sql_extra = Security::getPermissionsSQLByUserId($uid);
547
548                 $key = "photo_albums:".$uid.":".local_user().":".remote_user();
549                 $albums = Cache::get($key);
550                 if (is_null($albums) || $update) {
551                         if (!Config::get("system", "no_count", false)) {
552                                 /// @todo This query needs to be renewed. It is really slow
553                                 // At this time we just store the data in the cache
554                                 $albums = q("SELECT COUNT(DISTINCT `resource-id`) AS `total`, `album`, ANY_VALUE(`created`) AS `created`
555                                         FROM `photo`
556                                         WHERE `uid` = %d  AND `album` != '%s' AND `album` != '%s' $sql_extra
557                                         GROUP BY `album` ORDER BY `created` DESC",
558                                         intval($uid),
559                                         DBA::escape("Contact Photos"),
560                                         DBA::escape(L10n::t("Contact Photos"))
561                                 );
562                         } else {
563                                 // This query doesn't do the count and is much faster
564                                 $albums = q("SELECT DISTINCT(`album`), '' AS `total`
565                                         FROM `photo` USE INDEX (`uid_album_scale_created`)
566                                         WHERE `uid` = %d  AND `album` != '%s' AND `album` != '%s' $sql_extra",
567                                         intval($uid),
568                                         DBA::escape("Contact Photos"),
569                                         DBA::escape(L10n::t("Contact Photos"))
570                                 );
571                         }
572                         Cache::set($key, $albums, Cache::DAY);
573                 }
574                 return $albums;
575         }
576
577         /**
578          * @param int $uid User id of the photos
579          * @return void
580          * @throws \Exception
581          */
582         public static function clearAlbumCache($uid)
583         {
584                 $key = "photo_albums:".$uid.":".local_user().":".remote_user();
585                 Cache::set($key, null, Cache::DAY);
586         }
587
588         /**
589          * Generate a unique photo ID.
590          *
591          * @return string
592          * @throws \Exception
593          */
594         public static function newResource()
595         {
596                 return System::createGUID(32, false);
597         }
598
599         /**
600          * Changes photo permissions that had been embedded in a post
601          *
602          * @todo This function currently does have some flaws:
603          * - Sharing a post with a forum will create a photo that only the forum can see.
604          * - Sharing a photo again that been shared non public before doesn't alter the permissions.
605          *
606          * @return string
607          * @throws \Exception
608          */
609         public static function setPermissionFromBody($body, $uid, $original_contact_id, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny)
610         {
611                 // Simplify image codes
612                 $img_body = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '[img]$3[/img]', $body);
613                 $img_body = preg_replace("/\[img\=(.*?)\](.*?)\[\/img\]/ism", '[img]$1[/img]', $img_body);
614
615                 // Search for images
616                 if (!preg_match_all("/\[img\](.*?)\[\/img\]/", $img_body, $match)) {
617                         return false;
618                 }
619                 $images = $match[1];
620                 if (empty($images)) {
621                         return false;
622                 }
623
624                 foreach ($images as $image) {
625                         if (!stristr($image, DI::baseUrl() . '/photo/')) {
626                                 continue;
627                         }
628                         $image_uri = substr($image,strrpos($image,'/') + 1);
629                         $image_uri = substr($image_uri,0, strpos($image_uri,'-'));
630                         if (!strlen($image_uri)) {
631                                 continue;
632                         }
633
634                         // Ensure to only modify photos that you own
635                         $srch = '<' . intval($original_contact_id) . '>';
636
637                         $condition = [
638                                 'allow_cid' => $srch, 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '',
639                                 'resource-id' => $image_uri, 'uid' => $uid
640                         ];
641                         if (!Photo::exists($condition)) {
642                                 continue;
643                         }
644
645                         /// @todo Check if $str_contact_allow does contain a public forum. Then set the permissions to public.
646
647                         $fields = ['allow_cid' => $str_contact_allow, 'allow_gid' => $str_group_allow,
648                                         'deny_cid' => $str_contact_deny, 'deny_gid' => $str_group_deny];
649                         $condition = ['resource-id' => $image_uri, 'uid' => $uid];
650                         Logger::info('Set permissions', ['condition' => $condition, 'permissions' => $fields]);
651                         Photo::update($fields, $condition);
652                 }
653
654                 return true;
655         }
656
657         /**
658          * Strips known picture extensions from picture links
659          *
660          * @param string $name Picture link
661          * @return string stripped picture link
662          * @throws \Exception
663          */
664         public static function stripExtension($name)
665         {
666                 $name = str_replace([".jpg", ".png", ".gif"], ["", "", ""], $name);
667                 foreach (Images::supportedTypes() as $m => $e) {
668                         $name = str_replace("." . $e, "", $name);
669                 }
670                 return $name;
671         }
672
673         /**
674          * Returns the GUID from picture links
675          *
676          * @param string $name Picture link
677          * @return string GUID
678          * @throws \Exception
679          */
680         public static function getGUID($name)
681         {
682                 $base = DI::baseUrl()->get();
683
684                 $guid = str_replace([Strings::normaliseLink($base), '/photo/'], '', Strings::normaliseLink($name));
685
686                 $guid = self::stripExtension($guid);
687                 if (substr($guid, -2, 1) != "-") {
688                         return '';
689                 }
690
691                 $scale = intval(substr($guid, -1, 1));
692                 if (!is_numeric($scale)) {
693                         return '';
694                 }
695
696                 $guid = substr($guid, 0, -2);
697                 return $guid;
698         }
699
700         /**
701          * Tests if the picture link points to a locally stored picture
702          *
703          * @param string $name Picture link
704          * @return boolean
705          * @throws \Exception
706          */
707         public static function isLocal($name)
708         {
709                 $guid = self::getGUID($name);
710
711                 if (empty($guid)) {
712                         return false;
713                 }
714
715                 return DBA::exists('photo', ['resource-id' => $guid]);
716         }
717
718         /**
719          * Tests if the link points to a locally stored picture page
720          *
721          * @param string $name Page link
722          * @return boolean
723          * @throws \Exception
724          */
725         public static function isLocalPage($name)
726         {
727                 $base = DI::baseUrl()->get();
728
729                 $guid = str_replace(Strings::normaliseLink($base), '', Strings::normaliseLink($name));
730                 $guid = preg_replace("=/photos/.*/image/(.*)=ism", '$1', $guid);
731                 if (empty($guid)) {
732                         return false;
733                 }
734
735                 return DBA::exists('photo', ['resource-id' => $guid]);
736         }
737 }