From 0bd26ed3f07e349129e6e72576f081f493779a78 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Thu, 15 Sep 2011 16:16:58 -0700 Subject: [PATCH 1/2] Store a list of all paths the router knows about (backward compatibility with Net_URL_Mapper) --- lib/urlmapper.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/urlmapper.php b/lib/urlmapper.php index fcaa66a553..d17493e21d 100644 --- a/lib/urlmapper.php +++ b/lib/urlmapper.php @@ -4,7 +4,7 @@ * Copyright (C) 2011, StatusNet, Inc. * * URL mapper - * + * * PHP version 5 * * This program is free software: you can redistribute it and/or modify @@ -40,7 +40,7 @@ if (!defined('STATUSNET')) { * Converts a path into a set of parameters, and vice versa * * We used to use Net_URL_Mapper, so there's a wrapper class at Router, q.v. - * + * * NUM's vagaries are the main reason we have weirdnesses here. * * @category URL @@ -58,6 +58,7 @@ class URLMapper protected $statics = array(); protected $variables = array(); protected $reverse = array(); + protected $allpaths = array(); function connect($path, $args, $paramPatterns=array()) { @@ -65,6 +66,8 @@ class URLMapper throw new Exception(sprintf("Can't connect %s; path has no action.", $path)); } + $allpaths[] = $path; + $action = $args[self::ACTION]; $paramNames = $this->getParamNames($path); @@ -119,7 +122,7 @@ class URLMapper return $results; } } - + throw new Exception(sprintf('No match for path "%s"', $path)); } @@ -173,7 +176,7 @@ class URLMapper $path = vsprintf($format, $toFormat); } - if (!empty($qstring)) { + if (!empty($qstring)) { $formatted = http_build_query($qstring); $path .= '?' . $formatted; } @@ -223,6 +226,11 @@ class URLMapper return $format; } + + public function getPaths() + { + return $this->allpaths; + } } class PatternReplacer From dcbf2f6871de7cd26815334b6977792e2b2f31df Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Thu, 15 Sep 2011 16:52:23 -0700 Subject: [PATCH 2/2] Better error handling when the email subsystem isn't working. The installer was dying trying to send a confirmation email to the initial user. --- lib/mail.php | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/lib/mail.php b/lib/mail.php index 3f8a08f3ca..c93464a586 100644 --- a/lib/mail.php +++ b/lib/mail.php @@ -71,18 +71,25 @@ function mail_backend() */ function mail_send($recipients, $headers, $body) { - // XXX: use Mail_Queue... maybe - $backend = mail_backend(); - if (!isset($headers['Content-Type'])) { - $headers['Content-Type'] = 'text/plain; charset=UTF-8'; - } - assert($backend); // throws an error if it's bad - $sent = $backend->send($recipients, $headers, $body); - if (PEAR::isError($sent)) { - common_log(LOG_ERR, 'Email error: ' . $sent->getMessage()); + try { + // XXX: use Mail_Queue... maybe + $backend = mail_backend(); + + if (!isset($headers['Content-Type'])) { + $headers['Content-Type'] = 'text/plain; charset=UTF-8'; + } + + assert($backend); // throws an error if it's bad + $sent = $backend->send($recipients, $headers, $body); + return true; + } catch (PEAR_Exception $e) { + common_log( + LOG_ERR, + "Unable to send email - '{$e->getMessage()}'. " + . 'Is your mail subsystem set up correctly?' + ); return false; } - return true; } /**