~xibo-maintainers/xibo/tempel

« back to all changes in this revision

Viewing changes to lib/Service/DisplayNotifyService.php

  • Committer: GitHub
  • Author(s): Dan Garner
  • Date: 2016-11-16 11:51:16 UTC
  • Revision ID: git-v1:1cdd39222ff9fdd3fcc0bb8924cc706a24b18905
Bugfix/1.8.0 pack1 (#227)

* Library Tidy inaccessible
* Enabled notifications tidy task by default
* Implementation of "parent settings" so that TwitterMetro can use the API key/secret from Twitter.
* Fix for StatsArchive task infinite loop
* Fix for StatsArchive task processing ahead of now
* Flip clock to support countdown from a particular date, and daily countdown. xibosignage/xibo#936
* Fix date parsing when a timezone has been set
* Only save campaign if changes were made.
* Fix display notifications for removing dups
* XMR priv socket sleep to 100 ms
* Fix removal of Twig sources on release archive build. xibosignage/xibo#940
* Improve campaign layout assign/unassign xibosignage/xibo#941
* Tidy up unnecessary save in MediaInventory. Better logging for errors with sendfile from XMDS.
* Fix display status icon xibosignage/xibo#943
* Updated caching logic for required files
* Rewrite the nonce cache (required file) so that it uses a key per file instead of one storage object.
* Rework required files again - move back into the DB, but optimize nonce creation to ease contention.
* Further improvements to DB activity, basic connection management and stats reporting. Also deadlock protection statement.
* XMDS not updating bytes requested.
* More logging for retry deadlock loop
* Correct bandwidth logging. Fix deadlock loop.
* Improvements to media download (proper async). Fix for module downloads being copied rather than moved.
* Swagger doc fixes
* Convert XTR into a select and run single process script. Should fix it for windows.

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
namespace Xibo\Service;
10
10
use Stash\Interfaces\PoolInterface;
11
11
use Xibo\Entity\Display;
 
12
use Xibo\Exception\DeadlockException;
12
13
use Xibo\Factory\DayPartFactory;
13
14
use Xibo\Factory\ScheduleFactory;
14
15
use Xibo\Storage\StorageServiceInterface;
95
96
 
96
97
        $this->log->debug('Process queue of ' . count($this->displayIds) . ' display notifications');
97
98
 
98
 
        // Create a new connection
99
 
        $this->store->setConnection();
100
 
 
101
99
        // We want to do 3 things.
102
100
        // 1. Drop the Cache for each displayId
103
101
        // 2. Update the mediaInventoryStatus on each DisplayId to 3 (pending)
104
102
        // 3. Fire a PlayerAction if appropriate - what is appropriate?!
105
103
 
106
104
        // Unique our displayIds
107
 
        $displayIds = array_unique($this->displayIds, SORT_NUMERIC);
 
105
        $displayIds = array_values(array_unique($this->displayIds, SORT_NUMERIC));
108
106
 
109
107
        // Make a list of them that we can use in the update statement
110
108
        $qmarks = str_repeat('?,', count($displayIds) - 1) . '?';
111
109
 
112
 
        $this->store->update('UPDATE `display` SET mediaInventoryStatus = 3 WHERE displayId IN (' . $qmarks . ')', $displayIds);
 
110
        try {
 
111
            $this->store->updateWithDeadlockLoop('UPDATE `display` SET mediaInventoryStatus = 3 WHERE displayId IN (' . $qmarks . ')', $displayIds);
 
112
        } catch (DeadlockException $deadlockException) {
 
113
            $this->log->error('Failed to update media inventory status: ' . $deadlockException->getMessage());
 
114
        }
113
115
 
114
116
        // Dump the cache
115
117
        foreach ($displayIds as $displayId) {
118
120
 
119
121
        // Player actions
120
122
        $this->processPlayerActions();
121
 
 
122
 
        // Close the connetion
123
 
        $this->store->commitIfNecessary();
124
 
        $this->store->close();
125
123
    }
126
124
 
127
125
    /**
132
130
        if (count($this->displayIdsRequiringActions) <= 0)
133
131
            return;
134
132
 
135
 
        $displayIdsRequiringActions = array_unique($this->displayIdsRequiringActions, SORT_NUMERIC);
 
133
        $this->log->debug('Process queue of ' . count($this->displayIdsRequiringActions) . ' display actions');
 
134
 
 
135
        $displayIdsRequiringActions = array_values(array_unique($this->displayIdsRequiringActions, SORT_NUMERIC));
136
136
        $qmarks = str_repeat('?,', count($displayIdsRequiringActions) - 1) . '?';
137
137
        $displays = $this->store->select('SELECT displayId, xmrChannel, xmrPubKey FROM `display` WHERE displayId IN (' . $qmarks . ')', $displayIdsRequiringActions);
138
138
 
176
176
        foreach ($this->store->select($sql, ['displayGroupId' => $displayGroupId]) as $row) {
177
177
            $this->displayIds[] = $row['displayId'];
178
178
 
 
179
            $this->log->debug('DisplayGroup[' . $displayGroupId .'] change caused notify on displayId[' . $row['displayId'] . ']');
 
180
 
179
181
            if ($this->collectRequired)
180
182
                $this->displayIdsRequiringActions[] = $row['displayId'];
181
183
        }
276
278
                }
277
279
            }
278
280
 
 
281
            $this->log->debug('Campaign[' . $campaignId .'] change caused notify on displayId[' . $row['displayId'] . ']');
 
282
 
279
283
            $this->displayIds[] = $row['displayId'];
280
284
 
281
285
            if ($this->collectRequired)
412
416
                }
413
417
            }
414
418
 
 
419
            $this->log->debug('DataSet[' . $dataSetId .'] change caused notify on displayId[' . $row['displayId'] . ']');
 
420
 
415
421
            $this->displayIds[] = $row['displayId'];
416
422
 
417
423
            if ($this->collectRequired)
526
532
                }
527
533
            }
528
534
 
 
535
            $this->log->debug('Playlist[' . $playlistId .'] change caused notify on displayId[' . $row['displayId'] . ']');
 
536
 
529
537
            $this->displayIds[] = $row['displayId'];
530
538
 
531
539
            if ($this->collectRequired)