UPDATE - I did not find the problem. I'm assuming that the person who deleted their comments was right and either Asset.php or array_shift() was being called twice. What I did find was a sweet spot in another file that handled the form object and allowed me to manipulate the array as I intended without deleting extra elements. Left this up in case anyone wants to browse through it.
I have a website run by a Controller.php that shows different pages according to a GET value run through a switch. The relevant case is:
case 'pgImportAsset': {
require_once FORMS_DIR.'/Asset.php';
$form = new ImportAssetForm(&$smarty, &$req);
if(!empty($_SESSION['list'])){
$form->processTo(&$smarty, array('pg'=> 'pgImportAsset'));
} else {
$form->processTo(&$smarty, array('pg'=> 'pgListClip'));
}
break;
}
The $_SESSION['list'] variable is an array that stores strings of file names that come from a java applet that uploads those files. The array gets initialized perfectly to something like
Array
(
[0] => 0.jpg
[1] => 1.jpg
[2] => 2.jpg
[3] => 3.jpg
[4] => 4.jpg
)
and so on. Here's where it gets weird. The one line where the array gets decremented is in Asset.php
$this->filename=array_shift($_SESSION['list']);
The array will go into the instance of that page and I'll have a print_r statement right before and right after that line. Even though the array goes in with all 5 elements in it, the two print statements will show.
Array
(
[0] => 1.jpg
[1] => 2.jpg
[2] => 3.jpg
[3] => 4.jpg
)
Array
(
[0] => 2.jpg
[1] => 3.jpg
[2] => 4.jpg
)
It gets weirder. Shortly after that line in Asset.php I have this line (I'm using smarty).
$smarty->assign('filename',$this->filename);
And that shows up as the first element, which in this case would be 0.jpg. The value $this->filename then gets sent to a database without any lines of code altering it. What ends up stored in the database is 1.jpg.
I am completely lost and confused. Please help.
More information on it, Asset.php uses an object called ImportAssetForm that expands on the QuickForm library in PEAR as well as a couple other libraries including DB and some others.
This is not my code originally, I've just been tasked with changing it. The PEAR libraries are probably dated a little bit, but I don't have the knowledge of PEAR to go in and completely revamp the site.