Skip to content
Browse files

fix unchecked foreach loops

  • Loading branch information...
1 parent 3b0d855 commit e7b43fe5a24b34d5df66aa59b84a79ad2f66c6e2 diml committed Nov 20, 2007
Showing with 27 additions and 22 deletions.
  1. +8 −6 search/documents/resource_document.php
  2. +19 −16 search/documents/techproject_document.php
View
14 search/documents/resource_document.php
@@ -130,12 +130,14 @@ function resource_get_content_for_index(&$notneeded) {
$resources = get_records_sql($query);
// invokes external content extractor if exists.
- foreach($resources as $aResource){
- // fetches a physical indexable document and adds it to documents passed by ref
- $coursemodule = get_field('modules', 'id', 'name', 'resource');
- $cm = get_record('course_modules', 'id', $aResource->id);
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
- resource_get_physical_file($aResource, $context->id, false, $documents);
+ if ($resources){
+ foreach($resources as $aResource){
+ // fetches a physical indexable document and adds it to documents passed by ref
+ $coursemodule = get_field('modules', 'id', 'name', 'resource');
+ $cm = get_record('course_modules', 'id', $aResource->id);
+ $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+ resource_get_physical_file($aResource, $context->id, false, $documents);
+ }
}
}
return $documents;
View
35 search/documents/techproject_document.php
@@ -79,26 +79,29 @@ function techproject_get_content_for_index(&$techproject) {
$cm = get_record('course_modules', 'course', $techproject->course, 'module', $coursemodule, 'instance', $techproject->id);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
- $entries = array_merge($requirements, $specifications, $milestones, $deliverables);
- foreach($entries as $anEntry) {
- if ($anEntry) {
- if (strlen($anEntry->description) > 0) {
- $documents[] = new TechprojectEntrySearchDocument(get_object_vars($anEntry), $techproject->course, $context->id);
+ $entries = @array_merge($requirements, $specifications, $milestones, $deliverables);
+ if ($entries){
+ foreach($entries as $anEntry) {
+ if ($anEntry) {
+ if (strlen($anEntry->description) > 0) {
+ $documents[] = new TechprojectEntrySearchDocument(get_object_vars($anEntry), $techproject->course, $context->id);
+ }
}
}
- }
-
- foreach($tasks as $aTask) {
- if ($aTask) {
- if (strlen($aTask->description) > 0) {
- if ($aTask->assignee){
- $user = get_record('user', 'id', $aTask->assignee);
- $aTask->author = $user->firstname.' '.$user->lastname;
- }
- $documents[] = new TechprojectEntrySearchDocument(get_object_vars($aTask), $techproject->course, $context->id);
+ }
+ if ($tasks){
+ foreach($tasks as $aTask) {
+ if ($aTask) {
+ if (strlen($aTask->description) > 0) {
+ if ($aTask->assignee){
+ $user = get_record('user', 'id', $aTask->assignee);
+ $aTask->author = $user->firstname.' '.$user->lastname;
+ }
+ $documents[] = new TechprojectEntrySearchDocument(get_object_vars($aTask), $techproject->course, $context->id);
+ }
}
}
- }
+ }
return $documents;
} //techproject_get_content_for_index

0 comments on commit e7b43fe

Please sign in to comment.
Something went wrong with that request. Please try again.