[dw-free] strip unused functions from .pms in cgi-bin
[commit: http://hg.dwscoalition.org/dw-free/rev/c52accb4cf9a]
http://bugs.dwscoalition.org/show_bug.cgi?id=1379
Remove unused functions (round 2).
Patch by
denise.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=1379
Remove unused functions (round 2).
Patch by
![[staff profile]](https://www.dreamwidth.org/img/silk/identity/user_staff.png)
Files modified:
- cgi-bin/ljlang.pl
- cgi-bin/ljmemories.pl
- cgi-bin/supportstatslib.pl
-------------------------------------------------------------------------------- diff -r 95cbf3152cf5 -r c52accb4cf9a cgi-bin/ljlang.pl --- a/cgi-bin/ljlang.pl Mon Aug 03 12:31:29 2009 -0500 +++ b/cgi-bin/ljlang.pl Mon Aug 03 13:41:30 2009 -0500 @@ -214,16 +214,6 @@ sub init_cvsprefixes { } } $cvspfx_local ||= ""; -} - -sub cvsprefix_shared { - init_cvsprefixes(); - return $cvspfx_shared; -} - -sub cvsprefix_local { - init_cvsprefixes(); - return $cvspfx_local; } sub langdat_file_of_lang_itcode diff -r 95cbf3152cf5 -r c52accb4cf9a cgi-bin/ljmemories.pl --- a/cgi-bin/ljmemories.pl Mon Aug 03 12:31:29 2009 -0500 +++ b/cgi-bin/ljmemories.pl Mon Aug 03 13:41:30 2009 -0500 @@ -391,38 +391,38 @@ sub get_keywordids { # you want to update the memory to have. # returns: 1 on success, undef on error # </LJFUNC> -sub update_memory { - my ($u, $memid, $upd) = @_; - $u = LJ::want_user($u); - $memid += 0; - return unless $u && $memid && %{$upd || {}}; - - # get database handle - my ($db, $table) = $u->{dversion} > 5 ? - ($u, '2') : - (LJ::get_db_writer(), ''); - return undef unless $db; - - # construct update lines... only valid things we can update are des and security - my @updates; - my $security_updated; - foreach my $what (keys %$upd) { - next unless $what =~ m/^(?:des|security)$/; - $security_updated = 1 if $what eq 'security'; - push @updates, "$what=" . $db->quote($upd->{$what}); - } - my $updstr = join ',', @updates; - - # now perform update - $db->do("UPDATE memorable$table SET $updstr WHERE userid = ? AND memid = ?", - undef, $u->{userid}, $memid); - return undef if $db->err; - - # Delete memcache entries if the security of the memory was updated - clear_memcache($u) if $security_updated; - - return 1; -} +# sub update_memory { +# my ($u, $memid, $upd) = @_; +# $u = LJ::want_user($u); +# $memid += 0; +# return unless $u && $memid && %{$upd || {}}; +# +# # get database handle +# my ($db, $table) = $u->{dversion} > 5 ? +# ($u, '2') : +# (LJ::get_db_writer(), ''); +# return undef unless $db; +# +# # construct update lines... only valid things we can update are des and security +# my @updates; +# my $security_updated; +# foreach my $what (keys %$upd) { +# next unless $what =~ m/^(?:des|security)$/; +# $security_updated = 1 if $what eq 'security'; +# push @updates, "$what=" . $db->quote($upd->{$what}); +# } +# my $updstr = join ',', @updates; +# +# # now perform update +# $db->do("UPDATE memorable$table SET $updstr WHERE userid = ? AND memid = ?", +# undef, $u->{userid}, $memid); +# return undef if $db->err; +# +# # Delete memcache entries if the security of the memory was updated +# clear_memcache($u) if $security_updated; +# +# return 1; +# } # this messy function gets memories based on an options hashref. this is an # API API and isn't recommended for use by BML etc... add to the API and have @@ -537,13 +537,13 @@ sub _memory_getter { # des-memids: The rest of the memory ids. Array. (Pass them in as individual parameters...) # returns: Hashref of memories with keys being memid; undef on error. # </LJFUNC> -sub get_by_id { - my $u = shift; - return {} unless @_; # make sure they gave us some ids - - # pass to getter to get by id - return LJ::Memories::_memory_getter($u, { byid => [ map { $_+0 } @_ ] }); -} +# sub get_by_id { +# my $u = shift; +# return {} unless @_; # make sure they gave us some ids +# +# # pass to getter to get by id +# return LJ::Memories::_memory_getter($u, { byid => [ map { $_+0 } @_ ] }); +# } # <LJFUNC> # name: LJ::Memories::get_by_ditemid @@ -576,10 +576,10 @@ sub get_by_ditemid { # des-uuobj: User id or user object to get memories for. # returns: Hashref of memories with keys being memid; undef on error. # </LJFUNC> -sub get_by_user { - # simply passes through to _memory_getter - return LJ::Memories::_memory_getter(@_); -} +# sub get_by_user { +# # simply passes through to _memory_getter +# return LJ::Memories::_memory_getter(@_); +# } # <LJFUNC> # name: LJ::Memories::get_by_keyword diff -r 95cbf3152cf5 -r c52accb4cf9a cgi-bin/supportstatslib.pl --- a/cgi-bin/supportstatslib.pl Mon Aug 03 12:31:29 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,129 +0,0 @@ -#!/usr/bin/perl -# -# This library is used by Support Stats. -# -# In particular, it's used by the following pages: -# - htdocs/admin/support/dept.bml -# - htdocs/admin/support/individual.bml -# -# This library doesn't have any DB access routines. -# All DB access routines are in supportlib.pl -# - -use strict; -package LJ::Support::Stats; -use vars qw($ALL_CATEGORIES_ID); - -use Carp qw(croak); -use DateTime; - -# Constants -$ALL_CATEGORIES_ID = -1; - -# <LJFUNC> -# name: LJ::Support::Stats::filter_support_by_category -# des: Filter Support by Category ID. -# args: support -# des-support: HashRef of Support Rows indexed by Support ID. -# info: Used by dept.bml and individual.bml under -# htdocs/admin/support/. -# All DB access routines are in supportlib.pl. -# Return: Filtered HashRef of Support Rows. -# </LJFUNC> -sub filter_support_by_category { - my($support_hashref, $category_id_parm) = @_; - - return $support_hashref if $category_id_parm == $ALL_CATEGORIES_ID; - - my %filtered_support = (); - while (my($support_id, $support) = each %{$support_hashref}) { - $filtered_support{$support_id} = $support - if $support->{spcatid} == $category_id_parm; - } - - return \%filtered_support; -} - -# <LJFUNC> -# name: LJ::Support::Stats::date_formatter -# des: Format a date -# args: year, month, day -# des-year: Four digit year (e.g. 2001) -# des-month: One-based numeric month: 1-12 -# des-day: One-based numeric day: 1-31 -# info: Used by dept.bml and individual.bml under -# htdocs/admin/support/. -# All DB access routines are in supportlib.pl. -# Return: Date formatted as follows: YYYY-MM-DD -# </LJFUNC> -sub date_formatter { - croak('Not enough parameters') if @_ < 3; - my($year, $month, $day) = @_; - my $date = sprintf("%04d-%02d-%02d", $year, $month, $day); - return $date; -} - -# <LJFUNC> -# name: LJ::Support::Stats::comma_formatter -# des: Format a number with commas -# args: number -# des-number: number to commafy. -# info: Used by dept.bml and individual.bml under -# htdocs/admin/support/. -# All DB access routines are in supportlib.pl. -# Return: Number with commas inserted. -# </LJFUNC> -sub comma_formatter { - my $number = shift or croak('No parameter for comma_formatter'); - 1 while ($number =~ s/([-+]?\d+)(\d\d\d\.?)(?!\d)/$1,$2/); - return $number; -}; - - -# <LJFUNC> -# name: LJ::Support::Stats::percent_formatter -# des: Format a percentage: Take integer portion and append percent sign. -# args: percent -# des-percent: Number to format as a percentage. -# info: Used by dept.bml and individual.bml under -# htdocs/admin/support/. -# All DB access routines are in supportlib.pl. -# Return: Formatted percentage. -# </LJFUNC> -sub percent_formatter { - my $percent = shift; - $percent = int($percent) . '%'; - return $percent; -}; - -# <LJFUNC> -# name: LJ::Support::Stats::get_grains_from_seconds -# des: Determine the grains (day/week/month/year) of given a date -# args: seconds -# des-seconds: Seconds since Unix epoch. -# info: Used by dept.bml and individual.bml under -# htdocs/admin/support/. -# All DB access routines are in supportlib.pl. -# Return: HashRef of Grains. -# </LJFUNC> -sub get_grains_from_seconds { - my $seconds_since_epoch = shift or croak('No parameter specified'); - - my $date = LJ::mysql_time($seconds_since_epoch); - - my %grain; - $grain{grand} = 'Grand'; - $grain{day} = substr($date, 0, 10); - $grain{month} = substr($date, 0, 7); - $grain{year} = substr($date, 0, 4); - - # Get week of Support Ticket - my $dt = DateTime->from_epoch( epoch => $seconds_since_epoch ); - my($week_year, $week_number) = $dt->week; - $grain{week} = $week_year . ' - Week #' . sprintf('%02d', $week_number); - - return \%grain; -} - - -1; --------------------------------------------------------------------------------