An appeals court ruling made it temporarily legal to possess Ecstasy and other drugs in Ireland.

Story highlights

NEW: The president signs emergency legislation

The loophole opened when an appeals court struck down part of Ireland's drug law

CNN  — 

Well, it was weird while it lasted.

On Wednesday, lawmakers in Ireland rushed to close a loophole that temporarily made it legal to possess Ecstasy, crystal methamphetamine, ketamine, magic mushrooms and a host of other recreational drugs.

The loophole was inadvertently opened the day before, when an appeals court invalidated one section of the Misuse of Drugs Act 1977.

The court ruled that Irish governments had been unconstitutionally adding substances to Section 2 of the law for decades.

“We prepared for this possibility. Legislation was prepared and approved in advance by Cabinet,” Minister for Health Leo Varadkar said in a written statement. “The emergency legislation … will re-instate the status quo ante and re-control all drugs that were controlled prior to this judgment.”

The emergency law moved through the Irish legislature and was signed by the President on Wednesday, meaning that the drugs would become illegal to possess again at midnight, a Department of Health spokeswoman told CNN.

Varadkar said the temporarily legalized substances – which include a wide array of synthetic or “head shop” drugs – “all have very significant health risks that outweigh any perceived recreational benefits,” according to the Irish Times.

The original schedule of substances listed in the 1977 law – including cannabis, cocaine and heroin – were untouched by the appeals court ruling and remained illegal.

Varadkar also told the Irish Times that the court ruling could affect “dozens” of cases, although The Journal of Ireland said the court’s decision will affect only cases now in the judicial process.