View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0002184 | OXID eShop (all versions) | 1. ----- eShop frontend ----- | public | 2010-10-28 20:06 | 2012-12-10 14:38 |
Reporter | Moehlis | Assigned To | |||
Priority | normal | Severity | major | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
Product Version | 4.4.3 revision 30016 | ||||
Fixed in Version | 4.5.6 revision 40808 | ||||
Summary | 0002184: error in spl implementation of Iterator | ||||
Description | while iterating through an oxlist object using foreach, unsetting the current entry will result in skipping the next entry. thats because the unset is done directly on the object. so while the array loses the current element, it already points to the next one, meaning the next foreach loop will get the one after next. its a bit complicated, so i'll insert my test code. you will see what will happen if you trying this in an oxid module or portlet, maybe paypal... | ||||
Additional Information | <?php class _anzido extends oxUBase { public function init () { $this->_oxid(); $this->_php(); die( 'EOF ' . time() ); } public function _oxid () { $oList = oxNew('oxarticlelist'); $oList->selectString ( 'SELECT * FROM oxarticles limit 10' ); foreach ( $oList as $sKey => $oArticle ) { echo $oArticle->getId().' '; // $oList->rewind(); // this would help but doesnt solve the problem in the implementation unset($oList[$sKey]); } } public function _php () { $it = new MyIterator(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)); foreach ($it as $a => $b) { echo $b . ' '; unset($it[$a]); } } } class MyIterator implements Iterator, arrayaccess { private $var = array(); public function __construct($array) { if (is_array($array)) { $this->var = $array; } } public function rewind() { reset($this->var); } public function current() { $var = current($this->var); return $var; } public function key() { $var = key($this->var); return $var; } public function next() { $var = next($this->var); return $var; } public function valid() { $var = $this->current() !== false; return $var; } public function offsetSet($offset, $value) { $this->container[$offset] = $value; } public function offsetExists($offset) { return isset($this->container[$offset]); } public function offsetUnset($offset) { unset($this->container[$offset]); } public function offsetGet($offset) { return isset($this->container[$offset]) ? $this->container[$offset] : null; } } | ||||
Tags | No tags attached. | ||||
Theme | |||||
Browser | All | ||||
PHP Version | 5.2.9 | ||||
Database Version | any | ||||
related to | 0003627 | resolved | aurimas.gladutis | getVariantListExceptCurrent() on easy variant wrong |