Skip Navigation
Falvey Library
Advanced
You are exploring: Home > Blogs

Moving VuFind to Zend Framework 2: Part 5 — The Dreaded forward() Bug

IMPORTANT UPDATE: The problem discussed in this post only applies to Zend Framework 2.0 RC4 and earlier. Starting with RC5, a fix was introduced which eliminates the double-rendering issue described below. With the fix in place, you can do the logical thing of returning the output of $this->forward()->dispatch() rather than having to return false. Thanks to Nicholas Calugar, Matthew Weier O’Phinney, and all the others on zf-contributors and #zftalk.2 who talked to me about this problem and helped me refine my pull request to fix it.


It’s a law of software development that if you can’t explain some weird behavior and you choose to ignore it, it will inevitably come back to bite you. I know this very well, but knowing it doesn’t prevent it from happening.

The Problem

When I first implemented VuFind’s Flash Messenger view helper (designed to display status messages stored in the session), I ran into a strange problem. The behavior of the helper was simple: check the session for messages, display them, then clear the session. The problem was that flash messages never displayed. Eventually I just commented out the “clear the session” line and everything started working. I didn’t have time to figure out what was really going on, so I just put a note in the code to check it later, and moved on to other things.

The Real Problem

I kept running into bizarre flash messenger behavior, so I decided I needed to solve this problem for real rather than just putting on a band-aid. After digging deep into ZF2 and putting logging lines all over the place, I figured out what was causing the problem: many of my view templates were getting rendered twice. Even though the templates displayed on screen just once, the code was executing twice. This was the reason for my flash messenger problem: the first render displayed the messages and cleared them. The second render replaced the first, and by this point, the messages were gone.

The Root Cause

After a lot more digging and some extremely valuable help from mpinkston on the #zftalk.2 IRC channel, I discovered the root cause. Sometimes you want to forward from one controller action to another. In ZF1, you could use “return $this->_forward(…)” to achieve the effect. In ZF2, there is a controller plug-in called forward() that does the same basic thing. I was using it like this:


return $this->forward()->dispatch('controllerName', array('action' => 'actionName'));

Seems harmless enough, but what actually happens here is that the forward() plug-in dispatches an action, which causes ZF2 to attach a view model to the top-level layout object. The forward() plug-in then returns that view model. When the calling controller returns it, ZF2 attaches a second copy to the layout object. And then both copies get rendered!

What I should have been doing was this:


$this->forward()->dispatch('controllerName', array('action' => 'actionName'));
return false;

A simple, honest mistake with evil, subtle consequences.

The Solution

I’ve already found a solution to my immediate problem, as described above. I won’t make this mistake again, and VuFind’s flash messenger now works correctly. I was concerned that the solution would only work when forwarding to actions that return a ViewModel, but it seems to work for all cases, even when a Response is returned instead (i.e. when redirecting to another page).

I remain concerned that this is a big potential pitfall for users of ZF2 in general. It’s an easy mistake to make, and the consequences are extremely non-obvious, especially since in many cases, the only result of the mistake is a slight performance hit caused by duplicate work being done.

Hopefully this will be addressed in the future either by notes in the documentation or by the introduction of a convenience method in the forward() plugin that returns false instead of the actual output of the dispatched action. If either of these things had existed, I probably wouldn’t have spent the better part of a work day chasing this problem. But I don’t mean to criticize the ZF2 team — I like the framework, and these are the perils of working with software that is still under development. I just point this out as something to watch out for that should be addressed, one way or another, before the final 2.0 official release.


Like

Atchoo! available for proofreading

Atchoo!As mentioned in a previous post, we recently discovered some rare and fragile books in Falvey’s basement. As promised, the first of these titles is now available for online proofreading: Atchoo! Sneezes from a Hilarious Vaudevillian, which is essentially a stand-up comedy routine from 1903 transcribed to paper and peppered with illustrations. Needless to say, sensibilities have changed considerably since 1903, and some of the humor on display here is well outside the realm of political correctness. If you can stomach that, however, this is an interesting glimpse into the pop culture of an earlier era.

To learn more about the proofreading project and how you can help, see Proofreading the Digital Library.


Like

Kimberley Bugg Presents on Black Pop Culture

Kimberley Bugg, Information and Research Assistance team leader, presented a paper, “Fade to Black Popular Culture: An Electronic Annotated Index,” at the Popular Culture Association/American Culture Association annual conference in Boston on April 13.  Bugg’s paper “detailed the electronic annotated index with audible auto commentary on black popular culture.” Her presentation was part of the roundtable, “Embracing Engagement: Popular Technology and Academic Library Information Portals” and her project was partially funded by an award from the American Library Association (ALA) Carnegie-Whitney Grant.

Bugg serves as the Association of College & Research Libraries (ACRL) Popular Cultures convener for the discussion group that focuses on “hot topics.”  She is the outgoing ACRL Arts Film/Broadcast Studies  convener. In the last two years the group has sponsored talks dealing with ethical and legal issues related to Netflix and streaming video and copyright cases involving Georgia State University.

Bugg was also the chair of the ACRL Section Membership Committee.

Since joining the Library in December 2011, Bugg has actively explored alternative service and scheduling models and participated in social media committee work at Falvey.

 


Like

Want to know a secret? Look into declassified documents.

 

 

 

 

Try Declassified Documents Reference System (DDRS) (available until Sept. 28)

Background

In 1998, the systematic digitization and online publication of Declassified Documents Reference System (DDRS) was initiated by Gale Cengage Learning.  The process involves indexing, abstracting, and capturing on microfiche a large selection of U.S. government documents obtained from presidential libraries. These libraries receive declassified documents from various government agencies, including the White House, the CIA, the FBI, the State Department, and others. As researchers visit these presidential libraries and request documents, the libraries photocopy and provide for filming. The result is a collection of more than 75,000 documents, consisting of more than 465,000 pages, that has literally been built by researchers themselves for nearly two decades.

Searching

DDRS supports basic and advanced searching.  Basic search includes keyword and full-text searching.  Advanced discovery provides for searching by keyword/subject, title/abstract, source institution, and full-text, including the use of Boolean logic. Searches can be limited to a range of issue dates, a range of declassified dates, document type (such as bill, agenda, cable, airgram), source institution (such as agency, department, Supreme Court, Warren Commission), sanitized or unsanitized, completeness, number of pages.

Search history can be accessed during a search session. An InfoMark at the top of any page indicates that the URL of the page is persistent and can be bookmarked or copied for future reference.  Help links and search tips are also available.

Document facsimiles can be viewed as electronic text.  Document facsimiles can be scaled for ease of viewing, by choosing a size percentage. Facsimile documents can be viewed or printed as a PDF version but due to some excessive sizes cannot be emailed. Electronic texts of the documents can be emailed and printed.

Questions or comments? Contact me directly (merrill.stein@villanova.edu) or post your comments online.


Like

Ethical Dilemmas in a Brave New World

Eagerly awaited and long overdue, the second edition of the Encyclopedia of Applied Ethics is now available online through the library’s website. Over one hundred new articles address ethical topics which emerged since the publication of the first critically acclaimed edition in 1998. Browsing through the table of contents, the interested reader encounters a brave new world expressed in neologisms such as Savior Siblings, Genetic Exceptionalism, and Open Source Software, terminology which largely did not exist back in 1998. The fields of medical research and practice are well represented throughout the Encyclopedia with a strong emphasis on genetics. Interesting articles in the field of genetics include the new entries on the Human Genome Project, Genetic Ancestry, Genetics & Insurance, and Genetics & Crime. By comparison, the 1998 edition has a single entry on genetics.

Noteworthy among the new entries are articles on the Problem of Evil, Cyborgs, Obesity, Transhumanism, Global Public Goods and the Just War Theory. About thirty entries have been omitted from the new edition of the Encyclopedia. Missing from the new edition are Sexual Harassment, Corporal Punishment and Health Care Financing to name but a few examples. The Library will retain the first edition to ensure continued access to these materials.

The Encyclopedia of Applied Ethics is ideally suited for undergraduate students. Each article delivers a thorough introduction to its topic and concludes with a recommended reading list. Students may also browse the table of contents to generate ideas for topics. Some of the new entries in the Encyclopedia will be of special interest to undergraduate students who grew up with Facebook (Social Networking Sites) and Reality TV. Both topics have been added to the Encyclopedia.

Contributing authors are scholars and practitioners in the field. Each article includes a glossary and cross references which refer the reader to related articles. Articles can be read online, emailed or downloaded as pdf files. Entries include a convenient link to related peer-reviewed journal articles on the Science Direct platform. The new edition of the Encyclopedia of Applied Ethics is available online. Links to the online content can be found in the Library’s catalog as well as on the Ethics Research Guide.

Questions or comments? Contact me directly (jutta.seibert@villanova.edu) or post your comments online.


Like

E-ZBorrow Upgrade Complete

 

The upgrade to the E-ZBorrow system has been completed. If users encounter any technical problems, please contact Luisa Cywinski or Raamaan McBride at 610-519-4270.


Like

Fasten Your Seatbelts: Vacationland Reading in Window Display

The license plate says SMR RDG. One postcard reads “Escape to Yoknapatawpha!” Another proclaims “A Whale of a Time,” while a third suggests “Souvenir from Castlerock, Maine – where the road to hell is paved with adverbs.  S. King.”

Fictional landscapes are the theme of Joanne Quinn’s latest cultural window exhibit: You are invited to transport yourself by reading the works of Faulkner, Melville and Stephen King.

It is only after spending some time observing this display, at least for this viewer, that one realizes the license plate translates “Summer Reading.” And the names on the postcards are sites associated with the works of well known authors: Lothlorien is the home of the elves in J.R.R. Tolkien’s The Lord of the Rings; Winnemac is the fictional state created by Sinclair Lewis, who located a number of his books there; Hertfordshire is an actual English county where Jane Austen set her Pride and Prejudice; Castlerock, Maine, is the setting for Stephen King’s novel, Cujo. “A Whale of a Time” refers to Moby Dick by Herman Melville.

The window glass is covered with large facsimiles of postcards, the antique type featuring the name of a place. Other vacation objects are a large kite containing a smiling, sun-glasses-wearing sunburst and a group of beach balls. Scattered across the base of the window are stacks of recommended reading, images of automobile wheels, Speed Limit 55 signs, ice chests, book-filled tote bags and a colorful straw hat. Tiny cars run on black ribbons that are draped across the window, suggesting our favorite mode of vacation travel.

Stephanie Liu and Thiomarie Matta work on the window display.

Quinn, graphic designer, created and mounted the exhibit with the assistance of Ann Stango, Access Services specialist, and two Outreach team student workers, Stephanie Liu and Thiomarie Matta. Quinn says that Research Support Librarians Susan Ottignon and Judith Olsen worked with her to find obscure literary sites and “funny places.”

The exhibit will remain on view throughout the summer.

Finally, don’t forget: “Lilliput – The perfect vacation spot for big shots like you.”

 

Also contributing: Judith Olsen and Gerald Dierkes. Photographs by Alice Bampton.


Like

Alert: Elevator Out of Service

As of now, the library elevator is out of service. The elevator company has ordered a part which we hope will be installed tomorrow. If we can help you retrieve materials, please contact us at 610-519-4270 or at circ@villanova.edu. Our apologies for the inconvenience.


Like

A Day at LVJ 2012

By Alice Bampton

The LVJ Summer Institute brought librarians from La Salle University, Villanova University and Saint Joseph’s University to Saint Joseph’s campus on July 18, 2012, to discuss the latest in technology, physical space and trends in academic libraries.

Falvey staff played an active role in LVJ 2012. University Librarian, Joe Lucia, and members of the Communication and Publications team each gave presentations.

(l. to r.) Gerald Dierkes, Alice Bampton, Mary Heyman, Luisa Cywinski, Laura Hutelmyer, Joe Lucia

The afternoon session began with a “Marketing Update and Idea Swap,” in which Falvey Memorial Library’s Communication and Publications team explained the team’s various activities. Gerald Dierkes, senior copy editor, provided a brief history of the library’s various communi-cations outlets, culminating in Falvey’s blog. Alice Bampton—people, Special Collections, exhibits and photography— explained the process for reporting on exhibits and events. Laura Hutelmyer, photography coordinator and features, discussed images and photos, as well as the Library’s newsletter. Luisa Cywinski—services, policies, online publishing and newswires—described Falvey’s use of social media.

In the next session Joe Fennewald, head of the Tombros McWhirter Knowledge Commons, Penn State University, shared insights from the creation of the Knowledge Commons

Joe Lucia outlined the goals, challenges and benefits of creating Falvey’s Learning Commons.

And Evelyn Minick, library director of the Post Learning Commons/Drexel Library at Saint Joseph’s University discussed issues in academic library building design

In the morning, Robert J. Lackie, MLIS, MA, presented “Protecting Your Digital Footprint at Work, Home and on the Road: 15 Tips on ID Theft in 60 Minutes.” Lackie is a professor and librarian at the Moore Library at Rider University. After a lively question and answer session, participants enjoyed lunch and tours of the Post Academic Center. Completed in March 2012, the 35,000-square-foot, three-story addition to Saint Joseph’s Drexel Library illustrates the epitome of 21st century academic libraries.

In addition to Lucia and members of the Communication and Publications team, several other Falvey librarians attended this year’s LVJ event.

LVJ (La Salle, Villanova, Saint Joseph’s) is almost ten years old. Joe Lucia initiated it, working with John Baky, director of libraries at La Salle, and Evelyn Minick of St. Joe’s. LVJ meets each summer. It is designed to provide librarians and staff from the three universities an opportunity for professional development.

 


Like

« Previous Page

 


Last Modified: August 1, 2012

Ask Us: Live Chat
Back to Top