Index: src/com/caucho/quercus/lib/VariableModule.java =================================================================== --- src/com/caucho/quercus/lib/VariableModule.java (revision 4182) +++ src/com/caucho/quercus/lib/VariableModule.java (working copy) @@ -665,7 +665,7 @@ return v; } - boolean useReference = s.indexOf("R:") > 0; + boolean useReference = s.indexOf("R:") > 0 || s.indexOf("r:") > 0; UnserializeReader is = null; @@ -681,7 +681,7 @@ v = BooleanValue.FALSE; } - if (! is.hasReference()) { + if (is != null && ! is.hasReference()) { entry = new UnserializeCacheEntry(v); _unserializeCache.put(s, entry); Index: src/com/caucho/quercus/lib/UnserializeReader.java =================================================================== --- src/com/caucho/quercus/lib/UnserializeReader.java (revision 4182) +++ src/com/caucho/quercus/lib/UnserializeReader.java (working copy) @@ -199,7 +199,7 @@ } if (ch != ';') - throw new IOException(L.l("expected ';'")); + throw new IOException(L.l("expected ';' (index: '{0}')", String.valueOf(_index))); Value value = new DoubleValue(Double.parseDouble(sb.toString())); @@ -301,6 +301,7 @@ return value; } + case 'r': case 'R': { _hasReference = true; @@ -311,7 +312,25 @@ expect(';'); - return _valueList.get(value - 1); + if (_useReference) { + Value dummyval = createReference(BooleanValue.create(Boolean.FALSE)); + + _valueList.add(dummyval); + } + + + if (value < _valueList.size()) + return _valueList.get(value - 1); + else + { + throw new IOException(L.l("reference id '{0}' not found in list (max id: {1}, parse index: {2})", + String.valueOf(value), + String.valueOf(_valueList.size()), + String.valueOf(_index))); + } + + + } default: @@ -513,6 +532,7 @@ return; } + case 'r': case 'R': { _referenceList.add(Boolean.FALSE); @@ -594,9 +614,10 @@ int ch = read(); if (ch != 's' && ch != 'S') { - throw new IOException(L.l("expected 's' at '{1}' (0x{2})", + throw new IOException(L.l("expected 's' at '{0}' (0x{1}, index: '{2}')", String.valueOf((char) ch), - Integer.toHexString(ch))); + Integer.toHexString(ch), + String.valueOf(this._index))); } expect(':'); @@ -629,11 +650,12 @@ if (_index < _buffer.length) context += _buffer[_index]; - throw new IOException(L.l("expected '{0}' at '{1}' (0x{2}) (context '{3}')", + throw new IOException(L.l("expected '{0}' at '{1}' (0x{2}) (context '{3}', index: '{4}')", String.valueOf((char) expectCh), String.valueOf((char) ch), Integer.toHexString(ch), - context)); + context, + String.valueOf(_index))); } }