Skip to content

Commit 346a9c4

Browse files
authored
Updating workflow to include code validation PHP8.4 and MariaDB 10.6 (#356)
* Updating workflow * Update workflow * Permission changes * Fix using php-cs-fixer
1 parent ccab000 commit 346a9c4

27 files changed

Lines changed: 2050 additions & 2122 deletions

.github/workflows/plugin-ci-workflow.yml

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ jobs:
3838
strategy:
3939
fail-fast: false
4040
matrix:
41-
php: ['8.1', '8.2', '8.3']
41+
php: ['8.1', '8.2', '8.3', '8.4']
4242
os: [ubuntu-latest]
4343

4444
services:
45-
mysql:
46-
image: mysql:8.0
45+
mariadb:
46+
image: mariadb:10.6
4747
env:
4848
MYSQL_ROOT_PASSWORD: cactiroot
4949
MYSQL_DATABASE: cacti
@@ -66,7 +66,7 @@ jobs:
6666
repository: Cacti/cacti
6767
path: cacti
6868

69-
- name: Checkout Intropage Plugin
69+
- name: Checkout intropage Plugin
7070
uses: actions/checkout@v4
7171
with:
7272
path: cacti/plugins/intropage
@@ -81,7 +81,6 @@ jobs:
8181
- name: Check PHP version
8282
run: php -v
8383

84-
8584
- name: Run apt-get update
8685
run: sudo apt-get update
8786

@@ -141,7 +140,6 @@ jobs:
141140
sed -r "s/'cactiuser'/'cactiuser'/g" > ${{ github.workspace }}/cacti/include/config.php
142141
sudo chmod 664 ${{ github.workspace }}/cacti/include/config.php
143142
144-
145143
- name: Configure Apache
146144
run: |
147145
cat << 'EOF' | sed 's#GITHUB_WORKSPACE#${{ github.workspace }}#g' > /tmp/cacti.conf
@@ -167,11 +165,10 @@ jobs:
167165
cd ${{ github.workspace }}/cacti
168166
sudo php cli/install_cacti.php --accept-eula --install --force
169167
170-
- name: Install Intropage Plugin
168+
- name: Install intropage Plugin
171169
run: |
172170
cd ${{ github.workspace }}/cacti
173171
sudo php cli/plugin_manage.php --plugin=intropage --install --enable
174-
175172
176173
- name: Check PHP Syntax for Plugin
177174
run: |
@@ -180,19 +177,41 @@ jobs:
180177
echo "Syntax errors found!"
181178
exit 1
182179
fi
180+
181+
- name: Remove the plugins directory exclusion from the .phpstan.neon
182+
run: sed '/plugins/d' -i .phpstan.neon
183+
working-directory: ${{ github.workspace }}/cacti
184+
185+
- name: Mark composer scripts executable
186+
run: sudo chmod +x ${{ github.workspace }}/cacti/include/vendor/bin/*
187+
188+
- name: Run Linter on base code
189+
run: composer run-script lint ${{ github.workspace }}/cacti/plugins/intropage
190+
working-directory: ${{ github.workspace }}/cacti
191+
192+
- name: Checking coding standards on base code
193+
run: composer run-script phpcsfixer ${{ github.workspace }}/cacti/plugins/intropage
194+
working-directory: ${{ github.workspace }}/cacti
195+
196+
# - name: Run PHPStan at Level 6 on base code outside of Composer due to technical issues
197+
# run: ./include/vendor/bin/phpstan analyze --level 6 ${{ github.workspace }}/cacti/plugins/intropage
198+
# working-directory: ${{ github.workspace }}/cacti
183199

184-
- name: Run intropage poller
200+
- name: Run Cacti Poller
185201
run: |
186202
cd ${{ github.workspace }}/cacti
203+
sudo php poller.php --poller=1 --force --debug
204+
if ! grep -q "SYSTEM STATS" log/cacti.log; then
205+
echo "Cacti poller did not finish successfully"
206+
cat log/cacti.log
207+
exit 1
208+
fi
187209
sudo php plugins/intropage/poller_intropage.php
188-
189-
210+
190211
- name: View Cacti Logs
191212
if: always()
192213
run: |
193214
if [ -f ${{ github.workspace }}/cacti/log/cacti.log ]; then
194215
echo "=== Cacti Log ==="
195216
sudo cat ${{ github.workspace }}/cacti/log/cacti.log
196217
fi
197-
198-

display.php

Lines changed: 44 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function display_information() {
5252
db_execute_prepared('INSERT INTO plugin_intropage_user_auth
5353
(user_id)
5454
VALUES (?)',
55-
array($_SESSION['sess_user_id']));
55+
[$_SESSION['sess_user_id']]);
5656

5757
$user_panels = 0;
5858
}
@@ -82,19 +82,19 @@ function display_information() {
8282
$number_of_dashboards = db_fetch_cell_prepared('SELECT COUNT(*)
8383
FROM plugin_intropage_dashboard
8484
WHERE user_id = ?',
85-
array($_SESSION['sess_user_id']));
85+
[$_SESSION['sess_user_id']]);
8686

8787
// console access
8888
$console_access = api_plugin_user_realm_auth('index.php');
8989

9090
// remove admin prohibited panels
91-
$panels = db_fetch_assoc_prepared ('SELECT pd.panel_id AS panel_name, pd.id AS id
91+
$panels = db_fetch_assoc_prepared('SELECT pd.panel_id AS panel_name, pd.id AS id
9292
FROM plugin_intropage_panel_data AS pd
9393
INNER JOIN plugin_intropage_panel_dashboard AS pda
9494
ON pd.id = pda.panel_id
9595
WHERE pda.user_id = ?
9696
AND pda.dashboard_id = ?',
97-
array($_SESSION['sess_user_id'], $dashboard_id));
97+
[$_SESSION['sess_user_id'], $dashboard_id]);
9898

9999
if (cacti_sizeof($panels)) {
100100
$removed = 0;
@@ -107,12 +107,12 @@ function display_information() {
107107
WHERE user_id = ?
108108
AND dashboard_id = ?
109109
AND panel_id = ?',
110-
array($_SESSION['sess_user_id'], $dashboard_id, $one['id']));
110+
[$_SESSION['sess_user_id'], $dashboard_id, $one['id']]);
111111

112112
db_execute_prepared('DELETE FROM plugin_intropage_panel_data
113113
WHERE user_id = ?
114114
AND panel_id = ?',
115-
array($_SESSION['sess_user_id'], $one['id']));
115+
[$_SESSION['sess_user_id'], $one['id']]);
116116

117117
$removed++;
118118
}
@@ -148,12 +148,12 @@ function display_information() {
148148
AND t3.panel_id = 'favourite_graph'
149149
AND t3.fav_graph_id IS NOT NULL
150150
$sql_order",
151-
array(
151+
[
152152
$_SESSION['sess_user_id'],
153153
$dashboard_id,
154154
$_SESSION['sess_user_id'],
155155
$dashboard_id
156-
)
156+
]
157157
);
158158

159159
// remove prohibited panels (for common panels (user_id=0))
@@ -162,18 +162,18 @@ function display_information() {
162162
$allowed = is_panel_allowed($value['panel_id']);
163163

164164
if (!$allowed) {
165-
unset ($panels[$key]);
165+
unset($panels[$key]);
166166
} else {
167167
// user has permission but no active panel
168168
$upanels = db_fetch_cell_prepared('SELECT COUNT(*)
169169
FROM plugin_intropage_panel_dashboard
170170
WHERE user_id = ?
171171
AND dashboard_id = ?
172172
AND panel_id = ?',
173-
array($_SESSION['sess_user_id'], $dashboard_id, $value['id']));
173+
[$_SESSION['sess_user_id'], $dashboard_id, $value['id']]);
174174

175175
if ($upanels == 0) {
176-
unset ($panels[$key]);
176+
unset($panels[$key]);
177177
}
178178
}
179179
}
@@ -182,15 +182,15 @@ function display_information() {
182182
// Notice about disable cacti dashboard
183183
if (read_config_option('hide_console') != 'on') {
184184
print '<table class="cactiTable"><tr><td class="textAreaNotes">' . __('You can disable rows above in <b>Configure > Settings > General > Hide Cacti Dashboard</b> and use the whole page for Intropage ', 'intropage');
185-
print '<a class="pic" href="' . $config['url_path'] . 'settings.php?tab=general&filter=hide"><i class="intro_glyph fas fa-link"></i></a></td></tr></table></br>';
185+
print '<a class="pic" href="' . $config['url_path'] . 'settings.php?tab=general&filter=hide"><i class="intro_glyph fas fa-link"></i></a></td></tr></table></br>';
186186
}
187187

188188
$dashboards = array_rekey(
189-
db_fetch_assoc_prepared ('SELECT dashboard_id, name
189+
db_fetch_assoc_prepared('SELECT dashboard_id, name
190190
FROM plugin_intropage_dashboard
191191
WHERE user_id = ?
192192
ORDER BY dashboard_id',
193-
array($_SESSION['sess_user_id'])),
193+
[$_SESSION['sess_user_id']]),
194194
'dashboard_id', 'name'
195195
);
196196

@@ -203,18 +203,18 @@ function display_information() {
203203
db_execute_prepared('INSERT INTO plugin_intropage_dashboard
204204
(user_id, dashboard_id, name)
205205
VALUES (?, ?, ?)',
206-
array($_SESSION['sess_user_id'], $dashboard_id, $dashboards[1]));
206+
[$_SESSION['sess_user_id'], $dashboard_id, $dashboards[1]]);
207207
}
208208

209209
// wide or normal number of panels on line
210210
if ($display_wide == 'on') {
211211
$width_quarter = 'calc(25% - 1em)';
212-
$width_third = 'calc(33% - 1em)';
213-
$width_half = 'calc(50% - 1em)';
212+
$width_third = 'calc(33% - 1em)';
213+
$width_half = 'calc(50% - 1em)';
214214
} else {
215215
$width_quarter = 'calc(33% - 1em)';
216-
$width_third = 'calc(50% - 1em)';
217-
$width_half = 'calc(66% - 1em)';
216+
$width_third = 'calc(50% - 1em)';
217+
$width_half = 'calc(66% - 1em)';
218218
}
219219

220220
// Intropage Display ----------------------------------
@@ -234,7 +234,7 @@ function display_information() {
234234
}
235235
}
236236

237-
print "</ul></nav></div>";
237+
print '</ul></nav></div>';
238238
print '</div>';
239239
print '<div class="float_right">';
240240

@@ -254,15 +254,15 @@ function display_information() {
254254

255255
print "<select id='intropage_action_timespan'>";
256256

257-
foreach($trend_timespans as $key => $value) {
257+
foreach ($trend_timespans as $key => $value) {
258258
if ($timespan == $key) {
259259
print "<option value='timespan_$key' selected='selected'>" . $value . '</option>';
260260
} else {
261261
print "<option value='timespan_$key'>" . $value . '</option>';
262262
}
263263
}
264264

265-
print "</select>";
265+
print '</select>';
266266
print '&nbsp; &nbsp; ';
267267

268268
print "<select id='intropage_action'>";
@@ -364,7 +364,6 @@ function display_information() {
364364

365365
print '<option value="" disabled="disabled">─────────────────────────</option>';
366366

367-
368367
if ($display_important_first == 'on') {
369368
print "<option value='important_first' disabled='disabled'>" . __('Sort by Severity', 'intropage') . '</option>';
370369
print "<option value='important_no'>" . __('Sort by User Preference', 'intropage') . '</option>';
@@ -412,7 +411,7 @@ function display_information() {
412411
(SELECT COUNT(panel_id) FROM plugin_intropage_panel_dashboard WHERE dashboard_id = t2.dashboard_id AND user_id = ?) as panels
413412
FROM plugin_intropage_dashboard AS t2
414413
WHERE user_id = ? AND dashboard_id = ?',
415-
array ($_SESSION['sess_user_id'], $_SESSION['sess_user_id'], $_SESSION['dashboard_id']));
414+
[$_SESSION['sess_user_id'], $_SESSION['sess_user_id'], $_SESSION['dashboard_id']]);
416415

417416
if (!empty($actual)) {
418417
if ($actual['shared']) {
@@ -432,17 +431,16 @@ function display_information() {
432431

433432
$shared_dashboards = db_fetch_assoc_prepared('SELECT dashboard_id,name,user_id FROM plugin_intropage_dashboard
434433
WHERE shared = 1 AND user_id != ?',
435-
array ($_SESSION['sess_user_id']));
434+
[$_SESSION['sess_user_id']]);
436435

437436
if (cacti_sizeof($shared_dashboards) > 0) {
438-
439-
foreach ($shared_dashboards as $sd) {
440-
$text = ' (' . get_username($sd['user_id']) . ' - ' . $sd['name'] . ')' ;
437+
foreach ($shared_dashboards as $sd) {
438+
$text = ' (' . get_username($sd['user_id']) . ' - ' . $sd['name'] . ')';
441439

442440
if ($number_of_dashboards < 9) {
443-
print "<option value='useshared_" . $sd['dashboard_id'] . "_" . $sd['user_id'] . "'>" . __('Use shared dashboard', 'intropage') . $text . '</option>';
441+
print "<option value='useshared_" . $sd['dashboard_id'] . '_' . $sd['user_id'] . "'>" . __('Use shared dashboard', 'intropage') . $text . '</option>';
444442
} else {
445-
print "<option value='useshared_" . $sd['dashboard_id'] . "_" . $sd['user_id'] . "' disabled='disabled'>" . __('Cannot use shared dashboard - dashboard limit reached.', 'intropage') . $text . '</option>';
443+
print "<option value='useshared_" . $sd['dashboard_id'] . '_' . $sd['user_id'] . "' disabled='disabled'>" . __('Cannot use shared dashboard - dashboard limit reached.', 'intropage') . $text . '</option>';
446444
}
447445
}
448446
} else {
@@ -508,16 +506,15 @@ function display_information() {
508506
$first_db = db_fetch_cell_prepared('SELECT MIN(IFNULL(dashboard_id, 1))
509507
FROM plugin_intropage_dashboard
510508
WHERE user_id = ?',
511-
array($_SESSION['sess_user_id']));
509+
[$_SESSION['sess_user_id']]);
512510

513511
// extra maint plugin panel - always first
514512
if (api_plugin_is_enabled('maint') && (read_config_option('intropage_maint_plugin_days_before') >= 0)) {
515-
516513
$row = db_fetch_row_prepared("SELECT id, data
517514
FROM plugin_intropage_panel_data
518515
WHERE panel_id = 'maint'
519516
AND user_id = ?",
520-
array($_SESSION['sess_user_id']));
517+
[$_SESSION['sess_user_id']]);
521518

522519
if (isset($row['data']) && $row['data'] != null && $dashboard_id == $first_db) {
523520
intropage_create_panel($row['id'], $dashboard_id);
@@ -550,32 +547,32 @@ function display_information() {
550547

551548
var refresh;
552549
var pollerRefresh;
553-
var intropage_autorefresh = <?php print $autorefresh;?>;
550+
var intropage_autorefresh = <?php print $autorefresh; ?>;
554551
var intropage_drag = true;
555552
var intropage_square = true;
556553
var callbackPage = '';
557554
var redirectPage = '';
558-
var fullPage = <?php print $display_important_first == 'on' ? 'true':'false';?>;
559-
var dashboard_id = <?php print $dashboard_id;?>;
560-
var intropage_text_panel_details = '<?php print __('Panel Details', 'intropage');?>';
561-
var intropage_text_panel_disable = '<?php print __esc('Disable panel move/Enable copy text from panel', 'intropage');?>';
562-
var intropage_text_panel_enable = '<?php print __esc('Enable panel move/Disable copy text from panel', 'intropage');?>';
563-
var intropage_text_square_disable = '<?php print __esc('Hide red/yellow/green square notifications', 'intropage');?>';
564-
var intropage_text_square_enable = '<?php print __esc('Show red/yellow/green square notifications', 'intropage');?>';
555+
var fullPage = <?php print $display_important_first == 'on' ? 'true' : 'false'; ?>;
556+
var dashboard_id = <?php print $dashboard_id; ?>;
557+
var intropage_text_panel_details = '<?php print __('Panel Details', 'intropage'); ?>';
558+
var intropage_text_panel_disable = '<?php print __esc('Disable panel move/Enable copy text from panel', 'intropage'); ?>';
559+
var intropage_text_panel_enable = '<?php print __esc('Enable panel move/Disable copy text from panel', 'intropage'); ?>';
560+
var intropage_text_square_disable = '<?php print __esc('Hide red/yellow/green square notifications', 'intropage'); ?>';
561+
var intropage_text_square_enable = '<?php print __esc('Show red/yellow/green square notifications', 'intropage'); ?>';
565562

566-
var intropage_text_data_error = '<?php print __('Error reading new data', 'intropage');?>';
567-
var intropage_text_close = '<?php print __('Close', 'intropage');?>';
563+
var intropage_text_data_error = '<?php print __('Error reading new data', 'intropage'); ?>';
564+
var intropage_text_close = '<?php print __('Close', 'intropage'); ?>';
568565

569566
var panels = {};
570567

571-
var intropage_panel_quarter_width = '<?php echo $width_quarter; ?>';
572-
var intropage_panel_third_width = '<?php echo $width_third; ?>';
573-
var intropage_panel_half_width = '<?php echo $width_half; ?>';
568+
var intropage_panel_quarter_width = '<?php print $width_quarter; ?>';
569+
var intropage_panel_third_width = '<?php print $width_third; ?>';
570+
var intropage_panel_half_width = '<?php print $width_half; ?>';
574571

575572
</script>
576573

577574
<?php
578-
print get_md5_include_js($config['base_path'].'/plugins/intropage/include/intropage.js');
575+
print get_md5_include_js($config['base_path'] . '/plugins/intropage/include/intropage.js');
579576

580577
return true;
581578
}

0 commit comments

Comments
 (0)