refactor: Centralize includes and initialization #4991

Merged
merged 5 commits into from Nov 21, 2016

Projects

None yet

4 participants

@murrant
Contributor
murrant commented Nov 14, 2016

Please note

Please read this information carefully. You can run ./scripts/pre-commit.php to check your code before submitting.

Remove initialization code from files that define functions or variables
Files that contain functions and variable definitions should not contain any code.

Tested, please test further:
./contrib/generate-iplist.php
./html/ajax_dash.php
./html/ajax_form.php
./html/ajax_listports.php
./html/ajax_output.php
./html/ajax_table.php
./html/api_v0.php
./html/data.php
./html/graph-realtime.php
./html/netcmd.php
./html/network-map.php
./html/pdf.php
./html/index.php
./html/install.php
./html/ajax_search.php
./html/ajax_rulesuggest.php
./html/graph.php
./scripts/console-ui.php
./scripts/gen_smokeping.php
./scripts/tune_port.php
./includes/sql-schema/update.php
./addhost.php
./adduser.php
./alerts.php
./check-services.php
./daily.php
./delhost.php
./discovery.php
./dist-pollers.php
./irc.php
./poller.php
./renamehost.php
./snmptrap.php
./syslog.php
./snmp-scan.php

Untested:
./html/form_new_config.php
./html/bandwidth-graph.php
./html/billing-graph.php
./billing-calculate.php
./poll-billing.php
./html/csv.php

@murrant murrant refactor: Centralize includes and initialization
Remove initialization code from files that define functions or variables
Files that contain functions and variable definitions should not contain any code.

Tested, please test further:
./contrib/generate-iplist.php
./html/ajax_dash.php
./html/ajax_form.php
./html/ajax_listports.php
./html/ajax_output.php
./html/ajax_table.php
./html/api_v0.php
./html/data.php
./html/graph-realtime.php
./html/netcmd.php
./html/network-map.php
./html/pdf.php
./html/index.php
./html/install.php
./html/ajax_search.php
./html/ajax_rulesuggest.php
./html/graph.php
./scripts/console-ui.php
./scripts/gen_smokeping.php
./scripts/tune_port.php
./includes/sql-schema/update.php
./addhost.php
./adduser.php
./alerts.php
./check-services.php
./daily.php
./delhost.php
./discovery.php
./dist-pollers.php
./irc.php
./poller.php
./renamehost.php
./snmptrap.php
./syslog.php
./snmp-scan.php

Untested:
./html/form_new_config.php
./html/bandwidth-graph.php
./html/billing-graph.php
./billing-calculate.php
./poll-billing.php
./html/csv.php
8c4cbfd
@laf
Member
laf commented Nov 15, 2016

./html/form_new_config.php - Don't think this is used. It looks left over from the initial attempt at dynamic config. Same with the add_config_item() function.

Billing quick graphs are broken:


Notice: Undefined variable: config in /opt/librenms/html/graph.php on line 31

Fatal error: Cannot redeclare format_bytes_billing() (previously declared in /opt/librenms/includes/billing.php:4) in /opt/librenms/includes/billing.php on line 9

./html/bandwidth-graph.php - Good.

./html/billing-graph.php - Good.

./html/csv.php - Good

witched to branch 'init'
-bash-4.2$ ./poller-wrapper.py 2
Traceback (most recent call last):
  File "./poller-wrapper.py", line 77, in <module>
    poller_path = config['install_dir'] + '/poller.php'
KeyError: 'install_dir'

I'll test billing at home over the weekend.

@laf laf added the Blocker label Nov 15, 2016
murrant added some commits Nov 15, 2016
@murrant murrant Fix unuath graphs, validate, and config_to_json missing install_dir 83db2c9
@murrant murrant Remove html/form_new_config.php and add_config_item()
f2666f8
@murrant murrant removed the Blocker label Nov 15, 2016
@murrant murrant Cisco uses rewrites in discovery..
b440617
@scrutinizer-notifier

The inspection completed: 13 new issues, 2 updated code elements

@laf
Member
laf commented Nov 17, 2016

Re-tested the elements I mentioned and they are all working fine now.

I've deployed at home where I run billing properly so will leave that running for a bit longer.

@laf
laf approved these changes Nov 18, 2016 View changes
@laf laf merged commit 9a33464 into librenms:master Nov 21, 2016

2 checks passed

Auto-Deploy Build finished.
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@murrant murrant deleted the murrant:init branch Nov 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment