Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add checks to avoid PHP Notices in Resources code. #233

Merged

Conversation

t4k
Copy link
Contributor

@t4k t4k commented Jun 13, 2017

Mostly using isset(). All original notices are included in the commit messages.

Issue #77

t4k added 7 commits June 12, 2017 13:53
PHP message: PHP Notice: Undefined index: orderBy in /var/www/coral/resources/admin/classes/domain/Resource.php on line 805
PHP message: PHP Notice: Undefined index: page in /var/www/coral/resources/admin/classes/domain/Resource.php on line 805
PHP message: PHP Notice: Undefined index: recordsPerPage in /var/www/coral/resources/admin/classes/domain/Resource.php on line 805
PHP message: PHP Notice: Undefined variable: currentPage in /var/www/coral/resources/index.php on line 32
PHP message: PHP Notice: Undefined index: startWith in /var/www/coral/resources/index.php on line 49
PHP message: PHP Notice: Undefined index: name in /var/www/coral/resources/index.php on line 69
PHP message: PHP Notice: Undefined index: resourceISBNOrISSN in /var/www/coral/resources/index.php on line 80
PHP message: PHP Notice: Undefined index: fund in /var/www/coral/resources/index.php on line 92
PHP message: PHP Notice: Undefined index: acquisitionTypeID in /var/www/coral/resources/index.php on line 125
PHP message: PHP Notice: Undefined index: acquisitionTypeID in /var/www/coral/resources/index.php on line 125
PHP message: PHP Notice: Undefined index: acquisitionTypeID in /var/www/coral/resources/index.php on line 125
PHP message: PHP Notice: Undefined index: acquisitionTypeID in /var/www/coral/resources/index.php on line 125
PHP message: PHP Notice: Undefined index: statusID in /var/www/coral/resources/index.php on line 150
PHP message: PHP Notice: Undefined index: statusID in /var/www/coral/resources/index.php on line 150
PHP message: PHP Notice: Undefined index: statusID in /var/www/coral/resources/index.php on line 150
PHP message: PHP Notice: Undefined index: creatorLoginID in /var/www/coral/resources/index.php on line 186
PHP message: PHP Notice: Undefined index: resourceFormatID in /var/www/coral/resources/index.php on line 211
PHP message: PHP Notice: Undefined index: resourceFormatID in /var/www/coral/resources/index.php on line 211
PHP message: PHP Notice: Undefined index: resourceFormatID in /var/www/coral/resources/index.php on line 211
PHP message: PHP Notice: Undefined index: resourceTypeID in /var/www/coral/resources/index.php on line 232
PHP message: PHP Notice: Undefined index: resourceTypeID in /var/www/coral/resources/index.php on line 243
PHP message: PHP Notice: Undefined index: generalSubjectID in /var/www/coral/resources/index.php on line 264
PHP message: PHP Notice: Undefined index: generalSubjectID in /var/www/coral/resources/index.php on line 275
PHP message: PHP Notice: Undefined index: detailedSubjectID in /var/www/coral/resources/index.php on line 295
PHP message: PHP Notice: Undefined index: noteTypeID in /var/www/coral/resources/index.php on line 356
PHP message: PHP Notice: Undefined index: noteTypeID in /var/www/coral/resources/index.php on line 366
PHP message: PHP Notice: Undefined index: noteTypeID in /var/www/coral/resources/index.php on line 366
PHP message: PHP Notice: Undefined index: noteTypeID in /var/www/coral/resources/index.php on line 366
PHP message: PHP Notice: Undefined index: noteTypeID in /var/www/coral/resources/index.php on line 366
PHP message: PHP Notice: Undefined index: noteTypeID in /var/www/coral/resources/index.php on line 366
PHP message: PHP Notice: Undefined index: noteTypeID in /var/www/coral/resources/index.php on line 366
PHP message: PHP Notice: Undefined index: resourceNote in /var/www/coral/resources/index.php on line 382
PHP message: PHP Notice: Undefined index: resourceNote in /var/www/coral/resources/index.php on line 384
PHP message: PHP Notice: Undefined index: createDateStart in /var/www/coral/resources/index.php on line 393
PHP message: PHP Notice: Undefined index: createDateEnd in /var/www/coral/resources/index.php on line 399
PHP message: PHP Notice: Undefined index: purchaseSiteID in /var/www/coral/resources/index.php on line 414
PHP message: PHP Notice: Undefined index: purchaseSiteID in /var/www/coral/resources/index.php on line 424
PHP message: PHP Notice: Undefined index: authorizedSiteID in /var/www/coral/resources/index.php on line 446
PHP message: PHP Notice: Undefined index: authorizedSiteID in /var/www/coral/resources/index.php on line 456
PHP message: PHP Notice: Undefined index: administeringSiteID in /var/www/coral/resources/index.php on line 478
PHP message: PHP Notice: Undefined index: administeringSiteID in /var/www/coral/resources/index.php on line 488
PHP message: PHP Notice: Undefined index: authenticationTypeID in /var/www/coral/resources/index.php on line 508
PHP message: PHP Notice: Undefined index: authenticationTypeID in /var/www/coral/resources/index.php on line 519
PHP message: PHP Notice: Undefined index: authenticationTypeID in /var/www/coral/resources/index.php on line 519
PHP message: PHP Notice: Undefined index: authenticationTypeID in /var/www/coral/resources/index.php on line 519
PHP message: PHP Notice: Undefined index: catalogingStatusID in /var/www/coral/resources/index.php on line 537
PHP message: PHP Notice: Undefined index: catalogingStatusID in /var/www/coral/resources/index.php on line 546
PHP message: PHP Notice: Undefined index: catalogingStatusID in /var/www/coral/resources/index.php on line 546
PHP message: PHP Notice: Undefined index: catalogingStatusID in /var/www/coral/resources/index.php on line 546
PHP message: PHP Notice: Undefined index: stepName in /var/www/coral/resources/index.php on line 568
PHP message: PHP Notice: Undefined index: stepName in /var/www/coral/resources/index.php on line 568
PHP message: PHP Notice: Undefined index: stepName in /var/www/coral/resources/index.php on line 568
PHP message: PHP Notice: Undefined index: stepName in /var/www/coral/resources/index.php on line 568
PHP message: PHP Notice:  Undefined variable: currentPage in /var/www/coral/resources/queue.php on line 24
PHP message: PHP Warning:  session_start(): Cannot send session cookie - headers already sent by (output started at /var/www/coral/resources/templates/header.php:183) in /var/www/coral/resources/admin/classes/common/CoralSession.php on line 25
PHP message: PHP Warning:  session_start(): Cannot send session cache limiter - headers already sent (output started at /var/www/coral/resources/templates/header.php:183) in /var/www/coral/resources/admin/classes/common/CoralSession.php on line 25
PHP message: PHP Notice:  Undefined variable: currentPage in /var/www/coral/resources/admin.php on line 24
PHP message: PHP Notice:  Undefined variable: currentPage in /var/www/coral/resources/resource.php on line 34
PHP message: PHP Notice:  Undefined index: ref in /var/www/coral/resources/resource.php on line 52
PHP message: PHP Notice:  Undefined index: workflowID in /var/www/coral/resources/admin/classes/domain/Resource.php on line 1976
PHP message: PHP Notice:  Undefined variable: resourceOrganization in /var/www/coral/resources/ajax_forms/getUpdateProductForm.php on line 306
PHP message: PHP Notice:  Undefined index: resourceID in /var/www/coral/resources/admin/classes/domain/Resource.php on line 1526
PHP message: PHP Notice:  Undefined index: organizationID in /var/www/coral/resources/ajax_forms/getNewDowntimeForm.php on line 4
PHP message: PHP Notice:  Undefined index: issueID in /var/www/coral/resources/ajax_forms/getNewDowntimeForm.php on line 7
PHP message: PHP Notice:  Undefined offset: 0 in /var/www/coral/resources/admin/classes/domain/Downtime.php on line 67
PHP message: PHP Notice:  Undefined index: downtimeTypeID in /var/www/coral/resources/ajax_forms/getNewDowntimeForm.php on line 97
PHP message: PHP Notice:  Undefined index: shortName in /var/www/coral/resources/ajax_forms/getNewDowntimeForm.php on line 97
Copy link
Member

@jeffnm jeffnm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, except for the one comment I left about the change Downtime.php which seems to break the functionality, unless I'm mistaken.

@@ -64,7 +64,7 @@ public function getDowntimeTypesArray() {
$result = $this->db->processQuery($query, "assoc");
$names = array();

if (is_array($result[0])) {
if (is_array(isset($result[0]))) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see how this would avoid an undefined index error, but it won't work when the index is set either. is_array will return false with a true or a false result from isset, so the foreach loop will never trigger.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Thank you. I’ll put in a fix shortly.

@jeffnm jeffnm added bug This is a bug (not an enhancement) refactor labels Oct 10, 2017
@t4k
Copy link
Contributor Author

t4k commented Oct 11, 2017

I’ve changed the isset() check to be distinct from the is_array() check which should clear things up.

@jeffnm
Copy link
Member

jeffnm commented Oct 11, 2017

Everything looks good to me. I think we can merge this.

@t4k t4k merged commit 4c5eef8 into coral-erm:development Oct 19, 2017
@t4k
Copy link
Contributor Author

t4k commented Oct 19, 2017

Merging based on the review by @jeffnm.

@t4k t4k deleted the issue77-php-notices-resources branch October 19, 2017 22:53
@t4k
Copy link
Contributor Author

t4k commented Oct 19, 2017

I tried the Squash and Merge option on this PR to try and keep the history cleaner, and it doesn’t create a merge commit, which might be what we want. Maybe we should discuss this in an issue.

@PaulPoulain PaulPoulain added this to the Version 2.0.0 milestone Mar 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This is a bug (not an enhancement) refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants