Endless loop?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Endless loop?

Barnett, Jeffrey
For some (I'm not sure why not all) authors,
http://newton.library.yale.edu/vufind/Author/Home?author=Edwards,%20Jonathan,%201703-1758.
returns a blank page, after a long wait.  Enabling php error display produces an endless list of:

Notice: Undefined offset: 0 in /usr/local/yulprog/yu-dev/web/services/Author/Home.php on line 294

Notice: Undefined offset: 0 in /usr/local/yulprog/yu-dev/web/services/Author/Home.php on line 297
.....

The cited code looks like:
   289          // Retrieve Page Content
   290          $desc = "";
   291          $done = 0;
   292          $i = 0;
   293          while (!$done) {
   294              if (substr($body[0], 0, 2) == '==') {
   295                  $done = 1;
   296              } else {
   297                  $desc .= $body[0];
   298                  array_shift($body);
   299              }
   300              $i++;
   301          }

Shouldn't $body[0] be $body[i] ?  Apparently this only works if '==' is found on the first try.  Of course there should also be a check to see that $body is not null.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Vufind-tech mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/vufind-tech
Reply | Threaded
Open this post in threaded view
|

Re: Endless loop?

Andrew Nagy-2
Jeffrey - can you post the author name that you are having the problem with?

Thanks
Andrew

> -----Original Message-----
> From: [hidden email] [mailto:vufind-tech-
> [hidden email]] On Behalf Of Barnett, Jeffrey
> Sent: Thursday, August 14, 2008 9:21 AM
> To: [hidden email]
> Subject: [VuFind-Tech] Endless loop?
>
> For some (I'm not sure why not all) authors,
> http://newton.library.yale.edu/vufind/Author/Home?author=Edwards,%20Jon
> athan,%201703-1758.
> returns a blank page, after a long wait.  Enabling php error display
> produces an endless list of:
>
> Notice: Undefined offset: 0 in /usr/local/yulprog/yu-
> dev/web/services/Author/Home.php on line 294
>
> Notice: Undefined offset: 0 in /usr/local/yulprog/yu-
> dev/web/services/Author/Home.php on line 297
> .....
>
> The cited code looks like:
>    289          // Retrieve Page Content
>    290          $desc = "";
>    291          $done = 0;
>    292          $i = 0;
>    293          while (!$done) {
>    294              if (substr($body[0], 0, 2) == '==') {
>    295                  $done = 1;
>    296              } else {
>    297                  $desc .= $body[0];
>    298                  array_shift($body);
>    299              }
>    300              $i++;
>    301          }
>
> Shouldn't $body[0] be $body[i] ?  Apparently this only works if '==' is
> found on the first try.  Of course there should also be a check to see
> that $body is not null.
>
> -----------------------------------------------------------------------
> --
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the
> world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Vufind-tech mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/vufind-tech

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Vufind-tech mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/vufind-tech
Reply | Threaded
Open this post in threaded view
|

Re: Endless loop?

Andrew Nagy-2
In reply to this post by Barnett, Jeffrey
> The cited code looks like:
>    289          // Retrieve Page Content
>    290          $desc = "";
>    291          $done = 0;
>    292          $i = 0;
>    293          while (!$done) {
>    294              if (substr($body[0], 0, 2) == '==') {
>    295                  $done = 1;
>    296              } else {
>    297                  $desc .= $body[0];
>    298                  array_shift($body);
>    299              }
>    300              $i++;
>    301          }
>
> Shouldn't $body[0] be $body[i] ?  Apparently this only works if '==' is
> found on the first try.  Of course there should also be a check to see
> that $body is not null.

No - this is correct.  The content from wikipedia is parsed as an array with each paragraph in its own array element.  The code here looks at the first line to see if it should be kept and then removes it from the array.  So the 0th element is always being analyzed.

It's probably not the most efficient code in the world - but I believe this was written by one of my graduate assistants.

I think the problem you are experiencing is due to the record not being found or wikipedia responding with alternate possibilities.  I think the code I have should fix this as it is not happening now on my end.  I will check in the code.  however, the wikipedia code still needs a bit more work to process the alternate possibilites and then try to figure out which match is the best - not an easy task!

Andrew

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Vufind-tech mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/vufind-tech
Reply | Threaded
Open this post in threaded view
|

Re: Endless loop?

Barnett, Jeffrey
OK, $body[0] is correct, but then what is the purpose of "i"?
As I said, it either works on the first try or loops forever.  We both agree that the empty array must be caught, which I assume is what you checked in.  Thanks.

-----Original Message-----
From: Andrew Nagy [mailto:[hidden email]]
Sent: Thursday, August 14, 2008 9:52 AM
To: Barnett, Jeffrey; [hidden email]
Subject: RE: Endless loop?

> The cited code looks like:
>    289          // Retrieve Page Content
>    290          $desc = "";
>    291          $done = 0;
>    292          $i = 0;
>    293          while (!$done) {
>    294              if (substr($body[0], 0, 2) == '==') {
>    295                  $done = 1;
>    296              } else {
>    297                  $desc .= $body[0];
>    298                  array_shift($body);
>    299              }
>    300              $i++;
>    301          }
>
> Shouldn't $body[0] be $body[i] ?  Apparently this only works if '==' is
> found on the first try.  Of course there should also be a check to see
> that $body is not null.

No - this is correct.  The content from wikipedia is parsed as an array with each paragraph in its own array element.  The code here looks at the first line to see if it should be kept and then removes it from the array.  So the 0th element is always being analyzed.

It's probably not the most efficient code in the world - but I believe this was written by one of my graduate assistants.

I think the problem you are experiencing is due to the record not being found or wikipedia responding with alternate possibilities.  I think the code I have should fix this as it is not happening now on my end.  I will check in the code.  however, the wikipedia code still needs a bit more work to process the alternate possibilites and then try to figure out which match is the best - not an easy task!

Andrew

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Vufind-tech mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/vufind-tech
Reply | Threaded
Open this post in threaded view
|

Re: Endless loop?

Barnett, Jeffrey
My turn for Oops.
"The code here looks at the first line to see if it should be kept and then *removes* it from the array."
So there is no endless loop (except for a null array).

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Barnett, Jeffrey
Sent: Thursday, August 14, 2008 10:06 AM
To: Andrew Nagy; [hidden email]
Subject: Re: [VuFind-Tech] Endless loop?

OK, $body[0] is correct, but then what is the purpose of "i"?
As I said, it either works on the first try or loops forever.  We both agree that the empty array must be caught, which I assume is what you checked in.  Thanks.

-----Original Message-----
From: Andrew Nagy [mailto:[hidden email]]
Sent: Thursday, August 14, 2008 9:52 AM
To: Barnett, Jeffrey; [hidden email]
Subject: RE: Endless loop?

> The cited code looks like:
>    289          // Retrieve Page Content
>    290          $desc = "";
>    291          $done = 0;
>    292          $i = 0;
>    293          while (!$done) {
>    294              if (substr($body[0], 0, 2) == '==') {
>    295                  $done = 1;
>    296              } else {
>    297                  $desc .= $body[0];
>    298                  array_shift($body);
>    299              }
>    300              $i++;
>    301          }
>
> Shouldn't $body[0] be $body[i] ?  Apparently this only works if '==' is
> found on the first try.  Of course there should also be a check to see
> that $body is not null.

No - this is correct.  The content from wikipedia is parsed as an array with each paragraph in its own array element.  The code here looks at the first line to see if it should be kept and then removes it from the array.  So the 0th element is always being analyzed.

It's probably not the most efficient code in the world - but I believe this was written by one of my graduate assistants.

I think the problem you are experiencing is due to the record not being found or wikipedia responding with alternate possibilities.  I think the code I have should fix this as it is not happening now on my end.  I will check in the code.  however, the wikipedia code still needs a bit more work to process the alternate possibilites and then try to figure out which match is the best - not an easy task!

Andrew

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Vufind-tech mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/vufind-tech

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Vufind-tech mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/vufind-tech